ruby on rails - Incorrect association in fixtures -


i'm following guide http://guides.rubyonrails.org/testing.html#the-low-down-on-fixtures rails 4.1.1 , using named fixtures within 1 in https://github.com/codetriage/codetriage project. when try reference 1 fixture doesn't work:

# fixtures/issues.rb  issue_triage_sandbox_issue:   id: 4   comment_count:   url: https://api.github.com/repos/bemurphy/issue_triage_sandbox/issues/1   last_touched_at: 2012-11-10 22:20:24.000000000 z   number: 1   created_at: 2012-11-10 23:23:45.281189000 z   updated_at: 2012-11-10 23:23:45.281189000 z   repo: issue_triage_sandbox   title: first test issue in sinatra   html_url: https://github.com/sinatra/sinatra/issues/1   state: open 

and

# fixtures/users.rb  issue_triage_sandbox:   id: 1   user_name: bemurphy   name: issue_triage_sandbox   full_name: bemurphy/issue_triage_sandbox   language: ruby   created_at: 2012-11-10 21:50:48.351554000 z   updated_at: 2012-11-10 21:50:48.351554000 z   issues_count: 1 

you can see issue should loading repo issue_triage_sandbox repo. in tests it's not:

issue = issues(:issue_triage_sandbox_issue) puts issue.repo # => nil  puts issue.inspect #<issue id: 4, comment_count: nil, url: "https://api.github.com/repos/bemurphy/issue_triage...", repo_name: nil, user_name: nil, last_touched_at: "2012-11-10 22:20:24", number: 1, created_at: "2012-11-10 23:23:45", updated_at: "2012-11-10 23:23:45", repo_id: 915227508, title: "first test issue in sinatra", html_url: "https://github.com/sinatra/sinatra/issues/1", state: "open", pr_attached: false>      

any ideas why issue being created reference non-existant repo?

i think has id attribute in repos fixture. i'm using yml fixtures. added issue , repo existing ones in project.

issues.yml

issue_triage_sandbox:   user_name: bemurphy   name: issue_triage_sandbox   full_name: bemurphy/issue_triage_sandbox   language: ruby   created_at: 2012-11-10 21:50:48.351554000 z   updated_at: 2012-11-10 21:50:48.351554000 z   issues_count: 1 

repos.yml

issue_triage_sandbox:   user_name: bemurphy   name: issue_triage_sandbox   full_name: bemurphy/issue_triage_sandbox   language: ruby   created_at: 2012-11-10 21:50:48.351554000 z   updated_at: 2012-11-10 21:50:48.351554000 z   issues_count: 1 

from console:

rake db:fixtures:load rails_env=test rails c test

irb(main):001:0> = issue.last 

=> #https://api.github.com/repos/bemurphy/issue_triage...", repo_name: nil, user_name: nil, last_touched_at: "2012-11-10 22:20:24", number: 1, created_at: "2012-11-10 23:23:45", updated_at: "2012-11-10 23:23:45", repo_id: 915227508, title: "first test issue in sinatra", html_url: "https://github.com/sinatra/sinatra/issues/1", state: "open", pr_attached: false>

irb(main):002:0> i.repo 


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -