diff options
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/concerns/avatarable_spec.rb | 39 | ||||
-rw-r--r-- | spec/models/member_spec.rb | 4 | ||||
-rw-r--r-- | spec/models/project_group_link_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/user_spec.rb | 2 |
4 files changed, 25 insertions, 22 deletions
diff --git a/spec/models/concerns/avatarable_spec.rb b/spec/models/concerns/avatarable_spec.rb index cbdc438be0b..3696e6f62fd 100644 --- a/spec/models/concerns/avatarable_spec.rb +++ b/spec/models/concerns/avatarable_spec.rb @@ -1,11 +1,11 @@ require 'spec_helper' describe Avatarable do - subject { create(:project, avatar: fixture_file_upload(File.join(Rails.root, 'spec/fixtures/dk.png'))) } + set(:project) { create(:project, avatar: fixture_file_upload(File.join(Rails.root, 'spec/fixtures/dk.png'))) } let(:gitlab_host) { "https://gitlab.example.com" } let(:relative_url_root) { "/gitlab" } - let(:asset_host) { "https://gitlab-assets.example.com" } + let(:asset_host) { 'https://gitlab-assets.example.com' } before do stub_config_setting(base_url: gitlab_host) @@ -15,29 +15,32 @@ describe Avatarable do describe '#avatar_path' do using RSpec::Parameterized::TableSyntax - where(:has_asset_host, :visibility_level, :only_path, :avatar_path) do - true | Project::PRIVATE | true | [gitlab_host, relative_url_root, subject.avatar.url] - true | Project::PRIVATE | false | [gitlab_host, relative_url_root, subject.avatar.url] - true | Project::INTERNAL | true | [gitlab_host, relative_url_root, subject.avatar.url] - true | Project::INTERNAL | false | [gitlab_host, relative_url_root, subject.avatar.url] - true | Project::PUBLIC | true | [subject.avatar.url] - true | Project::PUBLIC | false | [asset_host, subject.avatar.url] - false | Project::PRIVATE | true | [relative_url_root, subject.avatar.url] - false | Project::PRIVATE | false | [gitlab_host, relative_url_root, subject.avatar.url] - false | Project::INTERNAL | true | [relative_url_root, subject.avatar.url] - false | Project::INTERNAL | false | [gitlab_host, relative_url_root, subject.avatar.url] - false | Project::PUBLIC | true | [relative_url_root, subject.avatar.url] - false | Project::PUBLIC | false | [gitlab_host, relative_url_root, subject.avatar.url] + where(:has_asset_host, :visibility_level, :only_path, :avatar_path_prefix) do + true | Project::PRIVATE | true | [gitlab_host, relative_url_root] + true | Project::PRIVATE | false | [gitlab_host, relative_url_root] + true | Project::INTERNAL | true | [gitlab_host, relative_url_root] + true | Project::INTERNAL | false | [gitlab_host, relative_url_root] + true | Project::PUBLIC | true | [] + true | Project::PUBLIC | false | [asset_host] + false | Project::PRIVATE | true | [relative_url_root] + false | Project::PRIVATE | false | [gitlab_host, relative_url_root] + false | Project::INTERNAL | true | [relative_url_root] + false | Project::INTERNAL | false | [gitlab_host, relative_url_root] + false | Project::PUBLIC | true | [relative_url_root] + false | Project::PUBLIC | false | [gitlab_host, relative_url_root] end with_them do before do - allow(ActionController::Base).to receive(:asset_host).and_return(has_asset_host ? asset_host : nil) - subject.visibility_level = visibility_level + allow(ActionController::Base).to receive(:asset_host) { has_asset_host && asset_host } + + project.visibility_level = visibility_level end + let(:avatar_path) { (avatar_path_prefix + [project.avatar.url]).join } + it 'returns the expected avatar path' do - expect(subject.avatar_path(only_path: only_path)).to eq(avatar_path.join) + expect(project.avatar_path(only_path: only_path)).to eq(avatar_path) end end end diff --git a/spec/models/member_spec.rb b/spec/models/member_spec.rb index 6aa0e7f49c3..c64cdf8f812 100644 --- a/spec/models/member_spec.rb +++ b/spec/models/member_spec.rb @@ -488,7 +488,7 @@ describe Member do member.accept_invite!(user) end - it "refreshes user's authorized projects", :truncate do + it "refreshes user's authorized projects", :delete do project = member.source expect(user.authorized_projects).not_to include(project) @@ -523,7 +523,7 @@ describe Member do end end - describe "destroying a record", :truncate do + describe "destroying a record", :delete do it "refreshes user's authorized projects" do project = create(:project, :private) user = create(:user) diff --git a/spec/models/project_group_link_spec.rb b/spec/models/project_group_link_spec.rb index 41e2ab20d69..1fccf92627a 100644 --- a/spec/models/project_group_link_spec.rb +++ b/spec/models/project_group_link_spec.rb @@ -30,7 +30,7 @@ describe ProjectGroupLink do end end - describe "destroying a record", :truncate do + describe "destroying a record", :delete do it "refreshes group users' authorized projects" do project = create(:project, :private) group = create(:group) diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 762cec9b95e..594f23718da 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1569,7 +1569,7 @@ describe User do it { is_expected.to eq([private_group]) } end - describe '#authorized_projects', :truncate do + describe '#authorized_projects', :delete do context 'with a minimum access level' do it 'includes projects for which the user is an owner' do user = create(:user) |