Skip to content

Commit 72bec24

Browse files
fix(action): authorize all actions on development environment (#617)
1 parent 50b989f commit 72bec24

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

app/services/forest_liana/ability/permission.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ def is_crud_authorized?(action, user, collection)
3030
end
3131

3232
def is_smart_action_authorized?(user, collection, parameters, endpoint, http_method)
33+
return true unless has_permission_system?
34+
3335
user_data = get_user_data(user['id'])
3436
collections_data = get_collections_permissions_data
3537
begin

spec/requests/actions_controller_spec.rb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,39 @@
312312
end
313313
end
314314

315+
describe 'calling the action on development environment' do
316+
let(:all_records) { false }
317+
let(:params) {
318+
{
319+
data: {
320+
attributes: {
321+
collection_name: 'Island',
322+
ids: ['1'],
323+
all_records: all_records,
324+
smart_action_id: 'Island-Test'
325+
},
326+
type: 'custom-action-requests'
327+
},
328+
timezone: 'Europe/Paris'
329+
}
330+
}
331+
332+
it 'should respond 200 and perform the action' do
333+
Rails.cache.delete('forest.has_permission')
334+
Rails.cache.delete('forest.users')
335+
Rails.cache.write('forest.users', {'1' => { 'id' => 1, 'roleId' => 2, 'rendering_id' => '1' }})
336+
allow_any_instance_of(ForestLiana::Ability::Fetch)
337+
.to receive(:get_permissions)
338+
.with('/liana/v4/permissions/environment')
339+
.and_return(true)
340+
341+
post '/forest/actions/test', params: JSON.dump(params), headers: headers
342+
343+
expect(response.status).to eq(200)
344+
expect(JSON.parse(response.body)).to eq({'success' => 'You are OK.'})
345+
end
346+
end
347+
315348
describe 'calling the action' do
316349
before(:each) do
317350
allow_any_instance_of(ForestLiana::Ability).to receive(:forest_authorize!) { true }

0 commit comments

Comments
 (0)