summaryrefslogtreecommitdiff
path: root/spec/observers
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-01-09 09:14:05 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-01-09 09:14:05 +0300
commit9773ccc4519c4c35f969248c4e0f13689b631760 (patch)
treec8780c4bfcb5135dfc465f2f0d03424501ed3382 /spec/observers
parent71bd9568669d18bc04c551a603a04af2ea99328c (diff)
downloadgitlab-ce-9773ccc4519c4c35f969248c4e0f13689b631760.tar.gz
sidekiq with green tests
Diffstat (limited to 'spec/observers')
-rw-r--r--spec/observers/issue_observer_spec.rb16
-rw-r--r--spec/observers/merge_request_observer_spec.rb7
-rw-r--r--spec/observers/note_observer_spec.rb23
-rw-r--r--spec/observers/user_observer_spec.rb16
4 files changed, 26 insertions, 36 deletions
diff --git a/spec/observers/issue_observer_spec.rb b/spec/observers/issue_observer_spec.rb
index bbffbd342db..700c9a3a69b 100644
--- a/spec/observers/issue_observer_spec.rb
+++ b/spec/observers/issue_observer_spec.rb
@@ -21,8 +21,7 @@ describe IssueObserver do
end
it 'sends an email to the assignee' do
- Notify.should_receive(:new_issue_email).with(issue.id).
- and_return(double(deliver: true))
+ Notify.should_receive(:new_issue_email).with(issue.id)
subject.after_create(issue)
end
@@ -71,6 +70,7 @@ describe IssueObserver do
context 'a status "closed"' do
it 'note is created if the issue is being closed' do
issue.should_receive(:is_being_closed?).and_return(true)
+ Notify.should_receive(:issue_status_changed_email).twice
Note.should_receive(:create_status_change_note).with(issue, some_user, 'closed')
subject.after_update(issue)
@@ -85,7 +85,7 @@ describe IssueObserver do
it 'notification is delivered if the issue being closed' do
issue.stub(:is_being_closed?).and_return(true)
- Notify.should_receive(:issue_status_changed_email).twice.and_return(stub(deliver: true))
+ Notify.should_receive(:issue_status_changed_email).twice
Note.should_receive(:create_status_change_note).with(issue, some_user, 'closed')
subject.after_update(issue)
@@ -104,7 +104,7 @@ describe IssueObserver do
issue_without_assignee.stub(:is_being_reassigned?).and_return(false)
issue_without_assignee.stub(:is_being_closed?).and_return(true)
issue_without_assignee.stub(:is_being_reopened?).and_return(false)
- Notify.should_receive(:issue_status_changed_email).once.and_return(stub(deliver: true))
+ Notify.should_receive(:issue_status_changed_email).once
Note.should_receive(:create_status_change_note).with(issue_without_assignee, some_user, 'closed')
subject.after_update(issue_without_assignee)
@@ -113,6 +113,7 @@ describe IssueObserver do
context 'a status "reopened"' do
it 'note is created if the issue is being reopened' do
+ Notify.should_receive(:issue_status_changed_email).twice
issue.should_receive(:is_being_reopened?).and_return(true)
Note.should_receive(:create_status_change_note).with(issue, some_user, 'reopened')
@@ -128,7 +129,7 @@ describe IssueObserver do
it 'notification is delivered if the issue being reopened' do
issue.stub(:is_being_reopened?).and_return(true)
- Notify.should_receive(:issue_status_changed_email).twice.and_return(stub(deliver: true))
+ Notify.should_receive(:issue_status_changed_email).twice
Note.should_receive(:create_status_change_note).with(issue, some_user, 'reopened')
subject.after_update(issue)
@@ -147,7 +148,7 @@ describe IssueObserver do
issue_without_assignee.stub(:is_being_reassigned?).and_return(false)
issue_without_assignee.stub(:is_being_closed?).and_return(false)
issue_without_assignee.stub(:is_being_reopened?).and_return(true)
- Notify.should_receive(:issue_status_changed_email).once.and_return(stub(deliver: true))
+ Notify.should_receive(:issue_status_changed_email).once
Note.should_receive(:create_status_change_note).with(issue_without_assignee, some_user, 'reopened')
subject.after_update(issue_without_assignee)
@@ -164,8 +165,7 @@ describe IssueObserver do
end
def it_sends_a_reassigned_email_to(recipient)
- Notify.should_receive(:reassigned_issue_email).with(recipient, issue.id, previous_assignee.id).
- and_return(double(deliver: true))
+ Notify.should_receive(:reassigned_issue_email).with(recipient, issue.id, previous_assignee.id)
end
def it_does_not_send_a_reassigned_email_to(recipient)
diff --git a/spec/observers/merge_request_observer_spec.rb b/spec/observers/merge_request_observer_spec.rb
index 6b15be96630..4841bf88fc5 100644
--- a/spec/observers/merge_request_observer_spec.rb
+++ b/spec/observers/merge_request_observer_spec.rb
@@ -21,9 +21,7 @@ describe MergeRequestObserver do
end
it 'sends an email to the assignee' do
- Notify.should_receive(:new_merge_request_email).with(mr.id).
- and_return(double(deliver: true))
-
+ Notify.should_receive(:new_merge_request_email).with(mr.id)
subject.after_create(mr)
end
@@ -158,8 +156,7 @@ describe MergeRequestObserver do
end
def it_sends_a_reassigned_email_to(recipient)
- Notify.should_receive(:reassigned_merge_request_email).with(recipient, mr.id, previous_assignee.id).
- and_return(double(deliver: true))
+ Notify.should_receive(:reassigned_merge_request_email).with(recipient, mr.id, previous_assignee.id)
end
def it_does_not_send_a_reassigned_email_to(recipient)
diff --git a/spec/observers/note_observer_spec.rb b/spec/observers/note_observer_spec.rb
index 7dfa9f772e9..73da2e146cb 100644
--- a/spec/observers/note_observer_spec.rb
+++ b/spec/observers/note_observer_spec.rb
@@ -4,7 +4,6 @@ describe NoteObserver do
subject { NoteObserver.instance }
let(:team_without_author) { (1..2).map { |n| double :user, id: n } }
- let(:delivery_success) { double deliver: true }
describe '#after_create' do
let(:note) { double :note }
@@ -45,13 +44,13 @@ describe NoteObserver do
note.stub(:id).and_return(42)
author = double :user, id: 1
note.stub(:commit_author).and_return(author)
- Notify.should_receive(:note_commit_email).and_return(delivery_success)
+ Notify.should_receive(:note_commit_email)
subject.after_create(note)
end
it 'does not notify the author of a commit when not flagged to notify the author' do
- Notify.should_not_receive(:note_commit_email)
+ notify.should_not_receive(:note_commit_email)
subject.after_create(note)
end
@@ -71,28 +70,28 @@ describe NoteObserver do
context 'notifies team of a new note on' do
it 'a commit' do
note.stub(:noteable_type).and_return('Commit')
- Notify.should_receive(:note_commit_email).twice.and_return(delivery_success)
+ notify.should_receive(:note_commit_email).twice
subject.send(:notify_team, note)
end
it 'an issue' do
note.stub(:noteable_type).and_return('Issue')
- Notify.should_receive(:note_issue_email).twice.and_return(delivery_success)
+ notify.should_receive(:note_issue_email).twice
subject.send(:notify_team, note)
end
it 'a wiki page' do
note.stub(:noteable_type).and_return('Wiki')
- Notify.should_receive(:note_wiki_email).twice.and_return(delivery_success)
+ notify.should_receive(:note_wiki_email).twice
subject.send(:notify_team, note)
end
it 'a merge request' do
note.stub(:noteable_type).and_return('MergeRequest')
- Notify.should_receive(:note_merge_request_email).twice.and_return(delivery_success)
+ notify.should_receive(:note_merge_request_email).twice
subject.send(:notify_team, note)
end
@@ -100,16 +99,16 @@ describe NoteObserver do
it 'a wall' do
# Note: wall posts have #noteable_type of nil
note.stub(:noteable_type).and_return(nil)
- Notify.should_receive(:note_wall_email).twice.and_return(delivery_success)
+ notify.should_receive(:note_wall_email).twice
subject.send(:notify_team, note)
end
end
it 'does nothing for a new note on a snippet' do
- note.stub(:noteable_type).and_return('Snippet')
+ note.stub(:noteable_type).and_return('Snippet')
- subject.send(:notify_team, note).should be_nil
+ subject.send(:notify_team, note).should be_nil
end
end
@@ -125,4 +124,8 @@ describe NoteObserver do
subject.send(:team_without_note_author, note).should == team_without_author
end
end
+
+ def notify
+ Notify
+ end
end
diff --git a/spec/observers/user_observer_spec.rb b/spec/observers/user_observer_spec.rb
index befb980fdcb..bffa5fcfd69 100644
--- a/spec/observers/user_observer_spec.rb
+++ b/spec/observers/user_observer_spec.rb
@@ -10,24 +10,14 @@ describe UserObserver do
end
context 'when a new user is created' do
- let(:user) { double(:user, id: 42,
- password: 'P@ssword!',
- name: 'John',
- email: 'u@mail.local',
- username: 'root',
- create_namespace: true) }
- let(:notification) { double :notification }
-
it 'sends an email' do
- notification.should_receive(:deliver)
- Notify.should_receive(:new_user_email).with(user.id, user.password).and_return(notification)
-
- subject.after_create(user)
+ Notify.should_receive(:new_user_email)
+ create(:user)
end
it 'trigger logger' do
Gitlab::AppLogger.should_receive(:info)
- subject.after_create(user)
+ create(:user)
end
end
end