Implement an admin dashboard
Opened this issue · 0 comments
marlabrizel commented
Add a rudimentary admin dashboard to your Movies app. You should be able to flag a member as an admin, and should be forbidden from accessing the /admins/dashboards
route unless logged in as an admin.
The following test cases should pass:
# test/system/admin_dashboards_system_test.rb
test "admins can access the admin dashboard" do
admin = create(:member, password: "password", password_confirmation: "password", admin: true)
visit movies_path
click_link "Log In"
fill_in :email, with: admin.email
fill_in :password, with: "password"
click_button "Submit"
visit admin_dashboards_path
assert_text "Welcome to the admin portal, #{admin.email}!"
end
test "non-admins cannot access the admin dashboard" do
member = create(:member, password: "password", password_confirmation: "password", admin: false)
visit movies_path
click_link "Log In"
fill_in :email, with: member.email
fill_in :password, with: "password"
click_button "Submit"
visit admin_dashboards_path
refute_text "Welcome to the admin portal, #{member.email}!"
assert_text "Forbidden"
end