-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
102 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...grate/20240423054323_create_post_flags.rb → db/migrate/20240423054323_create_flags.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
class CreatePostFlags < ActiveRecord::Migration[7.0] | ||
class CreateFlags < ActiveRecord::Migration[7.0] | ||
def change | ||
create_table :post_flags do |t| | ||
create_table :flags do |t| | ||
t.string :name, unique: true | ||
t.integer :position, null: false | ||
t.boolean :system, null: false | ||
t.boolean :enabled, default: true, null: false | ||
t.boolean :topic_type, default: false, null: false | ||
t.boolean :notify_type, default: false, null: false | ||
t.boolean :auto_action_type, default: false, null: false | ||
t.boolean :custom_type, default: false, null: false | ||
t.timestamps | ||
end | ||
DB.exec("SELECT setval('flags_id_seq', 1001, FALSE);") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
lib/guardian/post_flag_guardian.rb → lib/guardian/flag_guardian.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,3 @@ | ||
# frozen_string_literal: true | ||
|
||
Fabricator(:flag, from: :post_action) do | ||
user | ||
post | ||
post_action_type_id PostActionType.types[:spam] | ||
end | ||
Fabricator(:flag) { name "offtopic" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
Fabricator(:flag_post_action, from: :post_action) do | ||
user | ||
post | ||
post_action_type_id PostActionType.types[:spam] | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
spec/lib/guardian/post_flag_guardian_spec.rb → spec/lib/guardian/flag_guardian_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe Flag, type: :model do | ||
it "has id lower than 1000 for system flags" do | ||
flag = Fabricate(:flag, id: 1) | ||
expect(flag.system?).to be true | ||
end | ||
|
||
it "has id greater than 1000 for non-system flags" do | ||
flag = Fabricate(:flag) | ||
expect(flag.system?).to be false | ||
expect(flag.id).to be > 1000 | ||
end | ||
|
||
before { Flag.reset_flag_settings! } | ||
|
||
it "updates post action types when created, modified or destroyed" do | ||
expect(PostActionType.flag_types.keys).to eq( | ||
%i[notify_user notify_moderators off_topic inappropriate spam illegal], | ||
) | ||
|
||
flag = Fabricate(:flag, name: "custom") | ||
expect(PostActionType.flag_types.keys).to eq( | ||
%i[notify_user notify_moderators off_topic inappropriate spam illegal custom], | ||
) | ||
|
||
flag.update!(name: "edited_custom") | ||
expect(PostActionType.flag_types.keys).to eq( | ||
%i[notify_user notify_moderators off_topic inappropriate spam illegal edited_custom], | ||
) | ||
|
||
flag.destroy! | ||
expect(PostActionType.flag_types.keys).to eq( | ||
%i[notify_user notify_moderators off_topic inappropriate spam illegal], | ||
) | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.