diff options
author | Francisco Javier López <fjlopez@gitlab.com> | 2018-07-06 07:51:31 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2018-07-06 07:51:31 +0000 |
commit | 837c3b3d7322c56aa7baeec9b8fb617afe5b5e5c (patch) | |
tree | b6da7ba13c76c13e3afee03c11b7524f896f207f /spec | |
parent | 83f79ced3fd98031194e5667c4d80f66d7987c67 (diff) | |
download | gitlab-ce-837c3b3d7322c56aa7baeec9b8fb617afe5b5e5c.tar.gz |
Fix User role displayed on projects dashboard
Diffstat (limited to 'spec')
-rw-r--r-- | spec/features/dashboard/projects_spec.rb | 28 | ||||
-rw-r--r-- | spec/helpers/projects_helper_spec.rb | 5 | ||||
-rw-r--r-- | spec/spec_helper.rb | 11 |
3 files changed, 44 insertions, 0 deletions
diff --git a/spec/features/dashboard/projects_spec.rb b/spec/features/dashboard/projects_spec.rb index 46935662288..8647616101b 100644 --- a/spec/features/dashboard/projects_spec.rb +++ b/spec/features/dashboard/projects_spec.rb @@ -29,6 +29,34 @@ describe 'Dashboard Projects' do end end + context 'when user has access to the project' do + it 'shows role badge' do + visit dashboard_projects_path + + page.within '.user-access-role' do + expect(page).to have_content('Developer') + end + end + + context 'when role changes', :use_clean_rails_memory_store_fragment_caching do + it 'displays the right role' do + visit dashboard_projects_path + + page.within '.user-access-role' do + expect(page).to have_content('Developer') + end + + project.members.last.update(access_level: 40) + + visit dashboard_projects_path + + page.within '.user-access-role' do + expect(page).to have_content('Maintainer') + end + end + end + end + context 'when last_repository_updated_at, last_activity_at and update_at are present' do it 'shows the last_repository_updated_at attribute as the update date' do project.update_attributes!(last_repository_updated_at: Time.now, last_activity_at: 1.hour.ago) diff --git a/spec/helpers/projects_helper_spec.rb b/spec/helpers/projects_helper_spec.rb index 80147b13739..beb6e8ea273 100644 --- a/spec/helpers/projects_helper_spec.rb +++ b/spec/helpers/projects_helper_spec.rb @@ -80,6 +80,7 @@ describe ProjectsHelper do before do allow(helper).to receive(:current_user).and_return(user) allow(helper).to receive(:can?).with(user, :read_cross_project) { true } + allow(user).to receive(:max_member_access_for_project).and_return(40) end it "includes the route" do @@ -125,6 +126,10 @@ describe ProjectsHelper do expect(helper.project_list_cache_key(project)).to include("pipeline-status/#{project.commit.sha}-success") end + + it "includes the user max member access" do + expect(helper.project_list_cache_key(project)).to include('access:40') + end end describe '#load_pipeline_status' do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index fdce8e84620..46ec1bcef24 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -170,6 +170,17 @@ RSpec.configure do |config| redis_queues_cleanup! end + config.around(:each, :use_clean_rails_memory_store_fragment_caching) do |example| + caching_store = ActionController::Base.cache_store + ActionController::Base.cache_store = ActiveSupport::Cache::MemoryStore.new + ActionController::Base.perform_caching = true + + example.run + + ActionController::Base.perform_caching = false + ActionController::Base.cache_store = caching_store + end + # The :each scope runs "inside" the example, so this hook ensures the DB is in the # correct state before any examples' before hooks are called. This prevents a # problem where `ScheduleIssuesClosedAtTypeChange` (or any migration that depends |