diff --git a/app/assets/javascripts/releases/components/release_block.vue b/app/assets/javascripts/releases/components/release_block.vue index 4295fef8f0acdd39ae9509d56639068474536030..1d47133e89898e448ee139f85e72f8df3afc5396 100644 --- a/app/assets/javascripts/releases/components/release_block.vue +++ b/app/assets/javascripts/releases/components/release_block.vue @@ -87,7 +87,7 @@ export default {
{{ __('Assets') }} diff --git a/app/models/repository.rb b/app/models/repository.rb index b19ae2e0e6a500ae7d9221cc708b119de5e252e9..b47238b52f16ffcb123d8e3116ce24167cdaf0a3 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -1072,19 +1072,11 @@ class Repository end def cache - @cache ||= if is_wiki - Gitlab::RepositoryCache.new(self, extra_namespace: 'wiki') - else - Gitlab::RepositoryCache.new(self) - end + @cache ||= Gitlab::RepositoryCache.new(self) end def request_store_cache - @request_store_cache ||= if is_wiki - Gitlab::RepositoryCache.new(self, extra_namespace: 'wiki', backend: Gitlab::SafeRequestStore) - else - Gitlab::RepositoryCache.new(self, backend: Gitlab::SafeRequestStore) - end + @request_store_cache ||= Gitlab::RepositoryCache.new(self, backend: Gitlab::SafeRequestStore) end def tags_sorted_by_committed_date diff --git a/app/views/shared/issuable/_sidebar_assignees.html.haml b/app/views/shared/issuable/_sidebar_assignees.html.haml index c5cce1823f0a5732ead3282795000aee65fa0777..1a59055f6528c797ad15f6eb35f67d856f014685 100644 --- a/app/views/shared/issuable/_sidebar_assignees.html.haml +++ b/app/views/shared/issuable/_sidebar_assignees.html.haml @@ -25,7 +25,7 @@ .value.hide-collapsed - if issuable_sidebar[:assignee] = link_to_member(@project, assignee, size: 32, extra_class: 'bold') do - - if issuable_sidebar[:assignee][:can_merge] + - unless issuable_sidebar[:assignee][:can_merge] %span.float-right.cannot-be-merged{ data: { toggle: 'tooltip', placement: 'left' }, title: _('Not allowed to merge') } = icon('exclamation-triangle', 'aria-hidden': 'true') %span.username diff --git a/changelogs/unreleased/56076-releases-margin.yml b/changelogs/unreleased/56076-releases-margin.yml new file mode 100644 index 0000000000000000000000000000000000000000..a3cae1e035f5ef1bd56471827c79129de3696b98 --- /dev/null +++ b/changelogs/unreleased/56076-releases-margin.yml @@ -0,0 +1,5 @@ +--- +title: Fixes missing margin in releases block +merge_request: +author: +type: fixed diff --git a/lib/gitlab/repository_cache.rb b/lib/gitlab/repository_cache.rb index 6b0808f53047dbac9999df886317e1ca0a2c254b..56007574b1b75fb11974993f74a0f46ac65ce49c 100644 --- a/lib/gitlab/repository_cache.rb +++ b/lib/gitlab/repository_cache.rb @@ -7,13 +7,13 @@ module Gitlab def initialize(repository, extra_namespace: nil, backend: Rails.cache) @repository = repository - @namespace = "project:#{repository.project.id}" + @namespace = "#{repository.full_path}:#{repository.project.id}" @namespace = "#{@namespace}:#{extra_namespace}" if extra_namespace @backend = backend end def cache_key(type) - "#{namespace}:#{type}" + "#{type}:#{namespace}" end def expire(key) diff --git a/spec/features/projects/files/user_browses_lfs_files_spec.rb b/spec/features/projects/files/user_browses_lfs_files_spec.rb index c559a301ca1c6883a1c1bba96a816d71f309f6e0..d56476adb05b349d4ce3753bdc5dc966009ad305 100644 --- a/spec/features/projects/files/user_browses_lfs_files_spec.rb +++ b/spec/features/projects/files/user_browses_lfs_files_spec.rb @@ -12,6 +12,7 @@ describe 'Projects > Files > User browses LFS files' do before do allow_any_instance_of(Project).to receive(:lfs_enabled?).and_return(false) visit project_tree_path(project, 'lfs') + wait_for_requests end it 'is possible to see raw content of LFS pointer' do @@ -26,10 +27,11 @@ describe 'Projects > Files > User browses LFS files' do end end - context 'when LFS is enabled' do + context 'when LFS is enabled', :js do before do allow_any_instance_of(Project).to receive(:lfs_enabled?).and_return(true) visit project_tree_path(project, 'lfs') + wait_for_requests end it 'shows an LFS object' do diff --git a/spec/lib/gitlab/repository_cache_spec.rb b/spec/lib/gitlab/repository_cache_spec.rb index 1b9a8b4ab0dbb6ec4d172d188156772b5fac0f39..741ee12633f3a4744b897013242b5708aaeeee24 100644 --- a/spec/lib/gitlab/repository_cache_spec.rb +++ b/spec/lib/gitlab/repository_cache_spec.rb @@ -4,14 +4,14 @@ describe Gitlab::RepositoryCache do let(:backend) { double('backend').as_null_object } let(:project) { create(:project) } let(:repository) { project.repository } - let(:namespace) { "project:#{project.id}" } + let(:namespace) { "#{repository.full_path}:#{project.id}" } let(:cache) { described_class.new(repository, backend: backend) } describe '#cache_key' do subject { cache.cache_key(:foo) } it 'includes the namespace' do - expect(subject).to eq "#{namespace}:foo" + expect(subject).to eq "foo:#{namespace}" end context 'with a given namespace' do @@ -22,7 +22,7 @@ describe Gitlab::RepositoryCache do end it 'includes the full namespace' do - expect(subject).to eq "#{namespace}:#{extra_namespace}:foo" + expect(subject).to eq "foo:#{namespace}:#{extra_namespace}" end end end @@ -30,21 +30,21 @@ describe Gitlab::RepositoryCache do describe '#expire' do it 'expires the given key from the cache' do cache.expire(:foo) - expect(backend).to have_received(:delete).with("#{namespace}:foo") + expect(backend).to have_received(:delete).with("foo:#{namespace}") end end describe '#fetch' do it 'fetches the given key from the cache' do cache.fetch(:bar) - expect(backend).to have_received(:fetch).with("#{namespace}:bar") + expect(backend).to have_received(:fetch).with("bar:#{namespace}") end it 'accepts a block' do p = -> {} cache.fetch(:baz, &p) - expect(backend).to have_received(:fetch).with("#{namespace}:baz", &p) + expect(backend).to have_received(:fetch).with("baz:#{namespace}", &p) end end @@ -67,7 +67,7 @@ describe Gitlab::RepositoryCache do end it 'caches the value' do - expect(backend).to receive(:write).with("#{namespace}:#{key}", true) + expect(backend).to receive(:write).with("#{key}:#{namespace}", true) cache.fetch_without_caching_false(key) { true } end @@ -83,7 +83,7 @@ describe Gitlab::RepositoryCache do end it 'does not cache the value' do - expect(backend).not_to receive(:write).with("#{namespace}:#{key}", true) + expect(backend).not_to receive(:write).with("#{key}:#{namespace}", true) cache.fetch_without_caching_false(key, &p) end @@ -92,7 +92,7 @@ describe Gitlab::RepositoryCache do context 'when the cached value is truthy' do before do - backend.write("#{namespace}:#{key}", true) + backend.write("#{key}:#{namespace}", true) end it 'returns the cached value' do @@ -116,7 +116,7 @@ describe Gitlab::RepositoryCache do context 'when the cached value is falsey' do before do - backend.write("#{namespace}:#{key}", false) + backend.write("#{key}:#{namespace}", false) end it 'returns the result of the block' do @@ -126,7 +126,7 @@ describe Gitlab::RepositoryCache do end it 'writes the truthy value to the cache' do - expect(backend).to receive(:write).with("#{namespace}:#{key}", 'block result') + expect(backend).to receive(:write).with("#{key}:#{namespace}", 'block result') cache.fetch_without_caching_false(key) { 'block result' } end diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index 2063b4bbe75762338287e0e2558bd71ea1e367e3..ac5874fd0f7a4454104df0fd5e801b895eea84d6 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -2400,22 +2400,4 @@ describe Repository do repository.merge_base('master', 'fix') end end - - describe '#cache' do - subject(:cache) { repository.send(:cache) } - - it 'returns a RepositoryCache' do - expect(subject).to be_kind_of Gitlab::RepositoryCache - end - - it 'when is_wiki it includes wiki as part of key' do - allow(repository).to receive(:is_wiki) { true } - - expect(subject.namespace).to include('wiki') - end - - it 'when is_wiki is false extra_namespace is nil' do - expect(subject.namespace).not_to include('wiki') - end - end end diff --git a/spec/views/projects/merge_requests/show.html.haml_spec.rb b/spec/views/projects/merge_requests/show.html.haml_spec.rb index b0042be339cdd91b8c466907308573322f31e16a..d9bda1a34148a47e2e49cc70e158f913fe7840a9 100644 --- a/spec/views/projects/merge_requests/show.html.haml_spec.rb +++ b/spec/views/projects/merge_requests/show.html.haml_spec.rb @@ -32,11 +32,7 @@ describe 'projects/merge_requests/show.html.haml' do assign(:noteable, closed_merge_request) assign(:notes, []) assign(:pipelines, Ci::Pipeline.none) - assign( - :issuable_sidebar, - MergeRequestSerializer.new(current_user: user, project: project) - .represent(closed_merge_request, serializer: 'sidebar') - ) + assign(:issuable_sidebar, serialize_issuable_sidebar(user, project, closed_merge_request)) preload_view_requirements @@ -45,6 +41,33 @@ describe 'projects/merge_requests/show.html.haml' do current_application_settings: Gitlab::CurrentSettings.current_application_settings) end + describe 'merge request assignee sidebar' do + context 'when assignee is allowed to merge' do + it 'does not show a warning icon' do + closed_merge_request.update(assignee_id: user.id) + project.add_maintainer(user) + assign(:issuable_sidebar, serialize_issuable_sidebar(user, project, closed_merge_request)) + + render + + expect(rendered).not_to have_css('.cannot-be-merged') + end + end + + context 'when assignee is not allowed to merge' do + it 'shows a warning icon' do + reporter = create(:user) + project.add_reporter(reporter) + closed_merge_request.update(assignee_id: reporter.id) + assign(:issuable_sidebar, serialize_issuable_sidebar(user, project, closed_merge_request)) + + render + + expect(rendered).to have_css('.cannot-be-merged') + end + end + end + context 'when the merge request is closed' do it 'shows the "Reopen" button' do render @@ -80,4 +103,10 @@ describe 'projects/merge_requests/show.html.haml' do expect(rendered).to have_css('a', visible: false, text: 'Close') end end + + def serialize_issuable_sidebar(user, project, merge_request) + MergeRequestSerializer + .new(current_user: user, project: project) + .represent(closed_merge_request, serializer: 'sidebar') + end end