Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/projects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,6 @@ def get_current_stories
end

def project_params
params.require(:project).permit(:title, :description, :pitch, :created, :status, :user_id, :github_url, :pivotaltracker_url, :pivotaltracker_id, :image_url, source_repositories_attributes: [:id, :url, :_destroy])
params.require(:project).permit(:title, :description, :pitch, :created, :status, :user_id, :github_url, :pivotaltracker_url, :pivotaltracker_id, :slack_channel_name, :image_url, source_repositories_attributes: [:id, :url, :_destroy])
end
end
10 changes: 10 additions & 0 deletions app/views/projects/_connections.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,14 @@
<% else %>
<p><i class="fa fa-gear fa-lg"></i> <span class="small">not linked to IssueTracker</span></p>
<% end %>

<% if @project.slack_channel_name.present? %>
<p><i class="fa fa-slack" aria-hidden="true"></i>
<span class="small">
<%= link_to "#{@project.title} ", "https://agileventures.slack.com/app_redirect?channel=#{@project.slack_channel_name}" %>on Slack
</span>
</p>
<% else %>
<p><i class="fa fa-gear fa-lg"></i> <span class="small">not linked to Slack</span></p>
<% end %>
</aside>
4 changes: 3 additions & 1 deletion app/views/projects/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

<%= awesome_text_field f, :pivotaltracker_url, label_text: 'Issue Tracker link', placeholder: 'https://www.pivotaltracker.com/s/projects/id' %>

<%= awesome_text_field f, :slack_channel_name, label_text: 'Slack channel name', placeholder: 'project_slack_channel_name' %>

<% if @project.new_record? %>
<div class="form-group">
<h3>New project checklist</h3>
Expand All @@ -40,4 +42,4 @@
</div>
<% end %>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddSlackChannelNameToProjects < ActiveRecord::Migration[5.1]
def change
add_column :projects, :slack_channel_name, :string
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20180515093331) do
ActiveRecord::Schema.define(version: 20180729040001) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -183,6 +183,7 @@
t.integer "commit_count", default: 0
t.string "image_url"
t.datetime "last_github_update"
t.string "slack_channel_name"
t.index ["slug"], name: "index_projects_on_slug", unique: true
t.index ["user_id"], name: "index_projects_on_user_id"
end
Expand Down
44 changes: 44 additions & 0 deletions features/projects/connections.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
Feature: Projects should show links to the connected APIs
As a User
So that I can easily navigate to Project apps
I want to see all connected app links on the show page

Background:
Given the following users exist
| first_name | last_name | email | receive_mailings |
| Bill | Bob | [email protected] | true |

Given the following projects exist:
| title | description | status | author | pivotaltracker_url | github_url | slack_channel_name |
| hello | earthlings | active | Bill | https://www.pivotaltracker.com/n/projects/742821 | https://github.com/hello | hello_earthlings |
| Bat Man | All bat | active | Bill | | | |

Scenario: I can see a link to the GitHub project page
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if some of this could be condensed down with a "Scenario Outline"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I will take a look at that!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feel free to open a new refactoring ticket for that :-)

When I go to the "hello" project "show" page
Then I should see "hello on GitHub"
And I should see a link to "hello" on github

Scenario: I can see when a project is not connected to GitHub
When I go to the "Bat Man" project "show" page
Then I should not see "Bat Man on GitHub"
And I should see "not linked to GitHub"

Scenario: I can see a link to the projects issue tracker
When I go to the "hello" project "show" page
Then I should see "hello on IssueTracker"
And I should see a link to "hello" on Pivotal Tracker

Scenario: I can see when a project is not connected to issue tracker
When I go to the "Bat Man" project "show" page
Then I should not see "Bat Man on IssueTracker"
And I should see "not linked to IssueTracker"

Scenario: I can see a link to the projects slack channel
When I go to the "hello" project "show" page
Then I should see "hello on Slack"
And I should see a link to the slack channel for "hello"

