FIX: Error when moving the group default notification state (#28910)
This commit is contained in:
parent
e7e9c99568
commit
0c019b2e45
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
<TagChooser
|
<TagChooser
|
||||||
@tags={{this.model.watching_tags}}
|
@tags={{this.model.watching_tags}}
|
||||||
@blacklist={{this.selectedTags}}
|
@blockedTags={{this.selectedTags}}
|
||||||
@everyTag={{true}}
|
@everyTag={{true}}
|
||||||
@unlimitedTagCount={{true}}
|
@unlimitedTagCount={{true}}
|
||||||
@options={{hash allowAny=false}}
|
@options={{hash allowAny=false}}
|
||||||
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
<TagChooser
|
<TagChooser
|
||||||
@tags={{this.model.tracking_tags}}
|
@tags={{this.model.tracking_tags}}
|
||||||
@blacklist={{this.selectedTags}}
|
@blockedTags={{this.selectedTags}}
|
||||||
@everyTag={{true}}
|
@everyTag={{true}}
|
||||||
@unlimitedTagCount={{true}}
|
@unlimitedTagCount={{true}}
|
||||||
@options={{hash allowAny=false}}
|
@options={{hash allowAny=false}}
|
||||||
|
@ -53,7 +53,7 @@
|
||||||
|
|
||||||
<TagChooser
|
<TagChooser
|
||||||
@tags={{this.model.watching_first_post_tags}}
|
@tags={{this.model.watching_first_post_tags}}
|
||||||
@blacklist={{this.selectedTags}}
|
@blockedTags={{this.selectedTags}}
|
||||||
@everyTag={{true}}
|
@everyTag={{true}}
|
||||||
@unlimitedTagCount={{true}}
|
@unlimitedTagCount={{true}}
|
||||||
@options={{hash allowAny=false}}
|
@options={{hash allowAny=false}}
|
||||||
|
@ -70,7 +70,7 @@
|
||||||
|
|
||||||
<TagChooser
|
<TagChooser
|
||||||
@tags={{this.model.regular_tags}}
|
@tags={{this.model.regular_tags}}
|
||||||
@blacklist={{this.selectedTags}}
|
@blockedTags={{this.selectedTags}}
|
||||||
@everyTag={{true}}
|
@everyTag={{true}}
|
||||||
@unlimitedTagCount={{true}}
|
@unlimitedTagCount={{true}}
|
||||||
@options={{hash allowAny=false}}
|
@options={{hash allowAny=false}}
|
||||||
|
@ -87,7 +87,7 @@
|
||||||
|
|
||||||
<TagChooser
|
<TagChooser
|
||||||
@tags={{this.model.muted_tags}}
|
@tags={{this.model.muted_tags}}
|
||||||
@blacklist={{this.selectedTags}}
|
@blockedTags={{this.selectedTags}}
|
||||||
@everyTag={{true}}
|
@everyTag={{true}}
|
||||||
@unlimitedTagCount={{true}}
|
@unlimitedTagCount={{true}}
|
||||||
@options={{hash allowAny=false}}
|
@options={{hash allowAny=false}}
|
||||||
|
|
|
@ -34,9 +34,14 @@ class GroupTagNotificationDefault < ActiveRecord::Base
|
||||||
changed = true
|
changed = true
|
||||||
end
|
end
|
||||||
|
|
||||||
(tag_ids - old_ids).each do |id|
|
new_records_attrs =
|
||||||
self.create!(group: group, tag_id: id, notification_level: notification_levels[level])
|
(tag_ids - old_ids).map do |tag_id|
|
||||||
changed = true
|
{ group_id: group.id, tag_id: tag_id, notification_level: notification_levels[level] }
|
||||||
|
end
|
||||||
|
|
||||||
|
unless new_records_attrs.empty?
|
||||||
|
result = GroupTagNotificationDefault.insert_all(new_records_attrs)
|
||||||
|
changed = true if result.rows.length > 0
|
||||||
end
|
end
|
||||||
|
|
||||||
changed
|
changed
|
||||||
|
|
|
@ -1380,6 +1380,24 @@ RSpec.describe Group do
|
||||||
expect(GroupTagNotificationDefault.lookup(group, :watching)).to be_empty
|
expect(GroupTagNotificationDefault.lookup(group, :watching)).to be_empty
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "can change the notification level for a tag" do
|
||||||
|
GroupTagNotificationDefault.create!(
|
||||||
|
group: group,
|
||||||
|
tag: tag1,
|
||||||
|
notification_level: GroupTagNotificationDefault.notification_levels[:watching],
|
||||||
|
)
|
||||||
|
|
||||||
|
group.watching_tags = [tag1.name]
|
||||||
|
group.save!
|
||||||
|
expect(GroupTagNotificationDefault.lookup(group, :watching).pluck(:tag_id)).to eq([tag1.id])
|
||||||
|
|
||||||
|
group.watching_tags = []
|
||||||
|
group.tracking_tags = [tag1.name]
|
||||||
|
group.save!
|
||||||
|
expect(GroupTagNotificationDefault.lookup(group, :watching)).to be_empty
|
||||||
|
expect(GroupTagNotificationDefault.lookup(group, :tracking).pluck(:tag_id)).to eq([tag1.id])
|
||||||
|
end
|
||||||
|
|
||||||
it "can apply default notifications for admins group" do
|
it "can apply default notifications for admins group" do
|
||||||
group = Group.find(Group::AUTO_GROUPS[:admins])
|
group = Group.find(Group::AUTO_GROUPS[:admins])
|
||||||
group.tracking_category_ids = [category1.id]
|
group.tracking_category_ids = [category1.id]
|
||||||
|
|
Loading…
Reference in New Issue