Skip to content

Commit

Permalink
Test some FlagSetting behaviors
Browse files Browse the repository at this point in the history
  • Loading branch information
Undo1 committed May 16, 2017
1 parent 4a0dd07 commit aee94c6
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/fixtures/flag_settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,11 @@ enabled:
registration:
name: registration_enabled
value: 1

max_flags:
name: max_flags
value: 3

dry_run:
name: dry_run
value: 0
23 changes: 23 additions & 0 deletions test/integration/flagging_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,27 @@ def setup_user_with_permissive_flag_settings(user)
@limited_post.autoflag
assert_requested @flag_submit_stub, times: 1
end

test "should respect max flags setting" do
10.times do
user = @user.dup
user.email = SecureRandom.hex
user.save!(validate: false)

setup_user_with_permissive_flag_settings(user)
end

FlagSetting.find_by_name("max_flags").update(value: "2")

@post.autoflag
assert_requested @flag_submit_stub, times: 2
end

test "should respect dry run setting" do
FlagSetting.find_by_name("dry_run").update(value: "1")

@post.autoflag
assert_requested @flag_options_stub, at_least_times: 1
assert_not_requested @flag_submit_stub
end
end

0 comments on commit aee94c6

Please sign in to comment.