I'm using recommended rails 4 way to generate fixtures relations, and it works everywhere except on two models which I use from doorkeeper gem:
oauth_access_tokens.yml:
first_token:
resource_owner_id: <%= ActiveRecord::FixtureSet.identify(:mani) %>
token: 50fa9c51f67cc72056ef18a8563c6909ce14454474e92269bfb9e1c043979631
application_id: <%= ActiveRecord::FixtureSet.identify(:shane) %>
refresh_token:
expires_in:
revoked_at:
created_at: 2014-02-10 09:39:58.033008
scopes:
mani is the name of a user in users.yml which works perfectly, which means fixture generates correct id for it but the problem is with application_id column which is defined on Doorkeeper gem this way:
module Doorkeeper
class AccessToken
belongs_to :application,
class_name: 'Doorkeeper::Application',
inverse_of: :access_tokens
and this is oauth_applications.yml:
shane:
name: Bank of Shane
uid: f716cf9556afb3cc305cbbd30f7fb8313e2ef5be8d1dc210ce8ee9557c007011
secret: dfdfeb0ee1aec09dfeb4ee1a7d403811187a491a8b0fbbdd09862f3d623db9e1
redirect_uri: http://ift.tt/1hZvjYu
created_at: 2013-07-25 02:52:06.724123
updated_at: 2013-07-26 04:17:26.163418
owner_id: <%= ActiveRecord::FixtureSet.identify(:mani) %>
owner_type: User
image:
color: FEC54F
after generating fixtures, here is the problem in rails console test:
2.2.2 :003 > Doorkeeper::AccessToken.first.application_id
Doorkeeper::AccessToken Load (0.6ms) SELECT "oauth_access_tokens".* FROM "oauth_access_tokens" ORDER BY "oauth_access_tokens"."id" ASC LIMIT 1
=> 158449671
2.2.2 :004 > Doorkeeper::AccessToken.first.application
Doorkeeper::AccessToken Load (0.8ms) SELECT "oauth_access_tokens".* FROM "oauth_access_tokens" ORDER BY "oauth_access_tokens"."id" ASC LIMIT 1
Doorkeeper::Application Load (0.4ms) SELECT "oauth_applications".* FROM "oauth_applications" WHERE "oauth_applications"."id" = $1 LIMIT 1 [["id", 158449671]]
2.2.2 :005 > Doorkeeper::Application.first
Doorkeeper::Application Load (0.8ms) SELECT "oauth_applications".* FROM "oauth_applications" ORDER BY "oauth_applications"."id" ASC LIMIT 1
=> #<Doorkeeper::Application id: 1, name: "Bank of Shane", uid: "f716cf9556afb3cc305cbbd30f7fb8313e2ef5be8d1dc210ce...", secret: "dfdfeb0ee1aec09dfeb4ee1a7d403811187a491a8b0fbbdd09...", redirect_uri: "http://ift.tt/1W8GgK6...", created_at: "2013-07-25 02:52:06", updated_at: "2013-07-26 04:17:26", owner_id: 772656641, owner_type: "User", image: nil, color: "FEC54F">
=> nil
As you can see rails generated application_id of 158449671 on oauth_access_tokens while id of application shane is 1 on test database.
Aucun commentaire:
Enregistrer un commentaire