diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-04-02 17:33:07 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-04-02 17:33:07 +0400 |
commit | 928fbeeec057692d923146994c4b8dff57024417 (patch) | |
tree | c1c440d0ced942797422e5a5da05a95fbd9b761d | |
parent | 1b5fb4ac2187c0a9cd775686740615a9e2311646 (diff) |
More tests for Isses services
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-rw-r--r-- | spec/services/issues/close_service_spec.rb | 35 | ||||
-rw-r--r-- | spec/services/issues/update_service_spec.rb | 24 |
2 files changed, 57 insertions, 2 deletions
diff --git a/spec/services/issues/close_service_spec.rb b/spec/services/issues/close_service_spec.rb new file mode 100644 index 00000000000..d4f2cc1339b --- /dev/null +++ b/spec/services/issues/close_service_spec.rb @@ -0,0 +1,35 @@ +require 'spec_helper' + +describe Issues::CloseService do + let(:project) { create(:empty_project) } + let(:user) { create(:user) } + let(:user2) { create(:user) } + let(:issue) { create(:issue, assignee: user2) } + + before do + project.team << [user, :master] + project.team << [user2, :developer] + end + + describe :execute do + context "valid params" do + before do + @issue = Issues::CloseService.new(project, user, {}).execute(issue) + end + + it { @issue.should be_valid } + it { @issue.should be_closed } + + it 'should send email to user2 about assign of new issue' do + email = ActionMailer::Base.deliveries.last + email.to.first.should == user2.email + email.subject.should include(issue.title) + end + + it 'should create system note about issue reassign' do + note = @issue.notes.last + note.note.should include "Status changed to closed" + end + end + end +end diff --git a/spec/services/issues/update_service_spec.rb b/spec/services/issues/update_service_spec.rb index 9bfc0f674de..347560414e7 100644 --- a/spec/services/issues/update_service_spec.rb +++ b/spec/services/issues/update_service_spec.rb @@ -3,15 +3,22 @@ require 'spec_helper' describe Issues::UpdateService do let(:project) { create(:empty_project) } let(:user) { create(:user) } + let(:user2) { create(:user) } let(:issue) { create(:issue) } + before do + project.team << [user, :master] + project.team << [user2, :developer] + end + describe :execute do context "valid params" do before do - project.team << [user, :master] opts = { title: 'New title', - description: 'Also please fix' + description: 'Also please fix', + assignee_id: user2.id, + state_event: 'close' } @issue = Issues::UpdateService.new(project, user, opts).execute(issue) @@ -19,6 +26,19 @@ describe Issues::UpdateService do it { @issue.should be_valid } it { @issue.title.should == 'New title' } + it { @issue.assignee.should == user2 } + it { @issue.should be_closed } + + it 'should send email to user2 about assign of new issue' do + email = ActionMailer::Base.deliveries.last + email.to.first.should == user2.email + email.subject.should include(issue.title) + end + + it 'should create system note about issue reassign' do + note = @issue.notes.last + note.note.should include "Reassigned to \@#{user2.username}" + end end end end |