FEATURE: user status emoji (#17025)

This commit is contained in:
Andrei Prigorshnev
2022-06-22 18:15:33 +04:00
committed by GitHub
parent 0b8e6adabe
commit 033f72c65f
17 changed files with 351 additions and 91 deletions

View File

@ -25,32 +25,46 @@ describe UserStatusController do
SiteSetting.enable_user_status = true
end
it "sets user status" do
status = "off to dentist"
put "/user-status.json", params: { description: status }
expect(user.user_status.description).to eq(status)
it 'the description parameter is mandatory' do
put "/user-status.json", params: { emoji: "tooth" }
expect(response.status).to eq(400)
end
it 'the description parameter is mandatory' do
put "/user-status.json", params: {}
it 'the emoji parameter is mandatory' do
put "/user-status.json", params: { description: "off to dentist" }
expect(response.status).to eq(400)
end
it "sets user status" do
status = "off to dentist"
status_emoji = "tooth"
put "/user-status.json", params: { description: status, emoji: status_emoji }
expect(user.user_status.description).to eq(status)
expect(user.user_status.emoji).to eq(status_emoji)
end
it "following calls update status" do
status = "off to dentist"
put "/user-status.json", params: { description: status }
status_emoji = "tooth"
put "/user-status.json", params: { description: status, emoji: status_emoji }
user.reload
expect(user.user_status.description).to eq(status)
expect(user.user_status.emoji).to eq(status_emoji)
new_status = "working"
put "/user-status.json", params: { description: new_status }
new_status = "surfing"
new_status_emoji = "surfing_man"
put "/user-status.json", params: { description: new_status, emoji: new_status_emoji }
user.reload
expect(user.user_status.description).to eq(new_status)
expect(user.user_status.emoji).to eq(new_status_emoji)
end
it "publishes to message bus" do
status = "off to dentist"
messages = MessageBus.track_publish { put "/user-status.json", params: { description: status } }
emoji = "tooth"
messages = MessageBus.track_publish do
put "/user-status.json", params: { description: status, emoji: emoji }
end
expect(messages.size).to eq(1)
expect(messages[0].channel).to eq("/user-status/#{user.id}")