gitlabhq/spec/observers/users_project_observer_spec.rb

65 lines
1.6 KiB
Ruby
Raw Normal View History

require 'spec_helper'
describe UsersProjectObserver do
let(:user) { create(:user) }
let(:project) { create(:project) }
subject { UsersProjectObserver.instance }
2012-09-03 20:46:17 +02:00
describe "#after_commit" do
it "should called when UsersProject created" do
subject.should_receive(:after_commit)
2013-01-02 18:46:06 +01:00
create(:users_project)
end
2012-09-15 00:00:59 +02:00
it "should send email to user" do
Notify.should_receive(:project_access_granted_email).and_return(double(deliver: true))
2012-09-15 00:00:59 +02:00
Event.stub(:create => true)
create(:users_project)
end
2012-09-15 00:00:59 +02:00
2012-09-09 22:18:28 +02:00
it "should create new event" do
Event.should_receive(:create)
2012-09-15 00:00:59 +02:00
create(:users_project)
2012-09-09 22:18:28 +02:00
end
end
describe "#after_update" do
before do
@users_project = create :users_project
end
it "should called when UsersProject updated" do
subject.should_receive(:after_commit)
@users_project.update_attribute(:project_access, UsersProject::MASTER)
end
2012-09-15 00:00:59 +02:00
it "should send email to user" do
Notify.should_receive(:project_access_granted_email)
@users_project.update_attribute(:project_access, UsersProject::MASTER)
end
2012-09-03 20:46:17 +02:00
it "should not called after UsersProject destroyed" do
subject.should_not_receive(:after_commit)
@users_project.destroy
2012-09-03 20:46:17 +02:00
end
end
2012-09-15 00:00:59 +02:00
2012-09-09 23:27:47 +02:00
describe "#after_destroy" do
before do
@users_project = create :users_project
end
2012-09-09 23:27:47 +02:00
it "should called when UsersProject destroyed" do
subject.should_receive(:after_destroy)
@users_project.destroy
2012-09-09 23:27:47 +02:00
end
2012-09-15 00:00:59 +02:00
2012-09-09 23:27:47 +02:00
it "should create new event" do
Event.should_receive(:create)
@users_project.destroy
2012-09-09 23:27:47 +02:00
end
end
end