diff options
author | Sullivan SENECHAL <soullivaneuh@gmail.com> | 2014-10-01 02:48:41 +0200 |
---|---|---|
committer | Sullivan SENECHAL <soullivaneuh@gmail.com> | 2014-10-03 13:54:37 +0200 |
commit | d1fa3b336d1d3e3c1f9a10ca007e3d1193e5e205 (patch) | |
tree | 4ab193d600aa60182b1f0ff01bfd116b640b274f /spec/models | |
parent | 43217dd5ddcb7557ea0c7300c6a02253f1b99d7d (diff) | |
download | gitlab-ce-d1fa3b336d1d3e3c1f9a10ca007e3d1193e5e205.tar.gz |
Add Pushover service integration
That introduce select field type for services options.
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/project_spec.rb | 1 | ||||
-rw-r--r-- | spec/models/pushover_service_spec.rb | 69 |
2 files changed, 70 insertions, 0 deletions
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 524cab2b925..48b58400a1e 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -47,6 +47,7 @@ describe Project do it { should have_many(:protected_branches).dependent(:destroy) } it { should have_one(:forked_project_link).dependent(:destroy) } it { should have_one(:slack_service).dependent(:destroy) } + it { should have_one(:pushover_service).dependent(:destroy) } end describe "Mass assignment" do diff --git a/spec/models/pushover_service_spec.rb b/spec/models/pushover_service_spec.rb new file mode 100644 index 00000000000..59db69d7572 --- /dev/null +++ b/spec/models/pushover_service_spec.rb @@ -0,0 +1,69 @@ +# == Schema Information +# +# Table name: services +# +# id :integer not null, primary key +# type :string(255) +# title :string(255) +# project_id :integer not null +# created_at :datetime +# updated_at :datetime +# active :boolean default(FALSE), not null +# properties :text +# + +require 'spec_helper' + +describe PushoverService do + describe 'Associations' do + it { should belong_to :project } + it { should have_one :service_hook } + end + + describe 'Validations' do + context 'active' do + before do + subject.active = true + end + + it { should validate_presence_of :api_key } + it { should validate_presence_of :user_key } + it { should validate_presence_of :priority } + end + end + + describe 'Execute' do + let(:pushover) { PushoverService.new } + let(:user) { create(:user) } + let(:project) { create(:project) } + let(:sample_data) { GitPushService.new.sample_data(project, user) } + + let(:api_key) { 'verySecret' } + let(:user_key) { 'verySecret' } + let(:device) { 'myDevice' } + let(:priority) { 0 } + let(:sound) { 'bike' } + let(:api_url) { 'https://api.pushover.net/1/messages.json' } + + before do + pushover.stub( + project: project, + project_id: project.id, + service_hook: true, + api_key: api_key, + user_key: user_key, + device: device, + priority: priority, + sound: sound + ) + + WebMock.stub_request(:post, api_url) + end + + it 'should call Pushover API' do + pushover.execute(sample_data) + + WebMock.should have_requested(:post, api_url).once + end + end +end |