2016-03-25 13:51:17 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe "Internal Project Snippets Access", feature: true do
|
|
|
|
include AccessMatchers
|
|
|
|
|
2016-11-02 02:47:12 -04:00
|
|
|
let(:project) { create(:empty_project, :internal) }
|
2016-03-25 13:51:17 -04:00
|
|
|
|
2016-12-02 05:18:02 -05:00
|
|
|
let(:internal_snippet) { create(:project_snippet, :internal, project: project, author: project.owner) }
|
|
|
|
let(:private_snippet) { create(:project_snippet, :private, project: project, author: project.owner) }
|
2016-03-25 13:51:17 -04:00
|
|
|
|
|
|
|
describe "GET /:project_path/snippets" do
|
2017-06-29 13:06:35 -04:00
|
|
|
subject { project_snippets_path(project) }
|
2016-03-25 13:51:17 -04:00
|
|
|
|
2016-12-02 05:18:02 -05:00
|
|
|
it { is_expected.to be_allowed_for(:admin) }
|
|
|
|
it { is_expected.to be_allowed_for(:owner).of(project) }
|
|
|
|
it { is_expected.to be_allowed_for(:master).of(project) }
|
|
|
|
it { is_expected.to be_allowed_for(:developer).of(project) }
|
|
|
|
it { is_expected.to be_allowed_for(:reporter).of(project) }
|
|
|
|
it { is_expected.to be_allowed_for(:guest).of(project) }
|
|
|
|
it { is_expected.to be_allowed_for(:user) }
|
|
|
|
it { is_expected.to be_denied_for(:external) }
|
|
|
|
it { is_expected.to be_denied_for(:visitor) }
|
2016-03-25 13:51:17 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "GET /:project_path/snippets/new" do
|
2017-06-29 13:06:35 -04:00
|
|
|
subject { new_project_snippet_path(project) }
|
2016-03-25 13:51:17 -04:00
|
|
|
|
2016-12-02 05:18:02 -05:00
|
|
|
it { is_expected.to be_allowed_for(:admin) }
|
|
|
|
it { is_expected.to be_allowed_for(:owner).of(project) }
|
|
|
|
it { is_expected.to be_allowed_for(:master).of(project) }
|
|
|
|
it { is_expected.to be_allowed_for(:developer).of(project) }
|
|
|
|
it { is_expected.to be_allowed_for(:reporter).of(project) }
|
|
|
|
it { is_expected.to be_denied_for(:guest).of(project) }
|
|
|
|
it { is_expected.to be_denied_for(:user) }
|
|
|
|
it { is_expected.to be_denied_for(:external) }
|
|
|
|
it { is_expected.to be_denied_for(:visitor) }
|
2016-03-25 13:51:17 -04:00
|
|
|
end
|
|
|
|
|
2016-11-02 02:47:12 -04:00
|
|
|
describe "GET /:project_path/snippets/:id" do
|
|
|
|
context "for an internal snippet" do
|
2017-06-29 13:06:35 -04:00
|
|
|
subject { project_snippet_path(project, internal_snippet) }
|
2016-03-25 13:51:17 -04:00
|
|
|
|
2016-12-02 05:18:02 -05:00
|
|
|
it { is_expected.to be_allowed_for(:admin) }
|
|
|
|
it { is_expected.to be_allowed_for(:owner).of(project) }
|
|
|
|
it { is_expected.to be_allowed_for(:master).of(project) }
|
|
|
|
it { is_expected.to be_allowed_for(:developer).of(project) }
|
|
|
|
it { is_expected.to be_allowed_for(:reporter).of(project) }
|
|
|
|
it { is_expected.to be_allowed_for(:guest).of(project) }
|
|
|
|
it { is_expected.to be_allowed_for(:user) }
|
|
|
|
it { is_expected.to be_denied_for(:external) }
|
|
|
|
it { is_expected.to be_denied_for(:visitor) }
|
2016-11-02 02:47:12 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context "for a private snippet" do
|
2017-06-29 13:06:35 -04:00
|
|
|
subject { project_snippet_path(project, private_snippet) }
|
2016-11-02 02:47:12 -04:00
|
|
|
|
2016-12-02 05:18:02 -05:00
|
|
|
it { is_expected.to be_allowed_for(:admin) }
|
|
|
|
it { is_expected.to be_allowed_for(:owner).of(project) }
|
|
|
|
it { is_expected.to be_allowed_for(:master).of(project) }
|
|
|
|
it { is_expected.to be_allowed_for(:developer).of(project) }
|
|
|
|
it { is_expected.to be_allowed_for(:reporter).of(project) }
|
|
|
|
it { is_expected.to be_allowed_for(:guest).of(project) }
|
|
|
|
it { is_expected.to be_denied_for(:user) }
|
|
|
|
it { is_expected.to be_denied_for(:external) }
|
|
|
|
it { is_expected.to be_denied_for(:visitor) }
|
2016-11-02 02:47:12 -04:00
|
|
|
end
|
2016-03-25 13:51:17 -04:00
|
|
|
end
|
|
|
|
|
2016-11-02 02:47:12 -04:00
|
|
|
describe "GET /:project_path/snippets/:id/raw" do
|
|
|
|
context "for an internal snippet" do
|
2017-06-29 13:06:35 -04:00
|
|
|
subject { raw_project_snippet_path(project, internal_snippet) }
|
2016-03-25 13:51:17 -04:00
|
|
|
|
2016-12-02 05:18:02 -05:00
|
|
|
it { is_expected.to be_allowed_for(:admin) }
|
|
|
|
it { is_expected.to be_allowed_for(:owner).of(project) }
|
|
|
|
it { is_expected.to be_allowed_for(:master).of(project) }
|
|
|
|
it { is_expected.to be_allowed_for(:developer).of(project) }
|
|
|
|
it { is_expected.to be_allowed_for(:reporter).of(project) }
|
|
|
|
it { is_expected.to be_allowed_for(:guest).of(project) }
|
|
|
|
it { is_expected.to be_allowed_for(:user) }
|
|
|
|
it { is_expected.to be_denied_for(:external) }
|
|
|
|
it { is_expected.to be_denied_for(:visitor) }
|
2016-11-02 02:47:12 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context "for a private snippet" do
|
2017-06-29 13:06:35 -04:00
|
|
|
subject { raw_project_snippet_path(project, private_snippet) }
|
2016-11-02 02:47:12 -04:00
|
|
|
|
2016-12-02 05:18:02 -05:00
|
|
|
it { is_expected.to be_allowed_for(:admin) }
|
|
|
|
it { is_expected.to be_allowed_for(:owner).of(project) }
|
|
|
|
it { is_expected.to be_allowed_for(:master).of(project) }
|
|
|
|
it { is_expected.to be_allowed_for(:developer).of(project) }
|
|
|
|
it { is_expected.to be_allowed_for(:reporter).of(project) }
|
|
|
|
it { is_expected.to be_allowed_for(:guest).of(project) }
|
|
|
|
it { is_expected.to be_denied_for(:user) }
|
|
|
|
it { is_expected.to be_denied_for(:external) }
|
|
|
|
it { is_expected.to be_denied_for(:visitor) }
|
2016-11-02 02:47:12 -04:00
|
|
|
end
|
2016-03-25 13:51:17 -04:00
|
|
|
end
|
|
|
|
end
|