I'm trying to implement the Rolify gem and have trouble adding fixtures, especially because the role is scoped to a single organization. The (model) test below fails as @user.has_role?('moderator')
is false. Any idea what I'm doing wrong? The test:
def setup
@user = users(:one)
@organization1 = organizations(:one)
@moderator_role = roles(:first_organization_moderator_role)
end
test "should be moderator if fixtures correct" do
assert_equal @user.has_role?('moderator'), true
end
roles.yml
first_organization_moderator_role:
name: :organization_moderator
resource_id: 1
resource_type: 'Organization'
In users.yml to an existing user which is related to organization one I added the roles line (I'm undertain how to set its scope to be only moderator for organization one):
one:
organization: one
email: orgone@example.com
username: myster1
activated: true
roles: organization_moderator, organization(:one) #I also tried ", organization_id(:one)". The idea here is to set the scope of the role.
In organizations.yml there is an organization named one.
Aucun commentaire:
Enregistrer un commentaire