similar to: creating fixtures for has_many :through

Displaying 20 results from an estimated 2000 matches similar to: "creating fixtures for has_many :through"

2010 Jan 29
4
requiring records in the DB before testing
Is there any way I can require a small set of data be in the test database before any tests are run? (unit, functional, integration, cucumber, etc) Any way besides using fixtures, that is. Overload a rake task? Modify test_helper? Any ideas? (Simple Case: I have to have a minimal set of user roles defined before any users can be created) -- You received this message because you are subscribed to
2010 Dec 12
5
Fixtures and unit tests - no such file to load
Hello all, I''m having some issues with my test fixtures and unit tests and am hoping somebody has an idea about how to fix it. Background: I have a table in my legacy database called tp_approval_step. For this table I have a fixture called tp_approval_step.yml I have a model called ApprovalProcessStep that uses set_table_name ''tp_approval_step'' In my test file,
2009 Sep 01
13
Function Testing Reloading Fixtures before assertion
Hey Everyone, I have a function test the is failing (despite the fact the function actually works in the application). I was looking for some debug advice on how to find my problem. Here is the test: def test_should_delete_word assert_equal ''published'', words(:one).status debugger delete :destroy, :id => words(:one).to_param assert_equal
2009 Dec 22
1
Rails fixtures - defining a table name?
Hi, At the minute all my fixtures have the same name as the table that they are intended for, because of a recent issue with rails it doesn''t seem possible to have a fixture beginning with the word ''test'' Does anyone know of a way to have a different fixture name and then map it to the correct table? Thanks -- Posted via http://www.ruby-forum.com/. -- You received
2010 Feb 04
2
preload test data from factory_girl
Is there a way to preload common data made by factory_girl to speed up tests instead of recreating these common data at the beginning of every test. For example, I want to have 10 users premade at the beginning of every test. I found this http://agilewebdevelopment.com/plugins/factory_data_preloader But the page says that this plugin does not "play nice" with autotest. But I use
2010 Feb 01
3
validating both sides of a has_one relationship breaks pickle/machinist tests
A lot has been posted about validation issues with associations, however, I don''t see this issue addressed specifically. ex: class Foo has_one :schedule, :dependent => :destroy validates_presence_of :schedule class Schedule belongs_to :foo validates_presence_of :foo_id this creates a circular dependency that breaks test frameworks like pickle and machinist. At first I was
2010 Jul 28
5
db:fixures:load does not call Model.save()
Hello, $ ruby script/generate model balance plus:integer minus:integer equal:integer $ cat app/models/balance.rb class Balance < ActiveRecord::Base def save self.equal = self.plus - self.minus super end end $ cat test/fixtures/balances.yml _10-1: plus: 10 minus: 1 $ rake db:fixtures:load $ sqlite3 db/development.sqlite3 sqlite> select * from balances; //=>
2010 Aug 06
4
Object/Record foreign key IDs set to zero
Hello, Hope no one minds me just jumping in here with a question. I''m completely new to Ruby on Rails. I''ve been reading "Simply Rails 2", and following their examples. I reached a point where the unit tests were unexpectedly failing. Upon investigation, I discovered that when Rails loads the fixtures, the foreign keys aren''t being populated with the foreign
2011 Jan 20
11
RSpec / Cucumber painfully slow Rails 3 OSX
I am working on my first Rails BDD project with extensive tests since starting out with Rails a few years ago. Running RSpec or Cucumber is really slow. I''m using Rails 3 and RSpec 2. To run one model spec with only 5 tests takes almost 1 minute! When it finishes it says it took only 0.9 seconds to run the actual test. So obviously it is loading the environment that takes so long. I just
2009 Jul 11
3
Migration in Multiple Database
hello to all I been working on this from past few days. .I am talking about separate migration for each one of the multiple database that a single rails application has connection with.I know that rails can work with multiple databases but what with migrations for e.g my main rails application has a connection to two databases 1> main_development 2> secondary_development Know suppose i
2010 Nov 09
3
help getting started with javascript generated forms
How does one generate a form within a view using javascript? Specifically, assume views/premise/new.html.erb looks like this: <%= form_for(Premise.new) do |f| %> <%= f.hidden_field :full_address, :value => $FULL_ADDRESS %> <%= f.hidden_field :geocoding, :value => $GEOCODING %> <%= f.submit :value => "use this address" %> <%= f.label
2010 Jul 08
3
my web app seed data and cucumber
I''m writing a web app which is used a SaS. Each customer has their own db and app directory. I have a rake task which creates all necessary minimum data to run their website: default rights and roles, a superadmin user, a "us_states" table already populated, some local depots and terminals (it''s a logistics app). I don''t have any cucumber scenarios for it and
2010 Oct 06
7
Passing a hash from the model to the view
I''m trying to display a drop-down menu by using an instance variable from a model. THIS WORKS... <div class="field"> <%= f.label :duration %><br /> <%= f.select ("duration", {"30 minutes" => "30", "1 hour" => "60"}, :prompt => "Select") %> </div> THIS DOESN''T
2012 Apr 03
4
one master table to hold symbols: good or bad idea?
(This is may be more of a db design question than a rails question.) Summary: I''m thinking of creating a single AR class to hold constant symbol values and use it for :has_many_through relations whenever I need a constant symbol. Is this a good idea or a bad idea? Details: I notice that I have a lot of models that contain just a name string: create_table
2010 Dec 06
10
testing chapter: agile web dev withrails
I am working my way through Agile web development with rails and I''m in the testing chapter. when I run the following test(or any other test) I''m new and not sure where to start looking. require ''test_helper'' class ProductTest < ActiveSupport::TestCase # Replace this with your real tests. test "the truth" do assert true end end I
2010 Sep 27
3
having some issues with factory_girl and bundler...
Hi All Need some brilliants minds here :) I''m using Rails 2.3.8 & ruby 1.8 (I know, I know... ) I''ve move my gems from .gems to Bundler, but I''m having some issues with Factory_girl when I rake spec "uninitialized constant Factory" I''m following the instructions from http://gembundler.com/rails23.html. Basically: - grab all config.gem and place
2005 Oct 11
4
Searching an attribute in a hmabtm relationship
(Nuby to Ruby and Rails...) I''ve implemented security using the login generator in a simple app so that I have a user table, a roles table, and a join between them (roles_users). All works as expected. I now need to check if a user has a specific role, but my approach is off somehow. Here''s what I''ve tried thusfar: user_roles = @session[:user].roles
2007 Aug 10
1
How to spec a model method
Still new to Specs... How do I create a spec to test a model method? Specifically, here is my spec: #testing model describe User do it "should have many user roles" do User.reflect_on_association(:user_roles).should_not be_nil end it "should have many roles though user roles" do User.reflect_on_association(:roles).should_not be_nil end it "should know
2009 Jul 21
2
Machinist - having problems stubbing an after_create filter
Hi all I''m moving to using Machinist in my rspec tests and am having a problem with an after_create callback method that i need to stub out. It seems like calling ClassName.make will trigger this callback before i''ve had the chance to stub it. Can i stub it in my blueprint for that class? Or, can i stub the method for all instances of the class before i call ClassName.make?
2010 Oct 27
0
Help with routes
Switching our routes file from Rails2 to Rails3 DSl uncovered an odd situation, of my own making, but I am having some difficultly imagining how to fix it. Basically I have a commonplace: user -> user_role (clearance) <- role type arrangement where: User has_many :roles, :through => :clearances has_many :clearances Clearance belongs_to :role belongs_to :user and Role