discourse/plugins/chat/spec/requests/email_controller_spec.rb
Roman Rizzi 0a5f548635
DEV: Move discourse-chat to the core repo. (#18776)
As part of this move, we are also renaming `discourse-chat` to `chat`.
2022-11-02 10:41:30 -03:00

26 lines
710 B
Ruby

# frozen_string_literal: true
require "rails_helper"
describe EmailController do
describe "unsubscribing from chat email settings" do
fab!(:user) { Fabricate(:user) }
it "updates an user chat summary frequency" do
SiteSetting.chat_enabled = true
never_freq = "never"
key = UnsubscribeKey.create_key_for(user, "chat_summary")
user.user_option.send_chat_email_when_away!
post "/email/unsubscribe/#{key}.json", params: { chat_email_frequency: never_freq }
expect(response.status).to eq(302)
get response.redirect_url
expect(body).to include(user.email)
expect(user.user_option.reload.chat_email_frequency).to eq(never_freq)
end
end
end