Calling FactoryGirl.build(:role, :permissions => []) needs a setter directly on role. Otherwise it fails on Rails 4 with: ActiveRecord::HasManyThroughNestedAssociationsAreReadonly: Cannot modify association 'Role#permissions' because it goes through more than one other association.
Solution
Add a setter for permissions in role.rb. It's compatible with Rails 3 and 4.
Related issues
Refactor #12147: move rails3 compatible changes from the rails4 branch to develop
refs #12147 - adding permissions setter to roles
Problem
Calling FactoryGirl.build(:role, :permissions => []) needs a setter
directly on role. Otherwise it fails on Rails 4 with:
ActiveRecord::HasManyThroughNestedAssociationsAreReadonly: Cannot modify
association 'Role#permissions' because it goes through more than one
other association.
Solution
Add a setter for permissions in role.rb. It's compatible with Rails 3
and 4.