mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 05:33:40 +08:00
4ea21fa2d0
This change both speeds up specs (less strings to allocate) and helps catch cases where methods in Discourse are mutating inputs. Overall we will be migrating everything to use #frozen_string_literal: true it will take a while, but this is the first and safest move in this direction
36 lines
903 B
Ruby
36 lines
903 B
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
describe GroupUser do
|
|
|
|
it 'correctly sets notification level' do
|
|
moderator = Fabricate(:moderator)
|
|
|
|
Group.refresh_automatic_groups!(:moderators)
|
|
gu = GroupUser.find_by(user_id: moderator.id, group_id: Group::AUTO_GROUPS[:moderators])
|
|
|
|
expect(gu.notification_level).to eq(NotificationLevels.all[:tracking])
|
|
|
|
group = Group.create!(name: 'bob')
|
|
group.add(moderator)
|
|
group.save
|
|
|
|
gu = GroupUser.find_by(user_id: moderator.id, group_id: group.id)
|
|
expect(gu.notification_level).to eq(NotificationLevels.all[:watching])
|
|
|
|
group.remove(moderator)
|
|
group.save
|
|
|
|
group.default_notification_level = 1
|
|
group.save
|
|
|
|
group.add(moderator)
|
|
group.save
|
|
|
|
gu = GroupUser.find_by(user_id: moderator.id, group_id: group.id)
|
|
expect(gu.notification_level).to eq(NotificationLevels.all[:regular])
|
|
end
|
|
|
|
end
|