Displaying 20 results from an estimated 20000 matches similar to: "relationships in text fixtures"
2010 Jun 03
2
creating fixtures for has_many :through
I''m stymied at how to create a fixture that establishes a has_many
:through relationship.
I''ve watched the railscast at:
http://media.railscasts.com/videos/081_fixtures_in_rails_2.mov
... but that''s for HABTM relationships. I''ve read:
http://www.ruby-forum.com/topic/145676
but that ultimately doesn''t answer any question. So with no further
ado:
2011 Apr 26
1
problem populating table using rake db:fixtures:load
I''m running Rails 3 and I''m trying to populate a table using rake
db:fixtures:load, and I''m getting a "Could not find" file error.
The table is called stores, and I''ve confirmed that it exists, and the
data is in stores.yml in my test/fixtures directory. The command I''m
running is rake db:fixtures:load FIXTURES=stores.
The error message
2006 Jul 10
1
rake db:fixtures:load FIXTURES=xyz
I am attempting to do selective fixture loading against my test
database.
When I run
rake db:fixtures:load FIXTURES=DataSetInfo
I get no output. (A full trace is below). I''m trying to figure out why
nothing happens.
1) Does the command above attempt to operate against my test database?
2) DataSetInfo is the name of my table and the name of my yml file
I generated these YAML
2006 Feb 17
0
Model relationships in tests
I''m finding that its a pain to create yml files for tests where there
are relationships between tables/classes.
For example, I might have something like this:
vehicle.yml
red_ford:
id:1
owner_id:2
owner.yml
ford_owner:
id:2
address_id:5
address.yml
home_address:
id:5
etc.
To build up complex test relations, I have to edit all three files,
keeping track of the ids /
2007 Nov 14
1
New Foxy Fixtures (Rails 2) & STI (Single Table Inheritance)
I''ve got some problems right now using the new model for relationships
in fixtures (by label, not by id) and STI. What I''ve got, is a couple
of models:
Attachment
--> FileDownload
Version
Version has_one file_download with file_download_id on the versions
table
In my fixtures, I have two FileDownloads in my attachments.yml like
so:
hemingway_alpha_zip:
size: 100
2007 Apr 02
0
Fixtures.create_fixtures with any desired filenames?
Hi all
I''d like to create fixtures using
Fixtures.create_fixtures
But it seems that this one needs .yml files that have the same name like
the table they correspond to:
countries.yml => my_db.countries
readers.yml => my_db.readers
Is it possible to use any desired filenames somehow?
some_cool_countries.yml => my_db.countries
some_other_cool_countries.yml =>
2011 Aug 10
1
How to stop Rspec loading my Cucumber fixtures
I have a bunch of fixtures designed to populate the database for my Cucumber
integration tests.
But at this stage I want my database to be empty when using Rspec.
So, I moved the fixtures from `/spec/fixtures` to
`features/support/fixtures`, and updated `features/support/env.rb` to read:
Fixtures.reset_cache
fixtures_folder = File.join(RAILS_ROOT, ''features'',
2006 Apr 27
0
Intergration testing with ordered fixtures
Hi all.
I have a question on accessing fixtures by name.
I''m doing integration testing very similar to what is described in
Jamis''s excellent writeup at
http://jamis.jamisbuck.org/articles/2006/03/09/integration-testing-in-rails-1-1.
The problem is that I am using ordered yml fixtures so that rake loads
each element in the correct sequence. I need to do this because my
2007 Jun 27
5
Mosquito Fixtures Won''t Load
I can''t get fixtures to load correctly in a Mosquito test. The first
fixture loads in the unit test, but the rest don''t load at all.
File structure:
tracker/
tracker.rb
test/
test_tracker.rb
fixtures/
tracker_measurements.yml
tracker_projects.yml
Relevant test code:
require ''rubygems''
2006 Jun 12
0
Maintain foreign key linkages in fixtures...
Is there anyway to refer to the entities being linked in a foreign key field of
a fixture by name instead of id?
Ie, if I have
categories.yml
some_cat:
id: 1
name: Foo
other_cat:
id: 2
name: Bar
data.yml
some_item:
id: 1
category_id: <%= categories(:some_cat).id %>
name: Hello World
The above doesn''t work due to scope, even if the fixtures are loaded in the
proper
2005 Dec 15
3
Fixtures and table name
Is there a way to use table name other than the default or to turn it around have multiple fixture files associated to the same table.
Here''s my use case: I have multiple unit test classes that all work with the same model class and hence the same database table. However, for each test class I want the data to be in a different state.
So I''d like to have something like
class
2008 Apr 27
1
Odd fixtures behaviour
This is Rails 2.0.2
I have two yaml fixture files, both loading into ARs with acts_as_tree,
so they both have the !!omap directive set.
One, categories.yml, loads just fine. The other goes very weird, somehow
fixtures.rb opens the file, reads "name: All" from the first record, and
then tries to open a file called "All", which then fails miserably on
line .
I can''t
2009 Mar 28
10
Use fixtures within fixtures?
Heya,
I''m using globalize2 and have following problem with my fixtures:
categories.yml:
one:
parent_id: two
color: #ff00aa
two:
color: #00ff11
three:
parent_id: two
color: #ab00ab
category_translations.yml
one-en:
id: one
locale: en
name: Cars
one-es:
id: one
locale: es
name: Coches
two-en:
id: two
locale: en
name: Start
two-es:
id: two
locale: es
2006 Feb 21
0
How do you order fixtures within each yml file?
Hi.
I''ve come across the following documentation:
Note that YAML fixtures are unordered. If you want ordered fixtures, use the
omap YAML type. See yaml.org/type/omap.html for the specification. You will
need ordered fixtures when you have foreign key constraints on keys in the
same table. This is commonly needed for tree structures. Example:
--- !omap
- parent:
id:
2007 May 21
2
Rails'' fixtures suck! But what about something like this?
Sorry about the very long email, but this is a hairy topic that''s been
annoying me for some time and I decided to try to do something about.
Also, if you got this twice, I apologize too, but it didn''t seem to
have successfully gone out the first time.
Background:
----------
I''ve been dealing with Rails for about a year and a half now. I''ve
been using
2006 Aug 04
1
All Fixtures plugin
Just released a very simple plugin for including all fixtures in your
tests. Once you have a large number of table, manually managing the
fixtures for every single test stub can be quite tedious.
Use as follows
class BlogArticleTest < Test::Unit::TestCase
all_fixtures
def test_foo
...
end
end
Couldn''t be easier. More info here:
2006 May 23
2
Putting fixtures into subdirectories
I want to organize my fixtures just like the namespace of my models. So
for example if I have a model Company::Employee I''d like the fixture to
be in fixtures/company/employees.yml.
However, I can''t figure out how to specify the path of the fixture file.
If I do:
fixtures :employees
in my unit test it can''t find the fixture file. Any suggestions?
Thanks,
Todd
2006 Apr 02
1
Fixtures For Logging In
Hi,
I''m trying to write some integration tests for my app and am having some
troubles getting past the initial login.
Here is what my fixture looks like
users.yml
user_001:
id: "7"
login: testuser001,
email: testuser001@example.com,
state: 2,
password: b78d41e7ccb8da412f4f66f754121667,
password_salt: 78cKRniDIo,
password_hash_type: md5
I took the password and
2006 Jan 07
1
How to DRY with Fixtures (helper or extend Time class, how)?
I have a test/fixtures/users.yml like so:
apa:
id: 1
username: apa
[...]
created_at: <%=Time.now.strftime("%Y-%m-%d %H:%M:%S")%>
updated_at: <%=Time.now.strftime("%Y-%m-%d %H:%M:%S")%>
I don''t like how I''m repeating myself with the strftime bit.
Is there some shorter Time method to format time for a (MySQL) datetime
field that
2006 Apr 21
1
Using fixtures inside migrations
Hi,
I want to add data from a fixture file to a table inside a migration.
I''ve saved the file in db/migrate/fixtures/countries.yml
I guess I could just open the file, read the entries, and add them to
the database using AR, but I''m hoping I can use Rails for all that.
Also, if I have a file, say, with 200,000+ records, what would be the
best method (performance-wise) to go