Commit af63607a authored by Alex Denisov's avatar Alex Denisov
Browse files

test_after_commit gem added

parent 73c9bbb388d7
......@@ -117,6 +117,7 @@ group :test do
gem 'email_spec'
gem 'resque_spec'
gem "webmock"
gem 'test_after_commit'
end
group :production do
......
......@@ -341,6 +341,7 @@ GEM
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.6)
stamp (0.1.6)
test_after_commit (0.0.1)
therubyracer (0.10.1)
libv8 (~> 3.3.10)
thin (1.3.1)
......@@ -431,6 +432,7 @@ DEPENDENCIES
six
sqlite3
stamp
test_after_commit
therubyracer
thin
uglifier (= 1.0.3)
......
class UsersProjectObserver < ActiveRecord::Observer
#def after_create(users_project)
#Notify.project_access_granted_email(users_project.id).deliver
#end
#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
......
......@@ -10,9 +10,9 @@
user: user )}
subject { UsersProjectObserver.instance }
describe "#after_create" do
describe "#after_commit" do
it "should called when UsersProject created" do
subject.should_receive(:after_commit)
subject.should_receive(:after_commit).once
UsersProject.observers.enable :users_project_observer do
Factory.create(:users_project,
project: project,
......@@ -23,11 +23,8 @@
Notify.should_receive(:project_access_granted_email).with(users_project.id).and_return(double(deliver: true))
subject.after_commit(users_project)
end
end
describe "#after_update" do
it "should called when UsersProject updated" do
subject.should_receive(:after_commit)
subject.should_receive(:after_commit).once
UsersProject.observers.enable :users_project_observer do
users_project.update_attribute(:project_access, 40)
end
......@@ -36,5 +33,11 @@
Notify.should_receive(:project_access_granted_email).with(users_project.id).and_return(double(deliver: true))
subject.after_commit(users_project)
end
it "should not called after UsersProject destroyed" do
subject.should_not_receive(:after_commit)
UsersProject.observers.enable :users_project_observer do
users_project.destroy
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