Scenario: I can see when a project is not connected to slack
When I go to the "Bat Man" project "show" page
Then I should not see "Bat Man on Slack"
And I should see "not linked to Slack"
4 changes: 3 additions & 1 deletion features/projects/create_projects.feature
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Feature: Create projects
| Status |
| GitHub url (primary) |
| Issue Tracker link |
| Slack channel name |

Scenario Outline: Saving a new project: success
Given I have logged in
Expand All @@ -35,6 +36,7 @@ Feature: Create projects
And I fill in "Description" with "<description>"
And I fill in "GitHub url (primary)" with "<gh_link>"
And I fill in "Issue Tracker link" with "<pt_link>"
And I fill in "Slack channel name" with "slackin"
And I select "Status" to "Active"
And I click the "Submit" button
Then I should be on the "Show" page for project "<title>"
Expand All @@ -46,6 +48,7 @@ Feature: Create projects
| ACTIVE |
And I should see a link to "<title>" on github
And I should see a link to "<title>" on Pivotal Tracker
And I should see a link to the slack channel for "<title>"

Examples:
| title | description | gh_link | pt_link |
Expand Down Expand Up @@ -83,4 +86,3 @@ Feature: Create projects
| ACTIVE |
And I should see a link to "multiple repo project" on github
And I should see a link to "multiple repo project" on Pivotal Tracker

8 changes: 8 additions & 0 deletions features/projects/edit_project.feature
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,22 @@ Feature: Edit Project
When I click "Back"
Then I should be on the "Show" page for project "hello mars"

@javascript
Scenario: Updating a project: success
Given I have logged in
And I am on the "Edit" page for project "hello mars"
And I fill in "Description" with "Hello, Uranus!"
And I click "Add more repos"
And I fill in "GitHub url (primary)" with "https://github.com/google/instant-hangouts"
And I fill in "Issue Tracker link" with "https://www.pivotaltracker.com/s/projects/853345"
And I fill in "Slack channel name" with "slackin"
And I click the "Submit" button
Then I should be on the "Show" page for project "hello mars"
And I should see a success flash "Project was successfully updated."
And I should see "Hello, Uranus!"
And I should see a link to "hello mars" on github
And I should see a link to "hello mars" on Pivotal Tracker
And I should see a link to the slack channel for "hello mars"

Scenario: Saving a project: failure
Given I have logged in
Expand All @@ -53,9 +57,11 @@ Feature: Edit Project
And I click the "Submit" button
Then I should see "Project was not updated."

@javascript
Scenario: Update GitHub url if valid
Given I have logged in
And I am on the "Edit" page for project "hello mars"
And I click "Add more repos"
And I fill in "GitHub url (primary)" with "https://github.com/google/instant-hangouts"
And I click the "Submit" button
Then I should be on the "Show" page for project "hello mars"
Expand All @@ -69,9 +75,11 @@ Feature: Edit Project
Then I should be on the "Show" page for project "hello mars"
And I should see a link to "hello mars" on Pivotal Tracker

@javascript
Scenario: Reject GitHub url update if invalid
Given I have logged in
And I am on the "Edit" page for project "hello mars"
And I click "Add more repos"
And I fill in "GitHub url (primary)" with "https:/github.com/google/instant-hangouts"
And I click the "Submit" button
Then I should see "Project was not updated."
7 changes: 5 additions & 2 deletions features/step_definitions/projects_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
end
if hash[:github_url].present?
project.source_repositories.build(url: hash[:github_url])
else
project.source_repositories.build
end
if hash[:tags]
project.tag_list.add(hash[:tags], parse: true)
Expand Down Expand Up @@ -116,6 +114,11 @@
step %Q{I #{option} see link "#{object.title}"}
end

Then /^I should see a link to the slack channel for "([^"]*)"$/ do |project_title|
project = Project.find_by title: project_title
expect(page).to have_link project_title, href: "https://agileventures.slack.com/app_redirect?channel=#{project.slack_channel_name}"
end

Given(/^The project "([^"]*)" has (\d+) (.*)$/) do |title, num, item|
project = Project.find_by_title(title)
case item.downcase.pluralize
Expand Down