diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-03-25 07:16:45 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-03-25 07:16:45 +0300 |
commit | 8f3f6e9efbbacf5e52f98324944f644630da2f18 (patch) | |
tree | b8bd189a7dc4919a832eb583441d398b7294cb8c /spec | |
parent | d7aecf68e02cb9ac3b7e022aca60e15a65a62ac6 (diff) | |
parent | 4745424bd3b7f6e13e86ebf985977ad3268881e3 (diff) |
Merge branch 'api-internal-errors' into 'master'
Respond with full GitAccess error if user has project read access.
Should help with debugging #1236.
cc @marin
See merge request !437
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/git_access_spec.rb | 38 | ||||
-rw-r--r-- | spec/lib/gitlab/git_access_wiki_spec.rb | 4 |
2 files changed, 22 insertions, 20 deletions
diff --git a/spec/lib/gitlab/git_access_spec.rb b/spec/lib/gitlab/git_access_spec.rb index 666398eedd4..39be9d64644 100644 --- a/spec/lib/gitlab/git_access_spec.rb +++ b/spec/lib/gitlab/git_access_spec.rb @@ -1,25 +1,26 @@ require 'spec_helper' describe Gitlab::GitAccess do - let(:access) { Gitlab::GitAccess.new } + let(:access) { Gitlab::GitAccess.new(actor, project) } let(:project) { create(:project) } let(:user) { create(:user) } + let(:actor) { user } describe 'can_push_to_branch?' do describe 'push to none protected branch' do it "returns true if user is a master" do project.team << [user, :master] - expect(Gitlab::GitAccess.can_push_to_branch?(user, project, "random_branch")).to be_truthy + expect(access.can_push_to_branch?("random_branch")).to be_truthy end it "returns true if user is a developer" do project.team << [user, :developer] - expect(Gitlab::GitAccess.can_push_to_branch?(user, project, "random_branch")).to be_truthy + expect(access.can_push_to_branch?("random_branch")).to be_truthy end it "returns false if user is a reporter" do project.team << [user, :reporter] - expect(Gitlab::GitAccess.can_push_to_branch?(user, project, "random_branch")).to be_falsey + expect(access.can_push_to_branch?("random_branch")).to be_falsey end end @@ -30,17 +31,17 @@ describe Gitlab::GitAccess do it "returns true if user is a master" do project.team << [user, :master] - expect(Gitlab::GitAccess.can_push_to_branch?(user, project, @branch.name)).to be_truthy + expect(access.can_push_to_branch?(@branch.name)).to be_truthy end it "returns false if user is a developer" do project.team << [user, :developer] - expect(Gitlab::GitAccess.can_push_to_branch?(user, project, @branch.name)).to be_falsey + expect(access.can_push_to_branch?(@branch.name)).to be_falsey end it "returns false if user is a reporter" do project.team << [user, :reporter] - expect(Gitlab::GitAccess.can_push_to_branch?(user, project, @branch.name)).to be_falsey + expect(access.can_push_to_branch?(@branch.name)).to be_falsey end end @@ -51,17 +52,17 @@ describe Gitlab::GitAccess do it "returns true if user is a master" do project.team << [user, :master] - expect(Gitlab::GitAccess.can_push_to_branch?(user, project, @branch.name)).to be_truthy + expect(access.can_push_to_branch?(@branch.name)).to be_truthy end it "returns true if user is a developer" do project.team << [user, :developer] - expect(Gitlab::GitAccess.can_push_to_branch?(user, project, @branch.name)).to be_truthy + expect(access.can_push_to_branch?(@branch.name)).to be_truthy end it "returns false if user is a reporter" do project.team << [user, :reporter] - expect(Gitlab::GitAccess.can_push_to_branch?(user, project, @branch.name)).to be_falsey + expect(access.can_push_to_branch?(@branch.name)).to be_falsey end end @@ -72,7 +73,7 @@ describe Gitlab::GitAccess do before { project.team << [user, :master] } context 'pull code' do - subject { access.download_access_check(user, project) } + subject { access.download_access_check } it { expect(subject.allowed?).to be_truthy } end @@ -82,7 +83,7 @@ describe Gitlab::GitAccess do before { project.team << [user, :guest] } context 'pull code' do - subject { access.download_access_check(user, project) } + subject { access.download_access_check } it { expect(subject.allowed?).to be_falsey } end @@ -95,7 +96,7 @@ describe Gitlab::GitAccess do end context 'pull code' do - subject { access.download_access_check(user, project) } + subject { access.download_access_check } it { expect(subject.allowed?).to be_falsey } end @@ -103,7 +104,7 @@ describe Gitlab::GitAccess do describe 'without acccess to project' do context 'pull code' do - subject { access.download_access_check(user, project) } + subject { access.download_access_check } it { expect(subject.allowed?).to be_falsey } end @@ -111,17 +112,18 @@ describe Gitlab::GitAccess do describe 'deploy key permissions' do let(:key) { create(:deploy_key) } + let(:actor) { key } context 'pull code' do context 'allowed' do before { key.projects << project } - subject { access.download_access_check(key, project) } + subject { access.download_access_check } it { expect(subject.allowed?).to be_truthy } end context 'denied' do - subject { access.download_access_check(key, project) } + subject { access.download_access_check } it { expect(subject.allowed?).to be_falsey } end @@ -205,7 +207,7 @@ describe Gitlab::GitAccess do permissions_matrix[role].each do |action, allowed| context action do - subject { access.push_access_check(user, project, changes[action]) } + subject { access.push_access_check(changes[action]) } it { expect(subject.allowed?).to allowed ? be_truthy : be_falsey } end @@ -221,7 +223,7 @@ describe Gitlab::GitAccess do updated_permissions_matrix[role].each do |action, allowed| context action do - subject { access.push_access_check(user, project, changes[action]) } + subject { access.push_access_check(changes[action]) } it { expect(subject.allowed?).to allowed ? be_truthy : be_falsey } end diff --git a/spec/lib/gitlab/git_access_wiki_spec.rb b/spec/lib/gitlab/git_access_wiki_spec.rb index c31c6764091..4cb91094cb3 100644 --- a/spec/lib/gitlab/git_access_wiki_spec.rb +++ b/spec/lib/gitlab/git_access_wiki_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe Gitlab::GitAccessWiki do - let(:access) { Gitlab::GitAccessWiki.new } + let(:access) { Gitlab::GitAccessWiki.new(user, project) } let(:project) { create(:project) } let(:user) { create(:user) } @@ -11,7 +11,7 @@ describe Gitlab::GitAccessWiki do project.team << [user, :developer] end - subject { access.push_access_check(user, project, changes) } + subject { access.push_access_check(changes) } it { expect(subject.allowed?).to be_truthy } end |