Commit b900304c authored by Robert Speicher's avatar Robert Speicher

Make better use of the `visibility_level` factory traits

parent 7000e76a
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
describe Projects::ForksController do describe Projects::ForksController do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project, visibility_level: Project::PUBLIC) } let(:project) { create(:project, :public) }
let(:forked_project) { Projects::ForkService.new(project, user).execute } let(:forked_project) { Projects::ForkService.new(project, user).execute }
let(:group) { create(:group, owner: forked_project.creator) } let(:group) { create(:group, owner: forked_project.creator) }
......
...@@ -8,12 +8,11 @@ describe SnippetsFinder do ...@@ -8,12 +8,11 @@ describe SnippetsFinder do
let(:project1) { create(:empty_project, :public, group: group) } let(:project1) { create(:empty_project, :public, group: group) }
let(:project2) { create(:empty_project, :private, group: group) } let(:project2) { create(:empty_project, :private, group: group) }
context ':all filter' do context ':all filter' do
before do before do
@snippet1 = create(:personal_snippet, visibility_level: Snippet::PRIVATE) @snippet1 = create(:personal_snippet, :private)
@snippet2 = create(:personal_snippet, visibility_level: Snippet::INTERNAL) @snippet2 = create(:personal_snippet, :internal)
@snippet3 = create(:personal_snippet, visibility_level: Snippet::PUBLIC) @snippet3 = create(:personal_snippet, :public)
end end
it "returns all private and internal snippets" do it "returns all private and internal snippets" do
...@@ -31,9 +30,9 @@ describe SnippetsFinder do ...@@ -31,9 +30,9 @@ describe SnippetsFinder do
context ':by_user filter' do context ':by_user filter' do
before do before do
@snippet1 = create(:personal_snippet, visibility_level: Snippet::PRIVATE, author: user) @snippet1 = create(:personal_snippet, :private, author: user)
@snippet2 = create(:personal_snippet, visibility_level: Snippet::INTERNAL, author: user) @snippet2 = create(:personal_snippet, :internal, author: user)
@snippet3 = create(:personal_snippet, visibility_level: Snippet::PUBLIC, author: user) @snippet3 = create(:personal_snippet, :public, author: user)
end end
it "returns all public and internal snippets" do it "returns all public and internal snippets" do
...@@ -75,9 +74,9 @@ describe SnippetsFinder do ...@@ -75,9 +74,9 @@ describe SnippetsFinder do
context 'by_project filter' do context 'by_project filter' do
before do before do
@snippet1 = create(:project_snippet, visibility_level: Snippet::PRIVATE, project: project1) @snippet1 = create(:project_snippet, :private, project: project1)
@snippet2 = create(:project_snippet, visibility_level: Snippet::INTERNAL, project: project1) @snippet2 = create(:project_snippet, :internal, project: project1)
@snippet3 = create(:project_snippet, visibility_level: Snippet::PUBLIC, project: project1) @snippet3 = create(:project_snippet, :public, project: project1)
end end
it "returns public snippets for unauthorized user" do it "returns public snippets for unauthorized user" do
......
...@@ -58,7 +58,7 @@ describe VisibilityLevelHelper do ...@@ -58,7 +58,7 @@ describe VisibilityLevelHelper do
describe "skip_level?" do describe "skip_level?" do
describe "forks" do describe "forks" do
let(:project) { create(:project, visibility_level: Gitlab::VisibilityLevel::INTERNAL) } let(:project) { create(:project, :internal) }
let(:fork_project) { create(:forked_project_with_submodules) } let(:fork_project) { create(:forked_project_with_submodules) }
before do before do
...@@ -74,7 +74,7 @@ describe VisibilityLevelHelper do ...@@ -74,7 +74,7 @@ describe VisibilityLevelHelper do
end end
describe "non-forked project" do describe "non-forked project" do
let(:project) { create(:project, visibility_level: Gitlab::VisibilityLevel::INTERNAL) } let(:project) { create(:project, :internal) }
it "skips levels" do it "skips levels" do
expect(skip_level?(project, Gitlab::VisibilityLevel::PUBLIC)).to be_falsey expect(skip_level?(project, Gitlab::VisibilityLevel::PUBLIC)).to be_falsey
...@@ -84,7 +84,7 @@ describe VisibilityLevelHelper do ...@@ -84,7 +84,7 @@ describe VisibilityLevelHelper do
end end
describe "Snippet" do describe "Snippet" do
let(:snippet) { create(:snippet, visibility_level: Gitlab::VisibilityLevel::INTERNAL) } let(:snippet) { create(:snippet, :internal) }
it "skips levels" do it "skips levels" do
expect(skip_level?(snippet, Gitlab::VisibilityLevel::PUBLIC)).to be_falsey expect(skip_level?(snippet, Gitlab::VisibilityLevel::PUBLIC)).to be_falsey
......
...@@ -561,7 +561,7 @@ describe Project, models: true do ...@@ -561,7 +561,7 @@ describe Project, models: true do
end end
describe '#visibility_level_allowed?' do describe '#visibility_level_allowed?' do
let(:project) { create :project, visibility_level: Gitlab::VisibilityLevel::INTERNAL } let(:project) { create(:project, :internal) }
context 'when checking on non-forked project' do context 'when checking on non-forked project' do
it { expect(project.visibility_level_allowed?(Gitlab::VisibilityLevel::PRIVATE)).to be_truthy } it { expect(project.visibility_level_allowed?(Gitlab::VisibilityLevel::PRIVATE)).to be_truthy }
......
...@@ -102,8 +102,8 @@ describe Projects::UpdateService, services: true do ...@@ -102,8 +102,8 @@ describe Projects::UpdateService, services: true do
describe :visibility_level do describe :visibility_level do
let(:user) { create :user, admin: true } let(:user) { create :user, admin: true }
let(:project) { create :project, visibility_level: Gitlab::VisibilityLevel::INTERNAL } let(:project) { create(:project, :internal) }
let(:forked_project) { create :forked_project_with_submodules, visibility_level: Gitlab::VisibilityLevel::INTERNAL } let(:forked_project) { create(:forked_project_with_submodules, :internal) }
let(:opts) { {} } let(:opts) { {} }
before do before do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment