Skip to content
Snippets Groups Projects
Commit 83a0db0c authored by Rémy Coutable's avatar Rémy Coutable
Browse files

Merge branch 'bvl-user-status-message-35463' into 'master'

Allow users to set a status

Closes #35463

See merge request gitlab-org/gitlab-ce!20614
parents ea6fc714 12095251
No related branches found
No related tags found
1 merge request!10495Merge Requests - Assignee
Showing
with 297 additions and 1 deletion
# frozen_string_literal: true
module Banzai
module Pipeline
class EmojiPipeline < BasePipeline
# These filters will only perform sanitization of the content, preventing
# XSS, and replace emoji.
def self.filters
@filters ||= FilterArray[
Filter::HtmlEntityFilter,
Filter::SanitizationFilter,
Filter::EmojiFilter
]
end
end
end
end
Loading
Loading
@@ -4081,6 +4081,9 @@ msgstr ""
msgid "Profiles|This doesn't look like a public SSH key, are you sure you want to add it?"
msgstr ""
 
msgid "Profiles|This emoji and message will appear on your profile and throughout the interface. The message can contain emoji codes, too."
msgstr ""
msgid "Profiles|Type your %{confirmationValue} to confirm:"
msgstr ""
 
Loading
Loading
@@ -5624,6 +5627,9 @@ msgstr ""
msgid "Users"
msgstr ""
 
msgid "User|Current Status"
msgstr ""
msgid "Variables"
msgstr ""
 
Loading
Loading
Loading
Loading
@@ -78,6 +78,15 @@ describe ProfilesController, :request_store do
expect(ldap_user.name).not_to eq('John')
expect(ldap_user.location).to eq('City, Country')
end
it 'allows setting a user status' do
sign_in(user)
put :update, user: { status: { message: 'Working hard!' } }
expect(user.reload.status.message).to eq('Working hard!')
expect(response).to have_gitlab_http_status(302)
end
end
 
describe 'PUT update_username' do
Loading
Loading
Loading
Loading
@@ -993,6 +993,29 @@ describe Projects::IssuesController do
expect(json_response.first.keys).to match_array(%w[id reply_id expanded notes diff_discussion discussion_path individual_note resolvable resolved resolved_at resolved_by resolved_by_push commit_id for_commit project_id])
end
 
it 'renders the author status html if there is a status' do
create(:user_status, user: discussion.author)
get :discussions, namespace_id: project.namespace, project_id: project, id: issue.iid
note_json = json_response.first['notes'].first
expect(note_json['author']['status_tooltip_html']).to be_present
end
it 'does not cause an extra query for the status' do
control = ActiveRecord::QueryRecorder.new do
get :discussions, namespace_id: project.namespace, project_id: project, id: issue.iid
end
create(:user_status, user: discussion.author)
second_discussion = create(:discussion_note_on_issue, noteable: issue, project: issue.project, author: create(:user))
create(:user_status, user: second_discussion.author)
expect { get :discussions, namespace_id: project.namespace, project_id: project, id: issue.iid }
.not_to exceed_query_limit(control)
end
context 'with cross-reference system note', :request_store do
let(:new_issue) { create(:issue) }
let(:cross_reference) { "mentioned in #{new_issue.to_reference(issue.project)}" }
Loading
Loading
# frozen_string_literal: true
FactoryBot.define do
factory :user_status do
user
emoji 'coffee'
message 'I crave coffee'
end
end
Loading
Loading
@@ -9,7 +9,7 @@ describe 'Groups > Members > List members' do
let(:nested_group) { create(:group, parent: group) }
 
before do
gitlab_sign_in(user1)
sign_in(user1)
end
 
it 'show members from current group and parent', :nested_groups do
Loading
Loading
@@ -32,6 +32,18 @@ describe 'Groups > Members > List members' do
expect(second_row).to be_blank
end
 
describe 'showing status of members' do
before do
group.add_developer(user2)
end
subject { visit group_group_members_path(group) }
it_behaves_like 'showing user status' do
let(:user_with_status) { user2 }
end
end
def first_row
page.all('ul.content-list > li')[0]
end
Loading
Loading
Loading
Loading
@@ -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
# frozen_string_literal: true
require 'spec_helper'
describe 'Project > Commit > View user status' do
include RepoHelpers
set(:project) { create(:project, :repository) }
set(:user) { create(:user) }
let(:commit_author) { create(:user, email: sample_commit.author_email) }
before do
sign_in(user)
project.add_developer(user)
end
subject { visit(project_commit_path(project, sample_commit.id)) }
describe 'status for the commit author' do
it_behaves_like 'showing user status' do
let(:user_with_status) { commit_author }
end
end
describe 'status for a comment on the commit' do
let(:note) { create(:note, :on_commit, project: project) }
it_behaves_like 'showing user status' do
let(:user_with_status) { note.author }
end
end
describe 'status for a diff note on the commit' do
let(:note) { create(:diff_note_on_commit, project: project) }
it_behaves_like 'showing user status' do
let(:user_with_status) { note.author }
end
end
end
Loading
Loading
@@ -29,4 +29,22 @@ describe "User views issue" do
expect(page).not_to have_link('Close issue')
end
end
describe 'user status' do
subject { visit(project_issue_path(project, issue)) }
describe 'showing status of the author of the issue' do
it_behaves_like 'showing user status' do
let(:user_with_status) { issue.author }
end
end
describe 'showing status of a user who commented on an issue', :js do
let!(:note) { create(:note, noteable: issue, project: project, author: user_with_status) }
it_behaves_like 'showing user status' do
let(:user_with_status) { create(:user) }
end
end
end
end
Loading
Loading
@@ -87,4 +87,12 @@ describe 'Projects members' do
end
end
end
describe 'showing status of members' do
it_behaves_like 'showing user status' do
let(:user_with_status) { developer }
subject { visit project_settings_members_path(project) }
end
end
end
# frozen_string_literal: true
require 'spec_helper'
describe 'Project > Merge request > View user status' do
let(:project) { create(:project, :public, :repository) }
let(:merge_request) do
create(:merge_request, source_project: project, target_project: project, author: create(:user))
end
subject { visit merge_request_path(merge_request) }
describe 'the status of the merge request author' do
it_behaves_like 'showing user status' do
let(:user_with_status) { merge_request.author }
end
end
context 'for notes', :js do
describe 'the status of the author of a note on a merge request' do
let(:note) { create(:note, noteable: merge_request, project: project, author: create(:user)) }
it_behaves_like 'showing user status' do
let(:user_with_status) { note.author }
end
end
describe 'the status of the author of a diff note on a merge request' do
let(:note) { create(:diff_note_on_merge_request, noteable: merge_request, project: project, author: create(:user)) }
it_behaves_like 'showing user status' do
let(:user_with_status) { note.author }
end
end
end
end
Loading
Loading
@@ -63,6 +63,12 @@ describe 'Pipeline', :js do
expect(page).to have_css('#js-tab-pipeline.active')
end
 
