diff options
author | randx <dmitriy.zaporozhets@gmail.com> | 2012-09-15 02:00:59 +0400 |
---|---|---|
committer | randx <dmitriy.zaporozhets@gmail.com> | 2012-09-15 02:00:59 +0400 |
commit | a82977c64843aa177498f1a715121ae6e38bc323 (patch) | |
tree | ddccf4c68c46935d4dffa82fdb5c663bd5c65ac1 /spec/models/event_spec.rb | |
parent | 0d66cf2a38540056b6400c526e62ccc0cbc3144d (diff) |
A bit of test refactoring
Diffstat (limited to 'spec/models/event_spec.rb')
-rw-r--r-- | spec/models/event_spec.rb | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/spec/models/event_spec.rb b/spec/models/event_spec.rb index ee022e959e7..5cb68761b29 100644 --- a/spec/models/event_spec.rb +++ b/spec/models/event_spec.rb @@ -14,12 +14,12 @@ describe Event do it { should respond_to(:commits) } end - describe "Push event" do - before do + describe "Push event" do + before do project = Factory :project @user = project.owner - data = { + data = { before: "0000000000000000000000000000000000000000", after: "0220c11b9a3e6c69dc8fd35321254ca9a7b98f7e", ref: "refs/heads/master", @@ -50,25 +50,24 @@ describe Event do it { @event.author.should == @user } end - describe "Joined project team" do - let(:project) {Factory.create :project} - let(:new_user) {Factory.create :user} - it "should create event" do - UsersProject.observers.enable :users_project_observer - expect{ - UsersProject.bulk_import(project, [new_user.id], UsersProject::DEVELOPER) - }.to change{Event.count}.by(1) + describe 'Team events' do + let(:user_project) { stub.as_null_object } + let(:observer) { UsersProjectObserver.instance } + + before { + Event.should_receive :create + } + + describe "Joined project team" do + it "should create event" do + observer.after_create user_project + end end - end - describe "Left project team" do - let(:project) {Factory.create :project} - let(:new_user) {Factory.create :user} - it "should create event" do - UsersProject.bulk_import(project, [new_user.id], UsersProject::DEVELOPER) - UsersProject.observers.enable :users_project_observer - expect{ - UsersProject.bulk_delete(project, [new_user.id]) - }.to change{Event.count}.by(1) + + describe "Left project team" do + it "should create event" do + observer.after_destroy user_project + end end end end |