sidekiq with green tests
This commit is contained in:
parent
71bd956866
commit
9773ccc451
14 changed files with 48 additions and 68 deletions
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue