After commit instead of after_update
This commit is contained in:
parent
c7cfe3d83b
commit
1f1c8094fe
2 changed files with 12 additions and 8 deletions
|
@ -1,9 +1,13 @@
|
|||
class UsersProjectObserver < ActiveRecord::Observer
|
||||
def after_create(users_project)
|
||||
Notify.project_access_granted_email(users_project.id).deliver
|
||||
end
|
||||
#def after_create(users_project)
|
||||
#Notify.project_access_granted_email(users_project.id).deliver
|
||||
#end
|
||||
|
||||
def after_update(users_project)
|
||||
#def after_update(users_project)
|
||||
#Notify.project_access_granted_email(users_project.id).deliver
|
||||
#end
|
||||
|
||||
def after_commit(users_project)
|
||||
Notify.project_access_granted_email(users_project.id).deliver
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,7 +12,7 @@ describe UsersProjectObserver do
|
|||
|
||||
describe "#after_create" do
|
||||
it "should called when UsersProject created" do
|
||||
subject.should_receive(:after_create)
|
||||
subject.should_receive(:after_commit)
|
||||
UsersProject.observers.enable :users_project_observer do
|
||||
Factory.create(:users_project,
|
||||
project: project,
|
||||
|
@ -21,20 +21,20 @@ describe UsersProjectObserver do
|
|||
end
|
||||
it "should send email to user" do
|
||||
Notify.should_receive(:project_access_granted_email).with(users_project.id).and_return(double(deliver: true))
|
||||
subject.after_create(users_project)
|
||||
subject.after_commit(users_project)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#after_update" do
|
||||
it "should called when UsersProject updated" do
|
||||
subject.should_receive(:after_update)
|
||||
subject.should_receive(:after_commit)
|
||||
UsersProject.observers.enable :users_project_observer do
|
||||
users_project.update_attribute(:project_access, 40)
|
||||
end
|
||||
end
|
||||
it "should send email to user" do
|
||||
Notify.should_receive(:project_access_granted_email).with(users_project.id).and_return(double(deliver: true))
|
||||
subject.after_update(users_project)
|
||||
subject.after_commit(users_project)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue