2013-11-06 10:13:21 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2014-04-12 04:56:37 -04:00
|
|
|
describe "Internal Project Access", feature: true do
|
2014-03-19 05:15:24 -04:00
|
|
|
let(:project) { create(:project, :internal) }
|
2013-11-06 10:13:21 -05:00
|
|
|
|
|
|
|
let(:master) { create(:user) }
|
|
|
|
let(:guest) { create(:user) }
|
|
|
|
let(:reporter) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
# full access
|
|
|
|
project.team << [master, :master]
|
|
|
|
|
|
|
|
# readonly
|
|
|
|
project.team << [reporter, :reporter]
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "Project should be internal" do
|
|
|
|
subject { project }
|
|
|
|
|
2015-02-12 13:17:35 -05:00
|
|
|
describe '#internal?' do
|
|
|
|
subject { super().internal? }
|
|
|
|
it { is_expected.to be_truthy }
|
|
|
|
end
|
2013-11-06 10:13:21 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "GET /:project_path" do
|
2015-01-24 13:02:58 -05:00
|
|
|
subject { namespace_project_path(project.namespace, project) }
|
2013-11-06 10:13:21 -05:00
|
|
|
|
2015-02-12 13:17:35 -05:00
|
|
|
it { is_expected.to be_allowed_for master }
|
|
|
|
it { is_expected.to be_allowed_for reporter }
|
|
|
|
it { is_expected.to be_allowed_for :admin }
|
|
|
|
it { is_expected.to be_allowed_for guest }
|
|
|
|
it { is_expected.to be_allowed_for :user }
|
|
|
|
it { is_expected.to be_denied_for :visitor }
|
2013-11-06 10:13:21 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "GET /:project_path/tree/master" do
|
2015-01-24 13:02:58 -05:00
|
|
|
subject { namespace_project_tree_path(project.namespace, project, project.repository.root_ref) }
|
2013-11-06 10:13:21 -05:00
|
|
|
|
2015-02-12 13:17:35 -05:00
|
|
|
it { is_expected.to be_allowed_for master }
|
|
|
|
it { is_expected.to be_allowed_for reporter }
|
|
|
|
it { is_expected.to be_allowed_for :admin }
|
|
|
|
it { is_expected.to be_allowed_for guest }
|
|
|
|
it { is_expected.to be_allowed_for :user }
|
|
|
|
it { is_expected.to be_denied_for :visitor }
|
2013-11-06 10:13:21 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "GET /:project_path/commits/master" do
|
2015-01-24 13:02:58 -05:00
|
|
|
subject { namespace_project_commits_path(project.namespace, project, project.repository.root_ref, limit: 1) }
|
2013-11-06 10:13:21 -05:00
|
|
|
|
2015-02-12 13:17:35 -05:00
|
|
|
it { is_expected.to be_allowed_for master }
|
|
|
|
it { is_expected.to be_allowed_for reporter }
|
|
|
|
it { is_expected.to be_allowed_for :admin }
|
|
|
|
it { is_expected.to be_allowed_for guest }
|
|
|
|
it { is_expected.to be_allowed_for :user }
|
|
|
|
it { is_expected.to be_denied_for :visitor }
|
2013-11-06 10:13:21 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "GET /:project_path/commit/:sha" do
|
2015-01-24 13:02:58 -05:00
|
|
|
subject { namespace_project_commit_path(project.namespace, project, project.repository.commit) }
|
2013-11-06 10:13:21 -05:00
|
|
|
|
2015-02-12 13:17:35 -05:00
|
|
|
it { is_expected.to be_allowed_for master }
|
|
|
|
it { is_expected.to be_allowed_for reporter }
|
|
|
|
it { is_expected.to be_allowed_for :admin }
|
|
|
|
it { is_expected.to be_allowed_for guest }
|
|
|
|
it { is_expected.to be_allowed_for :user }
|
|
|
|
it { is_expected.to be_denied_for :visitor }
|
2013-11-06 10:13:21 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "GET /:project_path/compare" do
|
2015-01-24 13:02:58 -05:00
|
|
|
subject { namespace_project_compare_index_path(project.namespace, project) }
|
2013-11-06 10:13:21 -05:00
|
|
|
|
2015-02-12 13:17:35 -05:00
|
|
|
it { is_expected.to be_allowed_for master }
|
|
|
|
it { is_expected.to be_allowed_for reporter }
|
|
|
|
it { is_expected.to be_allowed_for :admin }
|
|
|
|
it { is_expected.to be_allowed_for guest }
|
|
|
|
it { is_expected.to be_allowed_for :user }
|
|
|
|
it { is_expected.to be_denied_for :visitor }
|
2013-11-06 10:13:21 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "GET /:project_path/team" do
|
2015-01-24 13:02:58 -05:00
|
|
|
subject { namespace_project_team_index_path(project.namespace, project) }
|
2013-11-06 10:13:21 -05:00
|
|
|
|
2015-02-12 13:17:35 -05:00
|
|
|
it { is_expected.to be_allowed_for master }
|
|
|
|
it { is_expected.to be_denied_for reporter }
|
|
|
|
it { is_expected.to be_allowed_for :admin }
|
|
|
|
it { is_expected.to be_denied_for guest }
|
|
|
|
it { is_expected.to be_denied_for :user }
|
|
|
|
it { is_expected.to be_denied_for :visitor }
|
2013-11-06 10:13:21 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "GET /:project_path/blob" do
|
|
|
|
before do
|
|
|
|
commit = project.repository.commit
|
2014-09-25 09:10:03 -04:00
|
|
|
path = '.gitignore'
|
2015-01-24 13:02:58 -05:00
|
|
|
@blob_path = namespace_project_blob_path(project.namespace, project, File.join(commit.id, path))
|
2013-11-06 10:13:21 -05:00
|
|
|
end
|
|
|
|
|
2015-02-12 13:17:35 -05:00
|
|
|
it { expect(@blob_path).to be_allowed_for master }
|
|
|
|
it { expect(@blob_path).to be_allowed_for reporter }
|
|
|
|
it { expect(@blob_path).to be_allowed_for :admin }
|
|
|
|
it { expect(@blob_path).to be_allowed_for guest }
|
|
|
|
it { expect(@blob_path).to be_allowed_for :user }
|
|
|
|
it { expect(@blob_path).to be_denied_for :visitor }
|
2013-11-06 10:13:21 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "GET /:project_path/edit" do
|
2015-01-24 13:02:58 -05:00
|
|
|
subject { edit_namespace_project_path(project.namespace, project) }
|
2013-11-06 10:13:21 -05:00
|
|
|
|
2015-02-12 13:17:35 -05:00
|
|
|
it { is_expected.to be_allowed_for master }
|
|
|
|
it { is_expected.to be_denied_for reporter }
|
|
|
|
it { is_expected.to be_allowed_for :admin }
|
|
|
|
it { is_expected.to be_denied_for guest }
|
|
|
|
it { is_expected.to be_denied_for :user }
|
|
|
|
it { is_expected.to be_denied_for :visitor }
|
2013-11-06 10:13:21 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "GET /:project_path/deploy_keys" do
|
2015-01-24 13:02:58 -05:00
|
|
|
subject { namespace_project_deploy_keys_path(project.namespace, project) }
|
2013-11-06 10:13:21 -05:00
|
|
|
|
2015-02-12 13:17:35 -05:00
|
|
|
it { is_expected.to be_allowed_for master }
|
|
|
|
it { is_expected.to be_denied_for reporter }
|
|
|
|
it { is_expected.to be_allowed_for :admin }
|
|
|
|
it { is_expected.to be_denied_for guest }
|
|
|
|
it { is_expected.to be_denied_for :user }
|
|
|
|
it { is_expected.to be_denied_for :visitor }
|
2013-11-06 10:13:21 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "GET /:project_path/issues" do
|
2015-01-24 13:02:58 -05:00
|
|
|
subject { namespace_project_issues_path(project.namespace, project) }
|
2013-11-06 10:13:21 -05:00
|
|
|
|
2015-02-12 13:17:35 -05:00
|
|
|
it { is_expected.to be_allowed_for master }
|
|
|
|
it { is_expected.to be_allowed_for reporter }
|
|
|
|
it { is_expected.to be_allowed_for :admin }
|
|
|
|
it { is_expected.to be_allowed_for guest }
|
|
|
|
it { is_expected.to be_allowed_for :user }
|
|
|
|
it { is_expected.to be_denied_for :visitor }
|
2013-11-06 10:13:21 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "GET /:project_path/snippets" do
|
2015-01-24 13:02:58 -05:00
|
|
|
subject { namespace_project_snippets_path(project.namespace, project) }
|
2013-11-06 10:13:21 -05:00
|
|
|
|
2015-02-12 13:17:35 -05:00
|
|
|
it { is_expected.to be_allowed_for master }
|
|
|
|
it { is_expected.to be_allowed_for reporter }
|
|
|
|
it { is_expected.to be_allowed_for :admin }
|
|
|
|
it { is_expected.to be_allowed_for guest }
|
|
|
|
it { is_expected.to be_allowed_for :user }
|
|
|
|
it { is_expected.to be_denied_for :visitor }
|
2013-11-06 10:13:21 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "GET /:project_path/snippets/new" do
|
2015-01-24 13:02:58 -05:00
|
|
|
subject { new_namespace_project_snippet_path(project.namespace, project) }
|
2013-11-06 10:13:21 -05:00
|
|
|
|
2015-02-12 13:17:35 -05:00
|
|
|
it { is_expected.to be_allowed_for master }
|
|
|
|
it { is_expected.to be_allowed_for reporter }
|
|
|
|
it { is_expected.to be_allowed_for :admin }
|
|
|
|
it { is_expected.to be_denied_for guest }
|
|
|
|
it { is_expected.to be_denied_for :user }
|
|
|
|
it { is_expected.to be_denied_for :visitor }
|
2013-11-06 10:13:21 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "GET /:project_path/merge_requests" do
|
2015-01-24 13:02:58 -05:00
|
|
|
subject { namespace_project_merge_requests_path(project.namespace, project) }
|
2013-11-06 10:13:21 -05:00
|
|
|
|
2015-02-12 13:17:35 -05:00
|
|
|
it { is_expected.to be_allowed_for master }
|
|
|
|
it { is_expected.to be_allowed_for reporter }
|
|
|
|
it { is_expected.to be_allowed_for :admin }
|
|
|
|
it { is_expected.to be_allowed_for guest }
|
|
|
|
it { is_expected.to be_allowed_for :user }
|
|
|
|
it { is_expected.to be_denied_for :visitor }
|
2013-11-06 10:13:21 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "GET /:project_path/merge_requests/new" do
|
2015-01-24 13:02:58 -05:00
|
|
|
subject { new_namespace_project_merge_request_path(project.namespace, project) }
|
2013-11-06 10:13:21 -05:00
|
|
|
|
2015-02-12 13:17:35 -05:00
|
|
|
it { is_expected.to be_allowed_for master }
|
|
|
|
it { is_expected.to be_denied_for reporter }
|
|
|
|
it { is_expected.to be_allowed_for :admin }
|
|
|
|
it { is_expected.to be_denied_for guest }
|
|
|
|
it { is_expected.to be_denied_for :user }
|
|
|
|
it { is_expected.to be_denied_for :visitor }
|
2013-11-06 10:13:21 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "GET /:project_path/branches" do
|
2015-01-24 13:02:58 -05:00
|
|
|
subject { namespace_project_branches_path(project.namespace, project) }
|
2013-11-06 10:13:21 -05:00
|
|
|
|
|
|
|
before do
|
|
|
|
# Speed increase
|
2015-02-12 13:17:35 -05:00
|
|
|
allow_any_instance_of(Project).to receive(:branches).and_return([])
|
2013-11-06 10:13:21 -05:00
|
|
|
end
|
|
|
|
|
2015-02-12 13:17:35 -05:00
|
|
|
it { is_expected.to be_allowed_for master }
|
|
|
|
it { is_expected.to be_allowed_for reporter }
|
|
|
|
it { is_expected.to be_allowed_for :admin }
|
|
|
|
it { is_expected.to be_allowed_for guest }
|
|
|
|
it { is_expected.to be_allowed_for :user }
|
|
|
|
it { is_expected.to be_denied_for :visitor }
|
2013-11-06 10:13:21 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "GET /:project_path/tags" do
|
2015-01-24 13:02:58 -05:00
|
|
|
subject { namespace_project_tags_path(project.namespace, project) }
|
2013-11-06 10:13:21 -05:00
|
|
|
|
|
|
|
before do
|
|
|
|
# Speed increase
|
2015-02-12 13:17:35 -05:00
|
|
|
allow_any_instance_of(Project).to receive(:tags).and_return([])
|
2013-11-06 10:13:21 -05:00
|
|
|
end
|
|
|
|
|
2015-02-12 13:17:35 -05:00
|
|
|
it { is_expected.to be_allowed_for master }
|
|
|
|
it { is_expected.to be_allowed_for reporter }
|
|
|
|
it { is_expected.to be_allowed_for :admin }
|
|
|
|
it { is_expected.to be_allowed_for guest }
|
|
|
|
it { is_expected.to be_allowed_for :user }
|
|
|
|
it { is_expected.to be_denied_for :visitor }
|
2013-11-06 10:13:21 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "GET /:project_path/hooks" do
|
2015-01-24 13:02:58 -05:00
|
|
|
subject { namespace_project_hooks_path(project.namespace, project) }
|
2013-11-06 10:13:21 -05:00
|
|
|
|
2015-02-12 13:17:35 -05:00
|
|
|
it { is_expected.to be_allowed_for master }
|
|
|
|
it { is_expected.to be_denied_for reporter }
|
|
|
|
it { is_expected.to be_allowed_for :admin }
|
|
|
|
it { is_expected.to be_denied_for guest }
|
|
|
|
it { is_expected.to be_denied_for :user }
|
|
|
|
it { is_expected.to be_denied_for :visitor }
|
2013-11-06 10:13:21 -05:00
|
|
|
end
|
|
|
|
end
|