Commit 5a2ae296fafb434e9f6a72118b02ddc1f584a9a9
1 parent
5289190c
Exists in
master
and in
4 other branches
fix observer specs
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing
5 changed files
with
17 additions
and
24 deletions
Show diff stats
spec/observers/issue_observer_spec.rb
... | ... | @@ -9,7 +9,7 @@ describe IssueObserver do |
9 | 9 | |
10 | 10 | before { subject.stub(:current_user).and_return(some_user) } |
11 | 11 | before { subject.stub(:current_commit).and_return(nil) } |
12 | - before { subject.stub(notification: mock('NotificationService').as_null_object) } | |
12 | + before { subject.stub(notification: double('NotificationService').as_null_object) } | |
13 | 13 | before { mock_issue.project.stub_chain(:repository, :commit).and_return(nil) } |
14 | 14 | |
15 | 15 | subject { IssueObserver.instance } | ... | ... |
spec/observers/merge_request_observer_spec.rb
... | ... | @@ -11,7 +11,7 @@ describe MergeRequestObserver do |
11 | 11 | let(:closed_unassigned_mr) { create(:closed_merge_request, author: author, target_project: create(:project)) } |
12 | 12 | |
13 | 13 | before { subject.stub(:current_user).and_return(some_user) } |
14 | - before { subject.stub(notification: mock('NotificationService').as_null_object) } | |
14 | + before { subject.stub(notification: double('NotificationService').as_null_object) } | |
15 | 15 | before { mr_mock.stub(:author_id) } |
16 | 16 | before { mr_mock.stub(:target_project) } |
17 | 17 | before { mr_mock.stub(:source_project) } | ... | ... |
spec/observers/user_observer_spec.rb
... | ... | @@ -4,7 +4,7 @@ describe UserObserver do |
4 | 4 | before(:each) { enable_observers } |
5 | 5 | after(:each) {disable_observers} |
6 | 6 | subject { UserObserver.instance } |
7 | - before { subject.stub(notification: mock('NotificationService').as_null_object) } | |
7 | + before { subject.stub(notification: double('NotificationService').as_null_object) } | |
8 | 8 | |
9 | 9 | it 'calls #after_create when new users are created' do |
10 | 10 | new_user = build(:user) | ... | ... |
spec/observers/users_group_observer_spec.rb
... | ... | @@ -5,7 +5,7 @@ describe UsersGroupObserver do |
5 | 5 | after(:each) { disable_observers } |
6 | 6 | |
7 | 7 | subject { UsersGroupObserver.instance } |
8 | - before { subject.stub(notification: mock('NotificationService').as_null_object) } | |
8 | + before { subject.stub(notification: double('NotificationService').as_null_object) } | |
9 | 9 | |
10 | 10 | describe "#after_create" do |
11 | 11 | it "should send email to user" do | ... | ... |
spec/observers/users_project_observer_spec.rb
... | ... | @@ -9,26 +9,6 @@ describe UsersProjectObserver do |
9 | 9 | subject { UsersProjectObserver.instance } |
10 | 10 | before { subject.stub(notification: double('NotificationService').as_null_object) } |
11 | 11 | |
12 | - describe "#after_commit" do | |
13 | - it "should called when UsersProject created" do | |
14 | - subject.should_receive(:after_commit) | |
15 | - create(:users_project) | |
16 | - end | |
17 | - | |
18 | - it "should send email to user" do | |
19 | - subject.should_receive(:notification) | |
20 | - Event.stub(create: true) | |
21 | - | |
22 | - create(:users_project) | |
23 | - end | |
24 | - | |
25 | - it "should create new event" do | |
26 | - Event.should_receive(:create) | |
27 | - | |
28 | - create(:users_project) | |
29 | - end | |
30 | - end | |
31 | - | |
32 | 12 | describe "#after_update" do |
33 | 13 | before do |
34 | 14 | @users_project = create :users_project |
... | ... | @@ -90,5 +70,18 @@ describe UsersProjectObserver do |
90 | 70 | it { File.exists?(@path).should be_false } |
91 | 71 | end |
92 | 72 | end |
73 | + | |
74 | + it "should send email to user" do | |
75 | + subject.should_receive(:notification) | |
76 | + Event.stub(create: true) | |
77 | + | |
78 | + create(:users_project) | |
79 | + end | |
80 | + | |
81 | + it "should create new event" do | |
82 | + Event.should_receive(:create) | |
83 | + | |
84 | + create(:users_project) | |
85 | + end | |
93 | 86 | end |
94 | 87 | end | ... | ... |