similar to: test/mocks/ in rails directory structure

Displaying 20 results from an estimated 9000 matches similar to: "test/mocks/ in rails directory structure"

2007 Sep 07
6
ActiveRecord::Base#update_all expected behaviour
Hi I noticed that if in my code I use the following: Photo.update_all("title = ''Ruby rocks'' ", "id IN (#{@photo_ids})") All my objects are properly updated but none of the filters/callbacks are triggered. Is that what''s expected? I have a before_update filter set on the Photo class and it gets totally ignored, I guess the only way to solve this
2007 Jul 25
5
set_default_values rocket science - continuing after_initialize/after_find misfeature
Just starting a new thread so that it''s easy to follow. I just submitted a patch at trac to add a new class method called "set_default_values" ( not a great name I think ), which lets you do all kinds of crazy stuff with setting default values. This ticket is at http://dev.rubyonrails.org/ticket/9093 and example pastie is at http://pastie.caboo.se/81925 It also lets you make
2007 Oct 18
9
with_scope issue
I have the following code: class User < ActiveRecord::Base has_many :requests do def find_active(options = {}) with_scope :find => { :conditions => ["requests.active = ?", true] } do find(:all, options) end end end end Executing user.requests.find_active results in the following SQL: SELECT * FROM requests WHERE (( requests.user_id = 10 ) AND (
2007 Aug 21
2
counter cache
Hi, I have two models, employees and departments, and i am using counter_cache to count the number of employees in a department. This works great, but employees can change their departments, and the counter cache does not get updated to reflect this. Is their a built in way to do this, or do i have to implement my own before_save hook thanks --~--~---------~--~----~------------~-------~--~----~
2007 Dec 11
2
Patch 10463: has_many through using uniq does not honor order
Hi, I''ve just submitted a patch for ActiveRecord; http://dev.rubyonrails.org/ticket/10463 The patch includes new fixtures because I could not find a applicable combination among the existing fixtures. I hope that''s okee. Please +1 or comment it. Thanks, Remco --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the
2007 Aug 07
2
Making Validations Optional
Hello, I am working with URL validations. I want this validation to be optional if the data exists in the form submission. I have tried several things. validates_format_of :website, :if => params[:organization][:website], :with => /((http|https):\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z] {2,5}(([0-9]{1,5})?\/.*)?/, :message => "Please enter a valid url" Of
2007 Aug 02
4
ActiveRecord Limitation (Advance)
Or is it ? Need to be able to :- @search = Form.find(:all, :include=>[:form_type, :form_type_items], :conditions=>....) I need in the Form model a :form_type_items, the question is, what is the relationship type? Current Models:- Form belongs_to :form_type FormType has_many :form_types has_many :form_type_items FormTypeItem Belongs_to :form_type Form ---------------- | id |
2007 Oct 24
5
Utility that checks outdated patches
I just noticed I frequently encounter patches that need to be updated because of applied changes. Maybe this can be automated? Not automating the "updating of the patch" part, but the part where a comment is posted to the ticket so the submitter is informed. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups
2007 Aug 09
4
no route found to match "/rails/info/properties" with {:method=>:get}
After a new install (Ruby, Rails en Gem) on a newly installed OS. I''m getting a ''no route found to match'' error. I Googled a bit, and saw that more people had this problem with older rails versions. I''m on Ruby 1.8.6, Rails 1.2.3 and Gem is 0.9.4, on a Mac running OS 10.4.9. Any suggestion is welcome. Regards, Robert.
2008 Dec 23
3
rake doc:guides error
I have Rails 2.2.2 installed and get the following message when I try to generate the rails guides: Family-iMac:expences Dad$ rake doc:guides (in /Users/Dad/Documents/Rails/Apps/expences) rake aborted! Don''t know how to build task ''doc:guides'' (See full trace by running task with --trace) Family-iMac:expences Dad$ rake doc:guides --trace (in
2007 Jul 18
16
Edge Rails namespaced routing
Hi, I was wondering if anyone came across a similar scenario when working with namespaced routes with edge rails. Consider an application with controllers customers and products that also have other resources. map.resources :customers do |customer| customer.resources :notes customer.resources :tags end map.resources :products do |product| customer.resources :notes customer.resources
2007 Jun 28
23
DRYing link_to with a symbol
Hi, I just put in a patch that allows you to DRY up this: <%= link_to @company.name, @company %> to this: <%= link_to :name, @company %> The symbol indicates the method to be called on the object passed in the link_to options. http://dev.rubyonrails.org/ticket/8789 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the
2007 Dec 02
5
walkthrough: Rails 2.0 startup process
I haven’t found a complete big-picture walkthrough for the Rails startup process when I looked for one recently. There are some really useful resources about this but they are for Rails 1.2 and each of them only covers certain parts of the process. Thus, I’ve taken some notes while reading to the Rails code and compiled the following guide from them.
2007 Nov 06
2
Why is this view spec failing?
I can''t figure out why I am getting a failure. It renders out fine in the browser. <h1>New member</h1> <%= error_messages_for :member %> <% form_for(:member, :url => members_path) do |f| %> <fieldset> <legend>Member Info</legend> <p><label for="member[first_name]">First Name:</label> <%=
2007 Aug 28
3
How do you keep mocks updated without pain?
Hi! I know you must be answering a lot of basic questions, sorry about that :-) However I have not get it, how do you keep mocks updated without pain? I reached to the point where mocking things for view. I spec model-controller-view using "correct doc" way mocking-stubbing (plus I should run integration test to be sure that everything really works together). Now, when I want to
2007 Aug 03
6
Problems saving an uploaded image to an app folder
In my app, the user can upload images. Rather than shoving the image data in the database, i want to put the filename and content type into the db, then rename the image with its record''s id number, and then save it into a local folder in my app folder. (hardcoded for now) All the details are being saved to the db ok, so as far as i know the "picture_file=" method is fine.
2007 Feb 17
1
"warning: object#id will be deprecated" with mocks
hi all I have the following code in a spec: @user = mock("user") User.stub!(:authenticate).and_return(@user) @user.should_receive(:id).once.and_return(99) post :login, {:username => ''username'', :password => ''password''} session[:user_id].should == 99 it works as expected but I get the following warning when I run the spec: warning:
2007 May 02
4
Terse Mocks
Hello, I recently made a feature request with a patch for terser mocks. http://rubyforge.org/tracker/index.php?func=detail&aid=10412&group_id=1917&atid=7480 Here are some examples with their current equivalents: the_mock.expects.foo(1,2) {|a, b| :bar} the_mock.expects.foo(1,2).returns(:bar) the_mock.expects(:foo).with(1,2) {|a, b| :bar} the_mock.expects(:foo).with(1,2).returns(:bar)
2006 Dec 18
4
How to keep mocks consistent?
Hey all, Here''s a question for everyone: how do you keep your mocks and stubs consistent with your real objects? I''m dipping my toes into the RSpec world, and it''s absolutely delightful (running dozens of tests in less than a second is nice as well), but I''m concerned about my ability to keep the mocks in my specs consistent with the behavior of their
2007 Mar 13
1
Opening the singleton class of mocked objects
I wrote a plugin [1] a while ago that lets me do validations on a single AR instance. Instead of defining validations in an AR class, I can define them on a AR instance''s singleton class: class << @video validates_presence_of :title end One of my specs mocks Video.find, and the above code is run on the mock object. When I run the spec, I get the expected undefined method