Users: add Contributor and Approver user levels
This commit is contained in:
@@ -22,37 +22,7 @@ class Admin::UsersControllerTest < ActionDispatch::IntegrationTest
|
||||
|
||||
assert_redirected_to(edit_admin_user_path(@user))
|
||||
assert_equal(30, @user.reload.level)
|
||||
assert_match(/promoted "#{@user.name}":\/users\/#{@user.id} from Member to Gold/, ModAction.last.description)
|
||||
assert_equal(@user, ModAction.last.subject)
|
||||
assert_equal(@mod, ModAction.last.creator)
|
||||
end
|
||||
|
||||
should "promote the user to unrestricted uploads" do
|
||||
put_auth admin_user_path(@user), @mod, params: { user: { level: User::Levels::BUILDER, can_upload_free: true }}
|
||||
|
||||
assert_redirected_to(edit_admin_user_path(@user.reload))
|
||||
assert_equal(true, @user.is_builder?)
|
||||
assert_equal(true, @user.can_upload_free?)
|
||||
assert_equal(false, @user.can_approve_posts?)
|
||||
assert_match(/granted unlimited upload privileges to "#{@user.name}":\/users\/#{@user.id}/, ModAction.first.description)
|
||||
assert_match(/promoted "#{@user.name}":\/users\/#{@user.id} from Member to Builder/, ModAction.last.description)
|
||||
assert_equal(@user, ModAction.first.subject)
|
||||
assert_equal(@mod, ModAction.first.creator)
|
||||
assert_equal(@user, ModAction.last.subject)
|
||||
assert_equal(@mod, ModAction.last.creator)
|
||||
end
|
||||
|
||||
should "promote the user to approver" do
|
||||
put_auth admin_user_path(@user), @mod, params: { user: { level: User::Levels::BUILDER, can_approve_posts: true }}
|
||||
|
||||
assert_redirected_to(edit_admin_user_path(@user.reload))
|
||||
assert_equal(true, @user.is_builder?)
|
||||
assert_equal(false, @user.can_upload_free?)
|
||||
assert_equal(true, @user.can_approve_posts?)
|
||||
assert_match(/granted approval privileges to "#{@user.name}":\/users\/#{@user.id}/, ModAction.first.description)
|
||||
assert_match(/promoted "#{@user.name}":\/users\/#{@user.id} from Member to Builder/, ModAction.last.description)
|
||||
assert_equal(@user, ModAction.first.subject)
|
||||
assert_equal(@mod, ModAction.first.creator)
|
||||
assert_match(%r{promoted "#{@user.name}":/users/#{@user.id} from Member to Gold}, ModAction.last.description)
|
||||
assert_equal(@user, ModAction.last.subject)
|
||||
assert_equal(@mod, ModAction.last.creator)
|
||||
end
|
||||
|
||||
@@ -522,8 +522,8 @@ class PostsControllerTest < ActionDispatch::IntegrationTest
|
||||
|
||||
context "with everything" do
|
||||
setup do
|
||||
@admin = create(:admin_user, can_approve_posts: true)
|
||||
@builder = create(:builder_user, can_approve_posts: true)
|
||||
@admin = create(:admin_user)
|
||||
@approver = create(:approver_user)
|
||||
|
||||
as(@user) do
|
||||
@post.update!(tag_string: "1girl solo highres blah 2001")
|
||||
@@ -545,7 +545,7 @@ class PostsControllerTest < ActionDispatch::IntegrationTest
|
||||
#create(:post_appeal, post: @post, creator: @user)
|
||||
create(:post_vote, post: @post, user: @user)
|
||||
create(:favorite, post: @post, user: @user)
|
||||
create(:moderation_report, model: @comment, creator: @builder)
|
||||
create(:moderation_report, model: @comment, creator: @approver)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -560,7 +560,7 @@ class PostsControllerTest < ActionDispatch::IntegrationTest
|
||||
end
|
||||
|
||||
should "render for a builder" do
|
||||
get_auth post_path(@post), @builder
|
||||
get_auth post_path(@post), @approver
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
@@ -570,7 +570,7 @@ class PostsControllerTest < ActionDispatch::IntegrationTest
|
||||
end
|
||||
|
||||
should "render for a builder with a search query" do
|
||||
get_auth post_path(@post, q: "tagme"), @builder
|
||||
get_auth post_path(@post, q: "tagme"), @approver
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
|
||||
context "index action" do
|
||||
setup do
|
||||
@mod_user = create(:moderator_user, name: "yukari")
|
||||
@other_user = create(:builder_user, can_upload_free: true, inviter: @mod_user, created_at: 2.weeks.ago)
|
||||
@other_user = create(:contributor_user, inviter: @mod_user, created_at: 2.weeks.ago)
|
||||
@uploader = create(:user, created_at: 2.weeks.ago)
|
||||
end
|
||||
|
||||
@@ -41,7 +41,6 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
|
||||
|
||||
should respond_to_search({}).with { [@uploader, @other_user, @mod_user, @user, User.system] }
|
||||
should respond_to_search(min_level: User::Levels::BUILDER).with { [@other_user, @mod_user, User.system] }
|
||||
should respond_to_search(can_upload_free: "true").with { @other_user }
|
||||
should respond_to_search(name_matches: "yukari").with { @mod_user }
|
||||
|
||||
context "using includes" do
|
||||
@@ -114,7 +113,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
|
||||
context "show action" do
|
||||
setup do
|
||||
# flesh out profile to get more test coverage of user presenter.
|
||||
@user = create(:user, can_approve_posts: true, created_at: 2.weeks.ago)
|
||||
@user = create(:approver, created_at: 2.weeks.ago)
|
||||
as(@user) do
|
||||
create(:saved_search, user: @user)
|
||||
create(:post, uploader: @user, tag_string: "fav:#{@user.name}")
|
||||
|
||||
Reference in New Issue
Block a user