Project

General

Profile

« Previous | Next » 

Revision f968c042

Added by Marek Hulán almost 6 years ago

Fixes #24158 - fix cloning of roles

Roles that contains filters without permissions could not be cloned. In
UI, user did not even get any error message, API responded with 422 at
least.

View differences:

app/models/role.rb
:include => [:locations, :organizations, { :filters => :permissions }])
new_role.attributes = role_params
new_role.cloned_from_id = self.id
new_role.filters = new_role.filters.select {|f| f.filterings.present? }
new_role
end
test/models/role_test.rb
assert_include Role.cloned, cloned_role
assert_not_include Role.cloned, role
end
context 'role has some empty filters' do
before do
role.permissions = [ Permission.first ]
role.filters.first.filterings = []
end
it 'clones the role ignoring the empty filters' do
assert cloned_role.valid?
assert_equal cloned_role.filters.size + 1, role.filters.size
end
end
end
context "System roles" do

Also available in: Unified diff