Skip to content

Commit 28b69fa

Browse files
NickSchimektansaku
authored andcommitted
Add Slack channel link to the projects show page (AgileVentures#2498)
* Add tests for viewing the projects API links * Add slack channel link to show page Added link for the projects slack channel. This is needed to so that individuals can easily find a projects slack channel. Fix AgileVentures#770 * Add slack channel name to tests Updated the background job to include the slack channel for the hello project * Update slack link assertion Updated the assertion to check for the slack channel name instead of the Project title since project title will not always be the same as the slack channel name. * Run migration to add slack channel name Added slack_channel_name to projects table. Storing the slack channel name for each project will allow us to create links that direct users to the correct slack channel for the project. * Update link to use the slack channel name * Fix grammar in cucumber test * Add CRUD tests for slack channel name * Update CRUD views to include slack channel name * Add test for when slack channel does not exist Added to test to check that the view renders revelant information when a slack channel does not exist. * Update view to render correct slack status The view was updated to render "not linked to Slack" when the project doesn't have a slack channel name associated to it. * Update test to check the views else route The github test is now failing for this, but it's working locally and in production which means there is a bug somewhere in the tests. * Remove building source repository When a github link is not present a source repository should not be built as this was causing the project to have a github source repository even though the link is nil. * Update tests now that source repo is not built There are three tests failing due to the source repository not being built for every project regardless if there is a valid github link. Source repo's should only exist when there are github links associated to a project. These three tests were trying to add github links to a project that didn't previously had a github link, hence the button needed to be clicked before the value could be filled in. * Replace hard link with param name * Permit slack channel name params
1 parent d7b32e9 commit 28b69fa

File tree

9 files changed

+81
-6
lines changed

9 files changed

+81
-6
lines changed

app/controllers/projects_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,6 @@ def get_current_stories
107107
end
108108

109109
def project_params
110-
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])
110+
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])
111111
end
112112
end

app/views/projects/_connections.html.erb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,14 @@
1515
<% else %>
1616
<p><i class="fa fa-gear fa-lg"></i> <span class="small">not linked to IssueTracker</span></p>
1717
<% end %>
18+
19+
<% if @project.slack_channel_name.present? %>
20+
<p><i class="fa fa-slack" aria-hidden="true"></i>
21+
<span class="small">
22+
<%= link_to "#{@project.title} ", "https://agileventures.slack.com/app_redirect?channel=#{@project.slack_channel_name}" %>on Slack
23+
</span>
24+
</p>
25+
<% else %>
26+
<p><i class="fa fa-gear fa-lg"></i> <span class="small">not linked to Slack</span></p>
27+
<% end %>
1828
</aside>

app/views/projects/_form.html.erb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

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

25+
<%= awesome_text_field f, :slack_channel_name, label_text: 'Slack channel name', placeholder: 'project_slack_channel_name' %>
26+
2527
<% if @project.new_record? %>
2628
<div class="form-group">
2729
<h3>New project checklist</h3>
@@ -40,4 +42,4 @@
4042
</div>
4143
<% end %>
4244
</div>
43-
</div>
45+
</div>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddSlackChannelNameToProjects < ActiveRecord::Migration[5.1]
2+
def change
3+
add_column :projects, :slack_channel_name, :string
4+
end
5+
end

db/schema.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111
# It's strongly recommended that you check this file into your version control system.
1212

13-
ActiveRecord::Schema.define(version: 20180515093331) do
13+
ActiveRecord::Schema.define(version: 20180729040001) do
1414

1515
# These are extensions that must be enabled in order to support this database
1616
enable_extension "plpgsql"
@@ -183,6 +183,7 @@
183183
t.integer "commit_count", default: 0
184184
t.string "image_url"
185185
t.datetime "last_github_update"
186+
t.string "slack_channel_name"
186187
t.index ["slug"], name: "index_projects_on_slug", unique: true
187188
t.index ["user_id"], name: "index_projects_on_user_id"
188189
end
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
Feature: Projects should show links to the connected APIs
2+
As a User
3+
So that I can easily navigate to Project apps
4+
I want to see all connected app links on the show page
5+
6+
Background:
7+
Given the following users exist
8+
| first_name | last_name | email | receive_mailings |
9+
| Bill | Bob | Bill@example.com | true |
10+
11+
Given the following projects exist:
12+
| title | description | status | author | pivotaltracker_url | github_url | slack_channel_name |
13+
| hello | earthlings | active | Bill | https://www.pivotaltracker.com/n/projects/742821 | https://github.com/hello | hello_earthlings |
14+
| Bat Man | All bat | active | Bill | | | |
15+
16+
Scenario: I can see a link to the GitHub project page
17+
When I go to the "hello" project "show" page
18+
Then I should see "hello on GitHub"
19+
And I should see a link to "hello" on github
20+
21+
Scenario: I can see when a project is not connected to GitHub
22+
When I go to the "Bat Man" project "show" page
23+
Then I should not see "Bat Man on GitHub"
24+
And I should see "not linked to GitHub"
25+
26+
Scenario: I can see a link to the projects issue tracker
27+
When I go to the "hello" project "show" page
28+
Then I should see "hello on IssueTracker"
29+
And I should see a link to "hello" on Pivotal Tracker
30+
31+
Scenario: I can see when a project is not connected to issue tracker
32+
When I go to the "Bat Man" project "show" page
33+
Then I should not see "Bat Man on IssueTracker"
34+
And I should see "not linked to IssueTracker"
35+
36+
Scenario: I can see a link to the projects slack channel
37+
When I go to the "hello" project "show" page
38+
Then I should see "hello on Slack"
39+
And I should see a link to the slack channel for "hello"
40+
41+
Scenario: I can see when a project is not connected to slack
42+
When I go to the "Bat Man" project "show" page
43+
Then I should not see "Bat Man on Slack"
44+
And I should see "not linked to Slack"

features/projects/create_projects.feature

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Feature: Create projects
2626
| Status |
2727
| GitHub url (primary) |
2828
| Issue Tracker link |
29+
| Slack channel name |
2930

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

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

features/projects/edit_project.feature

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,22 @@ Feature: Edit Project
3333
When I click "Back"
3434
Then I should be on the "Show" page for project "hello mars"
3535

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

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

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

78+
@javascript
7279
Scenario: Reject GitHub url update if invalid
7380
Given I have logged in
7481
And I am on the "Edit" page for project "hello mars"
82+
And I click "Add more repos"
7583
And I fill in "GitHub url (primary)" with "https:/github.com/google/instant-hangouts"
7684
And I click the "Submit" button
7785
Then I should see "Project was not updated."

features/step_definitions/projects_steps.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
end
1414
if hash[:github_url].present?
1515
project.source_repositories.build(url: hash[:github_url])
16-
else
17-
project.source_repositories.build
1816
end
1917
if hash[:tags]
2018
project.tag_list.add(hash[:tags], parse: true)
@@ -116,6 +114,11 @@
116114
step %Q{I #{option} see link "#{object.title}"}
117115
end
118116

117+
Then /^I should see a link to the slack channel for "([^"]*)"$/ do |project_title|
118+
project = Project.find_by title: project_title
119+
expect(page).to have_link project_title, href: "https://agileventures.slack.com/app_redirect?channel=#{project.slack_channel_name}"
120+
end
121+
119122
Given(/^The project "([^"]*)" has (\d+) (.*)$/) do |title, num, item|
120123
project = Project.find_by_title(title)
121124
case item.downcase.pluralize

0 commit comments

Comments
 (0)