Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/controllers/contributors_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,10 @@ def process_org(hash:)
allow = !Rails.configuration.x.application.restrict_orgs
org = org_from_params(params_in: hash,
allow_create: allow)
return nil if org.blank? && !allow

hash = remove_org_selection_params(params_in: hash)

return hash if org.blank? && !allow
return hash unless org.present?

hash[:org_id] = org.id
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/contributors_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,11 @@
hash = @controller.send(:process_org, hash: @params_hash[:contributor])
expect(hash).to eql(@params_hash[:contributor])
end
it "with restrict_orgs=true, returns nil if the org could not be converted" do
it "with restrict_orgs=true, returns hash if the org could not be converted" do
Rails.configuration.x.application.restrict_orgs = true
@controller.stubs(:org_from_params).returns(nil)
hash = @controller.send(:process_org, hash: @params_hash[:contributor])
expect(hash).to eql(nil)
expect(hash).to eql(@params_hash[:contributor])
end
it "sets the org_id to the idea of the org" do
new_org = create(:org)
Expand Down