Fixed missing current user for issue observer

This commit is contained in:
Dmitriy Zaporozhets 2013-01-02 20:25:25 +02:00
parent 6a9e7dc55b
commit 67896ea9a2
3 changed files with 25 additions and 25 deletions

View file

@ -78,6 +78,7 @@ module Gitlab
attrs = attributes_for_keys [:title, :description, :assignee_id, :milestone_id, :closed]
attrs[:label_list] = params[:labels] if params[:labels].present?
IssueObserver.current_user = current_user
if @issue.update_attributes attrs
present @issue, with: Entities::Issue
else

View file

@ -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

View file

@ -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) }