-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #589 from ualbertalib/add-cms-admin-tests
Add basic smoke tests to verify cms admin pages are being rendered
- Loading branch information
Showing
5 changed files
with
75 additions
and
8 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
Empty file.
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,53 @@ | ||
# frozen_string_literal: true | ||
|
||
require "test_helper" | ||
|
||
class CmsAdminTest < ActionDispatch::IntegrationTest | ||
test "unauthorized access to admin gets unauthorized response" do | ||
get comfy_admin_cms_path | ||
|
||
assert_response :unauthorized | ||
end | ||
|
||
test "/admin redirects to first site's pages index" do | ||
get comfy_admin_cms_path, headers: admin_authorization_headers | ||
|
||
assert_response :redirect | ||
assert_redirected_to comfy_admin_cms_site_pages_path(site_id: Comfy::Cms::Site.first) | ||
end | ||
|
||
test "admin sites index" do | ||
get comfy_admin_cms_sites_path, headers: admin_authorization_headers | ||
|
||
assert_response :success | ||
assert_select "h2", "Sites" | ||
end | ||
|
||
test "admin site pages index" do | ||
get comfy_admin_cms_site_pages_path(site_id: Comfy::Cms::Site.first), headers: admin_authorization_headers | ||
|
||
assert_response :success | ||
assert_select "h2", "Pages" | ||
end | ||
|
||
test "admin site layouts index" do | ||
get comfy_admin_cms_site_layouts_path(site_id: Comfy::Cms::Site.first), headers: admin_authorization_headers | ||
|
||
assert_response :success | ||
assert_select "h2", "Layouts" | ||
end | ||
|
||
test "admin site snippets index" do | ||
get comfy_admin_cms_site_snippets_path(site_id: Comfy::Cms::Site.first), headers: admin_authorization_headers | ||
|
||
assert_response :success | ||
assert_select "h2", "Snippets" | ||
end | ||
|
||
test "admin site files index" do | ||
get comfy_admin_cms_site_files_path(site_id: Comfy::Cms::Site.first), headers: admin_authorization_headers | ||
|
||
assert_response :success | ||
assert_select "h2", "Files" | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,15 +20,13 @@ class ProfilesTest < ActionDispatch::IntegrationTest | |
end | ||
|
||
test "should get new" do | ||
get new_profile_url, | ||
headers: {Authorization: ActionController::HttpAuthentication::Basic.encode_credentials(Rails.application.secrets.cms_user, Rails.application.secrets.cms_password)} | ||
get new_profile_url, headers: admin_authorization_headers | ||
|
||
assert_response :success | ||
end | ||
|
||
test "should get edit" do | ||
get edit_profile_url(profiles(:one)), | ||
headers: {Authorization: ActionController::HttpAuthentication::Basic.encode_credentials(Rails.application.secrets.cms_user, Rails.application.secrets.cms_password)} | ||
get edit_profile_url(profiles(:one)), headers: admin_authorization_headers | ||
|
||
assert_response :success | ||
end | ||
|
@@ -37,7 +35,7 @@ class ProfilesTest < ActionDispatch::IntegrationTest | |
assert_difference("Profile.count") do | ||
post profiles_url, | ||
params: {profile: {first_name: "John", last_name: "Doe", email: "[email protected]"}}, | ||
headers: {Authorization: ActionController::HttpAuthentication::Basic.encode_credentials(Rails.application.secrets.cms_user, Rails.application.secrets.cms_password)} | ||
headers: admin_authorization_headers | ||
end | ||
|
||
assert_redirected_to profile_url(Profile.last) | ||
|
@@ -46,7 +44,7 @@ class ProfilesTest < ActionDispatch::IntegrationTest | |
test "should update profile" do | ||
patch profile_url(@profile), | ||
params: {profile: {first_name: "John"}}, | ||
headers: {Authorization: ActionController::HttpAuthentication::Basic.encode_credentials(Rails.application.secrets.cms_user, Rails.application.secrets.cms_password)} | ||
headers: admin_authorization_headers | ||
|
||
@profile.reload | ||
|
||
|
@@ -56,8 +54,7 @@ class ProfilesTest < ActionDispatch::IntegrationTest | |
|
||
test "should destroy profile" do | ||
assert_difference("Profile.count", -1) do | ||
delete profile_url(@profile), | ||
headers: {Authorization: ActionController::HttpAuthentication::Basic.encode_credentials(Rails.application.secrets.cms_user, Rails.application.secrets.cms_password)} | ||
delete profile_url(@profile), headers: admin_authorization_headers | ||
end | ||
|
||
assert_redirected_to profiles_url | ||
|
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