diff options
author | Alex Denisov <1101.debian@gmail.com> | 2012-09-10 00:27:47 +0300 |
---|---|---|
committer | Alex Denisov <1101.debian@gmail.com> | 2012-09-10 00:27:47 +0300 |
commit | 1f240b09ed5f9f5476a863dd2f906398e5a9f0d4 (patch) | |
tree | 043a9a48f08507b96064cef157ff733ca89ce2b4 /spec | |
parent | a86bd87afcb8ba8221aa72562a6591139fa763c0 (diff) | |
download | gitlab-ce-1f240b09ed5f9f5476a863dd2f906398e5a9f0d4.tar.gz |
User left project event added
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/event_spec.rb | 13 | ||||
-rw-r--r-- | spec/observers/users_project_observer_spec.rb | 19 |
2 files changed, 31 insertions, 1 deletions
diff --git a/spec/models/event_spec.rb b/spec/models/event_spec.rb index 81459233cf6..ee022e959e7 100644 --- a/spec/models/event_spec.rb +++ b/spec/models/event_spec.rb @@ -50,7 +50,7 @@ describe Event do it { @event.author.should == @user } end - describe "New team mamber" do + describe "Joined project team" do let(:project) {Factory.create :project} let(:new_user) {Factory.create :user} it "should create event" do @@ -60,4 +60,15 @@ describe Event do }.to change{Event.count}.by(1) 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) + end + end end diff --git a/spec/observers/users_project_observer_spec.rb b/spec/observers/users_project_observer_spec.rb index 99130aa5161..f38d98620a3 100644 --- a/spec/observers/users_project_observer_spec.rb +++ b/spec/observers/users_project_observer_spec.rb @@ -45,4 +45,23 @@ describe UsersProjectObserver do subject.after_update(users_project) end end + describe "#after_destroy" do + it "should called when UsersProject destroyed" do + subject.should_receive(:after_destroy) + UsersProject.observers.enable :users_project_observer do + UsersProject.bulk_delete( + users_project.project, + [users_project.user.id] + ) + end + end + it "should create new event" do + Event.should_receive(:create).with( + project_id: users_project.project.id, + action: Event::Left, + author_id: users_project.user.id + ) + subject.after_destroy(users_project) + end + end end |