diff options
| author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-01-02 20:25:25 +0200 |
|---|---|---|
| committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-01-02 20:25:25 +0200 |
| commit | 67896ea9a258eee8bb8ecca849d59f48e16ac77a (patch) | |
| tree | 000ab00d8ad6a7f6fa17266205d9f216e47b5678 /spec | |
| parent | 6a9e7dc55bbf7bedaee1870763132d65dad15be9 (diff) | |
| download | gitlab-ce-67896ea9a258eee8bb8ecca849d59f48e16ac77a.tar.gz | |
Fixed missing current user for issue observer
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/observers/users_project_observer_spec.rb | 47 | ||||
| -rw-r--r-- | spec/requests/atom/issues_spec.rb | 2 |
2 files changed, 24 insertions, 25 deletions
diff --git a/spec/observers/users_project_observer_spec.rb b/spec/observers/users_project_observer_spec.rb index 9cf629214ab..068688b0d1d 100644 --- a/spec/observers/users_project_observer_spec.rb +++ b/spec/observers/users_project_observer_spec.rb @@ -3,63 +3,62 @@ require 'spec_helper' describe UsersProjectObserver do let(:user) { create(:user) } let(:project) { create(:project) } - let(:users_project) { create(:users_project, - project: project, - user: user )} subject { UsersProjectObserver.instance } describe "#after_commit" do it "should called when UsersProject created" do - subject.should_receive(:after_commit).once + subject.should_receive(:after_commit) create(:users_project) end it "should send email to user" do - Notify.should_receive(:project_access_granted_email).with(users_project.id).and_return(double(deliver: true)) - subject.after_commit(users_project) + Notify.should_receive(:project_access_granted_email).and_return(double(deliver: true)) Event.stub(:create => true) + + create(:users_project) end it "should create new event" do - Event.should_receive(:create).with( - project_id: users_project.project.id, - action: Event::Joined, - author_id: users_project.user.id - ) + Event.should_receive(:create) - subject.after_create(users_project) + create(:users_project) 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).once - create(:users_project).update_attribute(:project_access, UsersProject::MASTER) + subject.should_receive(:after_commit) + @users_project.update_attribute(:project_access, UsersProject::MASTER) end it "should send email to user" do - Notify.should_receive(:project_access_granted_email).with(users_project.id).and_return(double(deliver: true)) - subject.after_commit(users_project) + Notify.should_receive(:project_access_granted_email) + @users_project.update_attribute(:project_access, UsersProject::MASTER) end + it "should not called after UsersProject destroyed" do subject.should_not_receive(:after_commit) - users_project.destroy + @users_project.destroy end end describe "#after_destroy" do + before do + @users_project = create :users_project + end + it "should called when UsersProject destroyed" do subject.should_receive(:after_destroy) - create(:users_project).destroy + @users_project.destroy 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) + Event.should_receive(:create) + @users_project.destroy end end end diff --git a/spec/requests/atom/issues_spec.rb b/spec/requests/atom/issues_spec.rb index 29f88f3f1c3..eeb355377c4 100644 --- a/spec/requests/atom/issues_spec.rb +++ b/spec/requests/atom/issues_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe "Issues Feed" do describe "GET /issues" do let!(:user) { create(:user) } - let!(:project) { create(:project, owner: user) } + let!(:project) { create(:project, namespace: user.namespace) } let!(:issue) { create(:issue, author: user, project: project) } before { project.add_access(user, :read, :write) } |
