diff --git a/app/helpers/profiles_helper.rb b/app/helpers/profiles_helper.rb index e7aa92e6e5c..a6a57db3002 100644 --- a/app/helpers/profiles_helper.rb +++ b/app/helpers/profiles_helper.rb @@ -9,4 +9,8 @@ module ProfilesHelper end end end + + def show_user_status_field? + Feature.enabled?(:user_status_form) || cookies[:feature_user_status_form] == 'true' + end end diff --git a/app/views/profiles/show.html.haml b/app/views/profiles/show.html.haml index 5e70cc09104..73099297a38 100644 --- a/app/views/profiles/show.html.haml +++ b/app/views/profiles/show.html.haml @@ -30,16 +30,18 @@ - if @user.avatar? %hr = link_to _('Remove avatar'), profile_avatar_path, data: { confirm: _('Avatar will be removed. Are you sure?') }, method: :delete, class: 'btn btn-danger btn-inverted' - %hr - .row - .col-lg-4.profile-settings-sidebar - %h4.prepend-top-0= s_("User|Current Status") - %p= _("This emoji and message will appear on your profile and throughout the interface.") - .col-lg-8 - .row - = f.fields_for :status, @user.status do |status_form| - = status_form.text_field :emoji - = status_form.text_field :message, maxlength: 100 + + - if show_user_status_field? + %hr + .row + .col-lg-4.profile-settings-sidebar + %h4.prepend-top-0= s_("User|Current Status") + %p= _("This emoji and message will appear on your profile and throughout the interface.") + .col-lg-8 + .row + = f.fields_for :status, @user.status do |status_form| + = status_form.text_field :emoji + = status_form.text_field :message, maxlength: 100 %hr .row .col-lg-4.profile-settings-sidebar diff --git a/changelogs/unreleased/bvl-user-status-message-35463.yml b/changelogs/unreleased/bvl-user-status-message-35463.yml index 981f0608c29..c844e7ea0e4 100644 --- a/changelogs/unreleased/bvl-user-status-message-35463.yml +++ b/changelogs/unreleased/bvl-user-status-message-35463.yml @@ -1,5 +1,5 @@ --- title: Users can set a status message and emoji merge_request: 20614 -author: +author: niedermyer & davamr type: added diff --git a/spec/features/profiles/user_edit_profile_spec.rb b/spec/features/profiles/user_edit_profile_spec.rb index 0b5eacbe916..96bbe6f93f1 100644 --- a/spec/features/profiles/user_edit_profile_spec.rb +++ b/spec/features/profiles/user_edit_profile_spec.rb @@ -55,4 +55,31 @@ describe 'User edit profile' do expect(page).to have_link('gravatar.com') end end + + context 'user status' do + it 'hides user status when the feature is disabled' do + stub_feature_flags(user_status_form: false) + + visit(profile_path) + + expect(page).not_to have_content('Current Status') + end + + it 'shows the status form when the feature is enabled' do + stub_feature_flags(user_status_form: true) + + visit(profile_path) + + expect(page).to have_content('Current Status') + end + + it 'shows the status form when the feature is enabled by setting a cookie', :js do + stub_feature_flags(user_status_form: false) + set_cookie('feature_user_status_form', 'true') + + visit(profile_path) + + expect(page).to have_content('Current Status') + end + end end