Commit 2ab76ca5 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Fix UserProject obserse spec

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent d75eb243
class UsersProjectObserver < BaseObserver class UsersProjectObserver < BaseObserver
def after_commit(users_project)
return if users_project.destroyed?
end
def after_create(users_project) def after_create(users_project)
Event.create( Event.create(
project_id: users_project.project.id, project_id: users_project.project.id,
......
...@@ -7,7 +7,7 @@ describe UsersProjectObserver do ...@@ -7,7 +7,7 @@ describe UsersProjectObserver do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project) } let(:project) { create(:project) }
subject { UsersProjectObserver.instance } subject { UsersProjectObserver.instance }
before { subject.stub(notification: mock('NotificationService').as_null_object) } before { subject.stub(notification: double('NotificationService').as_null_object) }
describe "#after_commit" do describe "#after_commit" do
it "should called when UsersProject created" do it "should called when UsersProject created" do
...@@ -35,7 +35,7 @@ describe UsersProjectObserver do ...@@ -35,7 +35,7 @@ describe UsersProjectObserver do
end end
it "should called when UsersProject updated" do it "should called when UsersProject updated" do
subject.should_receive(:after_commit) subject.should_receive(:after_update)
@users_project.update_attribute(:project_access, UsersProject::MASTER) @users_project.update_attribute(:project_access, UsersProject::MASTER)
end end
...@@ -45,7 +45,7 @@ describe UsersProjectObserver do ...@@ -45,7 +45,7 @@ describe UsersProjectObserver do
end end
it "should not called after UsersProject destroyed" do it "should not called after UsersProject destroyed" do
subject.should_not_receive(:after_commit) subject.should_not_receive(:after_update)
@users_project.destroy @users_project.destroy
end end
end end
...@@ -91,4 +91,4 @@ describe UsersProjectObserver do ...@@ -91,4 +91,4 @@ describe UsersProjectObserver do
end end
end end
end end
end end
\ No newline at end of file
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