emails: add /emails index page.

Add emails index page at https://danbooru.donmai.us/emails. Mods can use
this page to view and search emails belonging to users below mod level.
This commit is contained in:
evazion
2020-12-13 21:02:12 -06:00
parent 67eefadd7f
commit 2e633f84f6
7 changed files with 90 additions and 1 deletions

View File

@@ -10,6 +10,26 @@ class EmailsControllerTest < ActionDispatch::IntegrationTest
@restricted_user = create(:user, requires_verification: true, is_verified: false)
end
context "#index" do
should "not let regular users see emails belonging to other users" do
get_auth emails_path, @user
assert_response 403
end
should "let mods see emails belonging to themselves and all users below mod level" do
@mod1 = create(:moderator_user, email_address: build(:email_address))
@mod2 = create(:moderator_user, email_address: build(:email_address))
get_auth emails_path, @mod1
assert_response :success
assert_select "#email-address-#{@user.email_address.id}", count: 1
assert_select "#email-address-#{@other_user.email_address.id}", count: 1
assert_select "#email-address-#{@mod1.email_address.id}", count: 1
assert_select "#email-address-#{@mod2.email_address.id}", count: 0
end
end
context "#show" do
should "render" do
get_auth user_email_path(@user), @user, as: :json