Skip to content

Commit

Permalink
Create PermissionTemplateAccess in the generated feature spec
Browse files Browse the repository at this point in the history
Previously this generated test would fail, because the user didn't have
access to deposit into the admin set that was created.
  • Loading branch information
jcoyne committed Nov 29, 2017
1 parent bb06ff5 commit 83d87fd
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/generators/hyrax/work/templates/feature_spec.rb.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,17 @@ RSpec.feature 'Create a <%= class_name %>', js: false do
let(:user) do
User.new(user_attributes) { |u| u.save(validate: false) }
end
let(:admin_set_id) { AdminSet.find_or_create_default_admin_set_id }
let(:permission_template) { Hyrax::PermissionTemplate.find_or_create_by!(admin_set_id: admin_set_id) }

before do
AdminSet.find_or_create_default_admin_set_id
# Grant the user access to deposit into the admin set.
Hyrax::PermissionTemplateAccess.create!(
permission_template_id: permission_template.id,
agent_type: 'user',
agent_id: user.user_key,
access: 'deposit'
)
login_as user
end

Expand Down

0 comments on commit 83d87fd

Please sign in to comment.