Skip to content

Commit d297533

Browse files
committed
Ensure Project#user_id is not set on public project
A public project, i.e. one that is accessible to all users, should not have `Project#user_id` set. This is already implicitly enforced by `Api::PublicProjectsController#project_params` which excludes the `user_id` param. However, I thought it was worth adding an example to guarantee it remains the case.
1 parent 3cb4a47 commit d297533

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

spec/features/public_project/creating_a_public_project_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@
3939
)
4040
end
4141

42+
it 'does not set user_id on project even if one is supplied' do
43+
user_id = SecureRandom.uuid
44+
45+
post('/api/public_projects', headers:, params: params.merge(user_id:))
46+
data = JSON.parse(response.body, symbolize_names: true)
47+
48+
expect(data).to include(user_id: nil)
49+
end
50+
4251
context 'when creator is not an experience-cs admin' do
4352
let(:creator) { build(:user) }
4453

0 commit comments

Comments
 (0)