Commit 4db87f7c4bd46983c1aad8ed7cc7338ca7bbf72e
1 parent
4525fc84
Exists in
master
and in
4 other branches
Integration with Assembla
Showing
5 changed files
with
118 additions
and
1 deletions
Show diff stats
@@ -0,0 +1,45 @@ | @@ -0,0 +1,45 @@ | ||
1 | +# == Schema Information | ||
2 | +# | ||
3 | +# Table name: services | ||
4 | +# | ||
5 | +# id :integer not null, primary key | ||
6 | +# type :string(255) | ||
7 | +# title :string(255) | ||
8 | +# token :string(255) | ||
9 | +# project_id :integer not null | ||
10 | +# created_at :datetime not null | ||
11 | +# updated_at :datetime not null | ||
12 | +# active :boolean default(FALSE), not null | ||
13 | +# project_url :string(255) | ||
14 | +# subdomain :string(255) | ||
15 | +# room :string(255) | ||
16 | +# | ||
17 | + | ||
18 | +class AssemblaService < Service | ||
19 | + include HTTParty | ||
20 | + | ||
21 | + validates :token, presence: true, if: :activated? | ||
22 | + | ||
23 | + def title | ||
24 | + 'Assembla' | ||
25 | + end | ||
26 | + | ||
27 | + def description | ||
28 | + 'Project Management Software (Source Commits Endpoint)' | ||
29 | + end | ||
30 | + | ||
31 | + def to_param | ||
32 | + 'assembla' | ||
33 | + end | ||
34 | + | ||
35 | + def fields | ||
36 | + [ | ||
37 | + { type: 'text', name: 'token', placeholder: '' } | ||
38 | + ] | ||
39 | + end | ||
40 | + | ||
41 | + def execute(push) | ||
42 | + url = "https://atlas.assembla.com/spaces/ouposp/github_tool?secret_key=#{token}" | ||
43 | + AssemblaService.post(url, body: { payload: push }.to_json, headers: { 'Content-Type' => 'application/json' }) | ||
44 | + end | ||
45 | +end |
app/models/project.rb
@@ -50,6 +50,7 @@ class Project < ActiveRecord::Base | @@ -50,6 +50,7 @@ class Project < ActiveRecord::Base | ||
50 | has_one :pivotaltracker_service, dependent: :destroy | 50 | has_one :pivotaltracker_service, dependent: :destroy |
51 | has_one :hipchat_service, dependent: :destroy | 51 | has_one :hipchat_service, dependent: :destroy |
52 | has_one :flowdock_service, dependent: :destroy | 52 | has_one :flowdock_service, dependent: :destroy |
53 | + has_one :assembla_service, dependent: :destroy | ||
53 | has_one :forked_project_link, dependent: :destroy, foreign_key: "forked_to_project_id" | 54 | has_one :forked_project_link, dependent: :destroy, foreign_key: "forked_to_project_id" |
54 | has_one :forked_from_project, through: :forked_project_link | 55 | has_one :forked_from_project, through: :forked_project_link |
55 | 56 | ||
@@ -224,7 +225,7 @@ class Project < ActiveRecord::Base | @@ -224,7 +225,7 @@ class Project < ActiveRecord::Base | ||
224 | end | 225 | end |
225 | 226 | ||
226 | def available_services_names | 227 | def available_services_names |
227 | - %w(gitlab_ci campfire hipchat pivotaltracker flowdock) | 228 | + %w(gitlab_ci campfire hipchat pivotaltracker flowdock assembla) |
228 | end | 229 | end |
229 | 230 | ||
230 | def gitlab_ci? | 231 | def gitlab_ci? |
features/project/service.feature
@@ -30,3 +30,9 @@ Feature: Project Services | @@ -30,3 +30,9 @@ Feature: Project Services | ||
30 | And I click Flowdock service link | 30 | And I click Flowdock service link |
31 | And I fill Flowdock settings | 31 | And I fill Flowdock settings |
32 | Then I should see Flowdock service settings saved | 32 | Then I should see Flowdock service settings saved |
33 | + | ||
34 | + Scenario: Activate Assembla service | ||
35 | + When I visit project "Shop" services page | ||
36 | + And I click Assembla service link | ||
37 | + And I fill Assembla settings | ||
38 | + Then I should see Assembla service settings saved | ||
33 | \ No newline at end of file | 39 | \ No newline at end of file |
features/steps/project/project_services.rb
@@ -12,6 +12,7 @@ class ProjectServices < Spinach::FeatureSteps | @@ -12,6 +12,7 @@ class ProjectServices < Spinach::FeatureSteps | ||
12 | page.should have_content 'Campfire' | 12 | page.should have_content 'Campfire' |
13 | page.should have_content 'Hipchat' | 13 | page.should have_content 'Hipchat' |
14 | page.should have_content 'GitLab CI' | 14 | page.should have_content 'GitLab CI' |
15 | + page.should have_content 'Assembla' | ||
15 | end | 16 | end |
16 | 17 | ||
17 | And 'I click gitlab-ci service link' do | 18 | And 'I click gitlab-ci service link' do |
@@ -72,4 +73,18 @@ class ProjectServices < Spinach::FeatureSteps | @@ -72,4 +73,18 @@ class ProjectServices < Spinach::FeatureSteps | ||
72 | Then 'I should see Flowdock service settings saved' do | 73 | Then 'I should see Flowdock service settings saved' do |
73 | find_field('Token').value.should == 'verySecret' | 74 | find_field('Token').value.should == 'verySecret' |
74 | end | 75 | end |
76 | + | ||
77 | + And 'I click Assembla service link' do | ||
78 | + click_link 'Assembla' | ||
79 | + end | ||
80 | + | ||
81 | + And 'I fill Assembla settings' do | ||
82 | + check 'Active' | ||
83 | + fill_in 'Token', with: 'verySecret' | ||
84 | + click_button 'Save' | ||
85 | + end | ||
86 | + | ||
87 | + Then 'I should see Assembla service settings saved' do | ||
88 | + find_field('Token').value.should == 'verySecret' | ||
89 | + end | ||
75 | end | 90 | end |
@@ -0,0 +1,50 @@ | @@ -0,0 +1,50 @@ | ||
1 | +# == Schema Information | ||
2 | +# | ||
3 | +# Table name: services | ||
4 | +# | ||
5 | +# id :integer not null, primary key | ||
6 | +# type :string(255) | ||
7 | +# title :string(255) | ||
8 | +# token :string(255) | ||
9 | +# project_id :integer not null | ||
10 | +# created_at :datetime not null | ||
11 | +# updated_at :datetime not null | ||
12 | +# active :boolean default(FALSE), not null | ||
13 | +# project_url :string(255) | ||
14 | +# subdomain :string(255) | ||
15 | +# room :string(255) | ||
16 | +# | ||
17 | + | ||
18 | +require 'spec_helper' | ||
19 | + | ||
20 | +describe AssemblaService do | ||
21 | + describe "Associations" do | ||
22 | + it { should belong_to :project } | ||
23 | + it { should have_one :service_hook } | ||
24 | + end | ||
25 | + | ||
26 | + describe "Execute" do | ||
27 | + let(:user) { create(:user) } | ||
28 | + let(:project) { create(:project_with_code) } | ||
29 | + | ||
30 | + before do | ||
31 | + @assembla_service = AssemblaService.new | ||
32 | + @assembla_service.stub( | ||
33 | + project_id: project.id, | ||
34 | + project: project, | ||
35 | + service_hook: true, | ||
36 | + token: 'verySecret' | ||
37 | + ) | ||
38 | + @sample_data = GitPushService.new.sample_data(project, user) | ||
39 | + @api_url = 'https://atlas.assembla.com/spaces/ouposp/github_tool?secret_key=verySecret' | ||
40 | + WebMock.stub_request(:post, @api_url) | ||
41 | + end | ||
42 | + | ||
43 | + it "should call FlowDock API" do | ||
44 | + @assembla_service.execute(@sample_data) | ||
45 | + WebMock.should have_requested(:post, @api_url).with( | ||
46 | + body: /#{@sample_data[:before]}.*#{@sample_data[:after]}.*#{project.path}/ | ||
47 | + ).once | ||
48 | + end | ||
49 | + end | ||
50 | +end |