fix observer specs
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
parent
5289190ce8
commit
5a2ae296fa
|
@ -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
|
||||||
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
|
||||||
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
|
||||||
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
|
||||||
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
|
||||||
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
|
||||||
|
|
Loading…
Reference in New Issue