Revision 3ab56604
Added by Ondřej Pražák almost 6 years ago
app/controllers/concerns/api/v2/taxonomies_controller.rb | ||
---|---|---|
|
||
# overriding public FindCommon#resource_scope to scope only to user's taxonomies
|
||
def resource_scope(*args)
|
||
super.send("my_#{taxonomies_plural}")
|
||
@resource_scope ||= scope_for(resource_class, args).send("my_#{taxonomies_plural}")
|
||
end
|
||
|
||
private
|
test/controllers/api/v2/organizations_controller_test.rb | ||
---|---|---|
response = JSON.parse(@response.body)
|
||
assert_equal "Missing one of the required permissions: create_organizations", response['error']['details']
|
||
end
|
||
|
||
test "should add location to organization" do
|
||
organization = FactoryBot.create(:organization)
|
||
location = FactoryBot.create(:location)
|
||
put :update, params: { :id => organization.id, :organization => { :location_ids => [location.id] } }
|
||
assert_response :success
|
||
assert_contains organization.locations, location
|
||
end
|
||
end
|
Also available in: Unified diff
Fixes #23918 - Find correct scope when updating taxonomy