-
Notifications
You must be signed in to change notification settings - Fork 326
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix broken interface for creating admin groups. Add tests.
- Loading branch information
Showing
2 changed files
with
76 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
<h1>Add Admin Group</h1> | ||
{{admin-groups/record-form model=model}} | ||
{{admin-groups/record-form model=model.record apiScopeOptions=model.apiScopeOptions permissionOptions=model.permissionOptions}} |
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,75 @@ | ||
require_relative "../test_helper" | ||
|
||
class Test::AdminUi::TestAdminGroups < Minitest::Capybara::Test | ||
include Capybara::Screenshot::MiniTestPlugin | ||
include ApiUmbrellaTestHelpers::AdminAuth | ||
include ApiUmbrellaTestHelpers::Setup | ||
|
||
def setup | ||
super | ||
setup_server | ||
|
||
AdminGroup.delete_all | ||
ApiScope.delete_all | ||
end | ||
|
||
def test_create | ||
api_scope = FactoryGirl.create(:api_scope, :name => "Example Scope") | ||
|
||
admin_login | ||
visit("/admin/#/admin_groups/new") | ||
|
||
fill_in("Group Name", :with => "Example") | ||
check("Example Scope") | ||
check("Analytics") | ||
|
||
click_button("Save") | ||
assert_text("Successfully saved") | ||
|
||
admin_group = AdminGroup.desc(:created_at).first | ||
assert_equal("Example", admin_group.name) | ||
assert_equal([api_scope.id], admin_group.api_scope_ids) | ||
assert_equal(["analytics"], admin_group.permission_ids) | ||
end | ||
|
||
def test_update | ||
api_scope1 = FactoryGirl.create(:api_scope, :name => "Example Scope 1") | ||
api_scope2 = FactoryGirl.create(:api_scope, :name => "Example Scope 2") | ||
admin_group = FactoryGirl.create(:admin_group, { | ||
:name => "Example", | ||
:api_scopes => [api_scope1], | ||
}) | ||
|
||
admin_login | ||
visit("/admin/#/admin_groups/#{admin_group.id}/edit") | ||
|
||
assert_field("Group Name", :with => "Example") | ||
assert_checked_field("Example Scope 1") | ||
assert_unchecked_field("Example Scope 2") | ||
assert_checked_field("Analytics") | ||
assert_checked_field("API Users - View") | ||
assert_checked_field("API Users - Manage") | ||
assert_checked_field("Admin Accounts - View & Manage") | ||
assert_checked_field("API Backend Configuration - View & Manage") | ||
assert_checked_field("API Backend Configuration - Publish") | ||
|
||
fill_in("Group Name", :with => "Example2") | ||
uncheck("Example Scope 1") | ||
check("Example Scope 2") | ||
uncheck("API Backend Configuration - Publish") | ||
|
||
click_button("Save") | ||
assert_text("Successfully saved") | ||
|
||
admin_group.reload | ||
assert_equal("Example2", admin_group.name) | ||
assert_equal([api_scope2.id], admin_group.api_scope_ids) | ||
assert_equal([ | ||
"analytics", | ||
"user_view", | ||
"user_manage", | ||
"admin_manage", | ||
"backend_manage", | ||
].sort, admin_group.permission_ids.sort) | ||
end | ||
end |