it_behaves_like 'showing user status' do
let(:user_with_status) { pipeline.user }
subject { visit project_pipeline_path(project, pipeline) }
end
describe 'pipeline graph' do
context 'when pipeline has running builds' do
it 'shows a running icon and a cancel action for the running build' do
Loading
Loading
Loading
Loading
@@ -141,4 +141,16 @@ describe 'Projects > Snippets > Project snippet', :js do
end
end
end
it_behaves_like 'showing user status' do
let(:file_name) { 'ruby-style-guide.md' }
let(:content) { project.repository.blob_at('master', 'files/markdown/ruby-style-guide.md').data }
let(:user_with_status) { snippet.author }
subject do
visit project_snippet_path(project, snippet)
wait_for_requests
end
end
end
Loading
Loading
@@ -16,6 +16,8 @@ describe 'Comments on personal snippets', :js do
before do
sign_in user
visit snippet_path(snippet)
wait_for_requests
end
 
subject { page }
Loading
Loading
@@ -42,6 +44,15 @@ describe 'Comments on personal snippets', :js do
expect(page).to have_selector('.note-emoji-button')
end
end
it 'shows the status of a note author' do
status = create(:user_status, user: user)
visit snippet_path(snippet)
within("#note_#{snippet_notes[0].id}") do
expect(page).to show_user_status(status)
end
end
end
 
context 'when submitting a note' do
Loading
Loading
Loading
Loading
@@ -155,4 +155,12 @@ describe 'Snippet', :js do
end
end
end
it_behaves_like 'showing user status' do
let(:file_name) { 'popen.rb' }
let(:content) { project.repository.blob_at('master', 'files/ruby/popen.rb').data }
let(:user_with_status) { snippet.author }
subject { visit snippet_path(snippet) }
end
end
Loading
Loading
@@ -53,6 +53,14 @@ describe 'User page' do
end
end
 
it 'shows the status if there was one' do
create(:user_status, user: user, message: "Working hard!")
visit(user_path(user))
expect(page).to have_content("Working hard!")
end
context 'signup disabled' do
it 'shows the sign in link' do
stub_application_setting(signup_enabled: false)
Loading
Loading
# frozen_string_literal: true
require 'spec_helper'
describe Banzai::Pipeline::EmojiPipeline do
def parse(text)
described_class.to_html(text, {})
end
it 'replaces emoji' do
expected_result = "Hello world #{Gitlab::Emoji.gl_emoji_tag('100')}"
expect(parse('Hello world :100:')).to eq(expected_result)
end
it 'filters out HTML tags' do
expected_result = "Hello &lt;b&gt;world&lt;/b&gt; #{Gitlab::Emoji.gl_emoji_tag('100')}"
expect(parse('Hello <b>world</b> :100:')).to eq(expected_result)
end
end
Loading
Loading
@@ -20,6 +20,7 @@ describe User do
 
describe 'associations' do
it { is_expected.to have_one(:namespace) }
it { is_expected.to have_one(:status) }
it { is_expected.to have_many(:snippets).dependent(:destroy) }
it { is_expected.to have_many(:members) }
it { is_expected.to have_many(:project_members) }
Loading
Loading
# frozen_string_literal: true
require 'spec_helper'
describe UserStatus do
it { is_expected.to validate_presence_of(:user) }
it { is_expected.to allow_value('smirk').for(:emoji) }
it { is_expected.not_to allow_value('hello world').for(:emoji) }
it { is_expected.not_to allow_value('').for(:emoji) }
it { is_expected.to validate_length_of(:message).is_at_most(100) }
it { is_expected.to allow_value('').for(:message) }
it 'is expected to be deleted when the user is deleted' do
status = create(:user_status)
expect { status.user.destroy }.to change { described_class.count }.from(1).to(0)
end
end
Loading
Loading
@@ -35,6 +35,10 @@ describe UserPolicy do
end
end
 
describe "updating a user's status" do
it_behaves_like 'changing a user', :update_user_status
end
describe "destroying a user" do
it_behaves_like 'changing a user', :destroy_user
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment