diff --git a/.gitlab/issue_templates/Feature Flag Roll Out.md b/.gitlab/issue_templates/Feature Flag Roll Out.md index d9e90f616b1..0462742513c 100644 --- a/.gitlab/issue_templates/Feature Flag Roll Out.md +++ b/.gitlab/issue_templates/Feature Flag Roll Out.md @@ -119,10 +119,10 @@ To do so, follow these steps: - [ ] Create a merge request with the following changes. Ask for review and merge it. - [ ] Set the `default_enabled` attribute in [the feature flag definition](https://docs.gitlab.com/ee/development/feature_flags/#feature-flag-definition-and-validation) to `true`. - [ ] Create [a changelog entry](https://docs.gitlab.com/ee/development/feature_flags/#changelog). -- [ ] Ensure that the default-enabling MR has been deployed to both production and canary. - If the merge request was deployed before [the code cutoff](https://about.gitlab.com/handbook/engineering/releases/#self-managed-releases-1), +- [ ] Ensure that the default-enabling MR has been included in the release package. + If the merge request was deployed before [the monthly release was tagged](https://about.gitlab.com/handbook/engineering/releases/#self-managed-releases-1), the feature can be officially announced in a release blog post. - - [ ] `/chatops run auto_deploy status ` + - [ ] `/chatops run release check ` - [ ] Close [the feature issue](ISSUE LINK) to indicate the feature will be released in the current milestone. - [ ] Set the next milestone to this rollout issue for scheduling [the flag removal](#release-the-feature). - [ ] (Optional) You can [create a separate issue](https://gitlab.com/gitlab-org/gitlab/-/issues/new?issuable_template=Feature%20Flag%20Cleanup) for scheduling the steps below to [Release the feature](#release-the-feature). @@ -152,10 +152,10 @@ You can either [create a follow-up issue for Feature Flag Cleanup](https://gitla - [ ] Remove all references to the feature flag from the codebase. - [ ] Remove the YAML definitions for the feature from the repository. - [ ] Create [a changelog entry](https://docs.gitlab.com/ee/development/feature_flags/#changelog). -- [ ] Ensure that the cleanup MR has been deployed to both production and canary. - If the merge request was deployed before [the code cutoff](https://about.gitlab.com/handbook/engineering/releases/#self-managed-releases-1), +- [ ] Ensure that the cleanup MR has been included in the release package. + If the merge request was deployed before [the monthly release was tagged](https://about.gitlab.com/handbook/engineering/releases/#self-managed-releases-1), the feature can be officially announced in a release blog post. - - [ ] `/chatops run auto_deploy status ` + - [ ] `/chatops run release check ` - [ ] Close [the feature issue](ISSUE LINK) to indicate the feature will be released in the current milestone. - [ ] Clean up the feature flag from all environments by running these chatops command in `#production` channel: - [ ] `/chatops run feature delete --dev` diff --git a/app/assets/javascripts/diffs/components/commit_item.vue b/app/assets/javascripts/diffs/components/commit_item.vue index 1ccbe0d0d41..42f4ea8eb58 100644 --- a/app/assets/javascripts/diffs/components/commit_item.vue +++ b/app/assets/javascripts/diffs/components/commit_item.vue @@ -103,7 +103,7 @@ export default { >
{ - const $broadcastMessageColor = $('.js-broadcast-message-color'); + const $broadcastMessageTheme = $('.js-broadcast-message-theme'); const $broadcastMessageType = $('.js-broadcast-message-type'); - const $broadcastBannerMessagePreview = $('.js-broadcast-banner-message-preview'); + const $broadcastBannerMessagePreview = $('.js-broadcast-banner-message-preview [role="alert"]'); const $broadcastMessage = $('.js-broadcast-message-message'); - const $jsBroadcastMessagePreview = $('.js-broadcast-message-preview'); + const $jsBroadcastMessagePreview = $('#broadcast-message-preview'); const reloadPreview = function reloadPreview() { const previewPath = $broadcastMessage.data('previewPath'); const message = $broadcastMessage.val(); const type = $broadcastMessageType.val(); + const theme = $broadcastMessageTheme.val(); - if (message === '') { - $jsBroadcastMessagePreview.text(__('Your message here')); - } else { - axios - .post(previewPath, { - broadcast_message: { - message, - broadcast_type: type, - }, - }) - .then(({ data }) => { - $jsBroadcastMessagePreview.html(data.message); - }) - .catch(() => - createFlash({ - message: __('An error occurred while rendering preview broadcast message'), - }), - ); - } + axios + .post(previewPath, { + broadcast_message: { + message, + broadcast_type: type, + theme, + }, + }) + .then(({ data }) => { + $jsBroadcastMessagePreview.html(data); + }) + .catch(() => + createFlash({ + message: __('An error occurred while rendering preview broadcast message'), + }), + ); }; - $broadcastMessageColor.on('input', function onMessageColorInput() { - const previewColor = $(this).val(); - $broadcastBannerMessagePreview.css('background-color', previewColor); - }); - - $('input#broadcast_message_font').on('input', function onMessageFontInput() { - const previewColor = $(this).val(); - $broadcastBannerMessagePreview.css('color', previewColor); - }); + $broadcastMessageTheme.on('change', reloadPreview); $broadcastMessageType.on('change', () => { const $broadcastMessageColorFormGroup = $('.js-broadcast-message-background-color-form-group'); @@ -68,37 +57,4 @@ export default () => { reloadPreview(); }, DEFAULT_DEBOUNCE_AND_THROTTLE_MS), ); - - const updateColorPreview = () => { - const selectedBackgroundColor = $broadcastMessageColor.val(); - const contrastTextColor = textColorForBackground(selectedBackgroundColor); - - // save contrastTextColor to hidden input field - $('input.text-font-color').val(contrastTextColor); - - // Updates the preview color with the hex-color input - const selectedColorStyle = { - backgroundColor: selectedBackgroundColor, - color: contrastTextColor, - }; - - $('.label-color-preview').css(selectedColorStyle); - - return $jsBroadcastMessagePreview.css(selectedColorStyle); - }; - - const setSuggestedColor = (e) => { - const color = $(e.currentTarget).data('color'); - $broadcastMessageColor - .val(color) - // Notify the form, that color has changed - .trigger('input'); - // Only banner supports colors - if ($broadcastMessageType === 'banner') { - updateColorPreview(); - } - return e.preventDefault(); - }; - - $(document).on('click', '.suggest-colors a', setSuggestedColor); }; diff --git a/app/assets/javascripts/repository/components/last_commit.vue b/app/assets/javascripts/repository/components/last_commit.vue index 6b5874c1e5b..2810db33e64 100644 --- a/app/assets/javascripts/repository/components/last_commit.vue +++ b/app/assets/javascripts/repository/components/last_commit.vue @@ -171,7 +171,7 @@ export default {
`; - -exports[`Repository last commit component renders the signature HTML as returned by the backend 1`] = ` -
- - -
-
- - Commit title - - - - -
- - - Test - - - authored - - -
- - -
- -
-
- -
- - - - - - 12345678 - - - - -
-
-
-`; diff --git a/spec/frontend/repository/components/last_commit_spec.js b/spec/frontend/repository/components/last_commit_spec.js index bb710c3a96c..cfbf74e34aa 100644 --- a/spec/frontend/repository/components/last_commit_spec.js +++ b/spec/frontend/repository/components/last_commit_spec.js @@ -143,11 +143,30 @@ describe('Repository last commit component', () => { }); it('renders the signature HTML as returned by the backend', async () => { - factory(createCommitData({ signatureHtml: '' })); + factory( + createCommitData({ + signatureHtml: ` + Verified + `, + }), + ); await nextTick(); - expect(vm.element).toMatchSnapshot(); + expect(vm.find('.gpg-status-box').html()).toBe( + ` + Verified +`, + ); }); it('sets correct CSS class if the commit message is empty', async () => { diff --git a/spec/helpers/broadcast_messages_helper_spec.rb b/spec/helpers/broadcast_messages_helper_spec.rb index e721a3fdc95..d4021a2eb59 100644 --- a/spec/helpers/broadcast_messages_helper_spec.rb +++ b/spec/helpers/broadcast_messages_helper_spec.rb @@ -115,37 +115,8 @@ RSpec.describe BroadcastMessagesHelper do end it 'includes the current message' do - allow(helper).to receive(:broadcast_message_style).and_return(nil) - expect(helper.broadcast_message(current_broadcast_message)).to include 'Current Message' end - - it 'includes custom style' do - allow(helper).to receive(:broadcast_message_style).and_return('foo') - - expect(helper.broadcast_message(current_broadcast_message)).to include 'style="foo"' - end - end - - describe 'broadcast_message_style' do - it 'defaults to no style' do - broadcast_message = spy - - expect(helper.broadcast_message_style(broadcast_message)).to eq '' - end - - it 'allows custom style for banner messages' do - broadcast_message = BroadcastMessage.new(color: '#f2dede', font: '#b94a48', broadcast_type: "banner") - - expect(helper.broadcast_message_style(broadcast_message)) - .to match('background-color: #f2dede; color: #b94a48') - end - - it 'does not add style for notification messages' do - broadcast_message = BroadcastMessage.new(color: '#f2dede', broadcast_type: "notification") - - expect(helper.broadcast_message_style(broadcast_message)).to eq '' - end end describe 'broadcast_message_status' do diff --git a/spec/initializers/omniauth_spec.rb b/spec/initializers/omniauth_spec.rb new file mode 100644 index 00000000000..928eac8c533 --- /dev/null +++ b/spec/initializers/omniauth_spec.rb @@ -0,0 +1,46 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'OmniAuth initializer for GitLab' do + let(:load_omniauth_initializer) do + load Rails.root.join('config/initializers/omniauth.rb') + end + + describe '#full_host' do + subject { OmniAuth.config.full_host } + + let(:base_url) { 'http://localhost/test' } + + before do + allow(Settings).to receive(:gitlab).and_return({ 'base_url' => base_url }) + allow(Gitlab::OmniauthInitializer).to receive(:full_host).and_return('proc') + end + + context 'with feature flags not available' do + before do + expect(Feature).to receive(:feature_flags_available?).and_return(false) + load_omniauth_initializer + end + + it { is_expected.to eq(base_url) } + end + + context 'with the omniauth_initializer_fullhost_proc FF disabled' do + before do + stub_feature_flags(omniauth_initializer_fullhost_proc: false) + load_omniauth_initializer + end + + it { is_expected.to eq(base_url) } + end + + context 'with the omniauth_initializer_fullhost_proc FF disabled' do + before do + load_omniauth_initializer + end + + it { is_expected.to eq('proc') } + end + end +end diff --git a/spec/lib/gitlab/omniauth_initializer_spec.rb b/spec/lib/gitlab/omniauth_initializer_spec.rb index 8b959cf787f..c91b14a33ba 100644 --- a/spec/lib/gitlab/omniauth_initializer_spec.rb +++ b/spec/lib/gitlab/omniauth_initializer_spec.rb @@ -309,4 +309,16 @@ RSpec.describe Gitlab::OmniauthInitializer do subject.execute([conf]) end end + + describe '.full_host' do + subject { described_class.full_host.call({}) } + + let(:base_url) { 'http://localhost/test' } + + before do + allow(Settings).to receive(:gitlab).and_return({ 'base_url' => base_url }) + end + + it { is_expected.to eq(base_url) } + end end diff --git a/spec/serializers/commit_entity_spec.rb b/spec/serializers/commit_entity_spec.rb index 6b4346faf5b..ba2d7e17d1a 100644 --- a/spec/serializers/commit_entity_spec.rb +++ b/spec/serializers/commit_entity_spec.rb @@ -3,8 +3,6 @@ require 'spec_helper' RSpec.describe CommitEntity do - let(:signature_html) { 'TEST' } - let(:entity) do described_class.new(commit, request: request) end @@ -16,11 +14,7 @@ RSpec.describe CommitEntity do subject { entity.as_json } before do - render = double('render') - allow(render).to receive(:call).and_return(signature_html) - allow(request).to receive(:project).and_return(project) - allow(request).to receive(:render).and_return(render) end context 'when commit author is a user' do @@ -83,8 +77,7 @@ RSpec.describe CommitEntity do let(:commit) { project.commit(TestEnv::BRANCH_SHA['signed-commits']) } it 'exposes "signature_html"' do - expect(request.render).to receive(:call) - expect(subject.fetch(:signature_html)).to be signature_html + expect(subject.fetch(:signature_html)).not_to be_nil end end diff --git a/spec/tasks/dev_rake_spec.rb b/spec/tasks/dev_rake_spec.rb index af7bd4bdf0b..73b1604aa10 100644 --- a/spec/tasks/dev_rake_spec.rb +++ b/spec/tasks/dev_rake_spec.rb @@ -12,6 +12,15 @@ RSpec.describe 'dev rake tasks' do end describe 'setup' do + around do |example| + old_force_value = ENV['force'] + + # setup rake task sets the force env var, so reset it + example.run + + ENV['force'] = old_force_value # rubocop:disable RSpec/EnvAssignment + end + subject(:setup_task) { run_rake_task('dev:setup') } let(:connections) { Gitlab::Database.database_base_models.values.map(&:connection) }