Commit 5a2ae296 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

fix observer specs

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 5289190c
...@@ -9,7 +9,7 @@ describe IssueObserver do ...@@ -9,7 +9,7 @@ describe IssueObserver do
before { subject.stub(:current_user).and_return(some_user) } before { subject.stub(:current_user).and_return(some_user) }
before { subject.stub(:current_commit).and_return(nil) } before { subject.stub(:current_commit).and_return(nil) }
before { subject.stub(notification: mock('NotificationService').as_null_object) } before { subject.stub(notification: double('NotificationService').as_null_object) }
before { mock_issue.project.stub_chain(:repository, :commit).and_return(nil) } before { mock_issue.project.stub_chain(:repository, :commit).and_return(nil) }
subject { IssueObserver.instance } subject { IssueObserver.instance }
......
...@@ -11,7 +11,7 @@ describe MergeRequestObserver do ...@@ -11,7 +11,7 @@ describe MergeRequestObserver do
let(:closed_unassigned_mr) { create(:closed_merge_request, author: author, target_project: create(:project)) } let(:closed_unassigned_mr) { create(:closed_merge_request, author: author, target_project: create(:project)) }
before { subject.stub(:current_user).and_return(some_user) } before { subject.stub(:current_user).and_return(some_user) }
before { subject.stub(notification: mock('NotificationService').as_null_object) } before { subject.stub(notification: double('NotificationService').as_null_object) }
before { mr_mock.stub(:author_id) } before { mr_mock.stub(:author_id) }
before { mr_mock.stub(:target_project) } before { mr_mock.stub(:target_project) }
before { mr_mock.stub(:source_project) } before { mr_mock.stub(:source_project) }
......
...@@ -4,7 +4,7 @@ describe UserObserver do ...@@ -4,7 +4,7 @@ describe UserObserver do
before(:each) { enable_observers } before(:each) { enable_observers }
after(:each) {disable_observers} after(:each) {disable_observers}
subject { UserObserver.instance } subject { UserObserver.instance }
before { subject.stub(notification: mock('NotificationService').as_null_object) } before { subject.stub(notification: double('NotificationService').as_null_object) }
it 'calls #after_create when new users are created' do it 'calls #after_create when new users are created' do
new_user = build(:user) new_user = build(:user)
......
...@@ -5,7 +5,7 @@ describe UsersGroupObserver do ...@@ -5,7 +5,7 @@ describe UsersGroupObserver do
after(:each) { disable_observers } after(:each) { disable_observers }
subject { UsersGroupObserver.instance } subject { UsersGroupObserver.instance }
before { subject.stub(notification: mock('NotificationService').as_null_object) } before { subject.stub(notification: double('NotificationService').as_null_object) }
describe "#after_create" do describe "#after_create" do
it "should send email to user" do it "should send email to user" do
......
...@@ -9,26 +9,6 @@ describe UsersProjectObserver do ...@@ -9,26 +9,6 @@ describe UsersProjectObserver do
subject { UsersProjectObserver.instance } subject { UsersProjectObserver.instance }
before { subject.stub(notification: double('NotificationService').as_null_object) } before { subject.stub(notification: double('NotificationService').as_null_object) }
describe "#after_commit" do
it "should called when UsersProject created" do
subject.should_receive(:after_commit)
create(:users_project)
end
it "should send email to user" do
subject.should_receive(:notification)
Event.stub(create: true)
create(:users_project)
end
it "should create new event" do
Event.should_receive(:create)
create(:users_project)
end
end
describe "#after_update" do describe "#after_update" do
before do before do
@users_project = create :users_project @users_project = create :users_project
...@@ -90,5 +70,18 @@ describe UsersProjectObserver do ...@@ -90,5 +70,18 @@ describe UsersProjectObserver do
it { File.exists?(@path).should be_false } it { File.exists?(@path).should be_false }
end end
end end
it "should send email to user" do
subject.should_receive(:notification)
Event.stub(create: true)
create(:users_project)
end
it "should create new event" do
Event.should_receive(:create)
create(:users_project)
end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment