diff options
Diffstat (limited to 'spec/models/user_spec.rb')
| -rw-r--r-- | spec/models/user_spec.rb | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 4a1e393..73a7a7d 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -53,16 +53,27 @@ describe User do end describe "authorized_projects" do - it "returns projects" do - project = FactoryGirl.create :project, gitlab_id: 1 - project1 = FactoryGirl.create :project, gitlab_id: 2 + let (:user) { User.new({}) } + + before do + FactoryGirl.create :project, gitlab_id: 1 + FactoryGirl.create :project, gitlab_id: 2 gitlab_project = OpenStruct.new({id: 1}) gitlab_project1 = OpenStruct.new({id: 2}) User.any_instance.stub(:gitlab_projects).and_return([gitlab_project, gitlab_project1]) - user = User.new({}) + end + + it "returns projects" do + User.any_instance.stub(:can_manage_project?).and_return(true) user.authorized_projects.count.should == 2 end + + it "empty list if user miss manage permission" do + User.any_instance.stub(:can_manage_project?).and_return(false) + + user.authorized_projects.count.should == 0 + end end describe "authorized_runners" do @@ -72,6 +83,7 @@ describe User do gitlab_project = OpenStruct.new({id: 1}) gitlab_project1 = OpenStruct.new({id: 2}) User.any_instance.stub(:gitlab_projects).and_return([gitlab_project, gitlab_project1]) + User.any_instance.stub(:can_manage_project?).and_return(true) user = User.new({}) runner = FactoryGirl.create :specific_runner |
