search for: to_param

Displaying 20 results from an estimated 77 matches for "to_param".

2009 Sep 01
13
Function Testing Reloading Fixtures before assertion
...espite 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 ''deleted'', words(:one).status end It fails on the last with: <"deleted"> expected but was <"published">. //My fixture: one: word: cup was_created_by_user: true status: published user_id: 1 ip_address: ''129.1....
2013 Apr 12
1
What is the meaning of the method to_param?
Hey! Foe example i have next code: test "should update user" do put :update, id: @user.to_param, user: @input_attributes assert_redirected_to users_path end What return id: @user.to_param? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop r...
2006 Jul 07
5
link_to: link is missing id
I''m using a legacy table, where the unique id is not ''id'' I have a Model class like the following: class Article < ActiveRecord::Base set_primary_key "ARTICLE_ID" end however, using a link_to like the following (modified scaffolding), the link has no id value: <% for article in @articles %> <tr> <% for column in
2007 Jan 24
2
A spec where interaction-based testing breaks down... (at least for now)
Here are the specs: context "Finding all the stylesheets available to a company" do setup do @mock_company = mock("company") @mock_company.stub!(:to_param).and_return "1" Stylesheet.stub!(:find) end def do_find Stylesheet.find_available_to @mock_company end specify "should convert the company into a parameter" do @mock_company.should_receive(:to_param).and_return "1" do_find end specify &qu...
2006 Feb 01
0
to_param() / url generation Question
I''m trying to implement the to_param method to allow url generation to be in the format of /:category_name/:article_permalink (as discussed on page 299 of Agile Web Development With Rails). I expect that I need to override/implement the to_param method and have it return the category_name for the category model and the article_pe...
2008 Feb 20
0
#dom_id should use AR#to_param instead of AR#id
Hi, I have just commited a patch for ActionController''s #dom_id, it should iternally use AR#to_param instead of AR#id, because #to_param is used for routing representation of an ActiveRecord inside ActionPack. You can found the ticket here: http://dev.rubyonrails.org/ticket/11179. Luca. -- blog: www.lucaguidi.com --~--~---------~--~----~------------~-------~--~----~ You received this message...
2007 Jan 30
5
errors while testing resource controller using rpec
...venue in this piece of code (generated using script/rspec_resource) ==================== context "Requesting /venues using POST" do controller_name :venues setup do @mock_venue = mock(''Venue'') @mock_venue.stub!(:save).and_return(true) @mock_venue.stub!(:to_param).and_return(1) Venue.stub!(:new).and_return(@mock_venue) end def do_post post :create, :venue => {:name => ''Venue''} end specify "should create a new venue" do Venue.should_receive(:new).with({''name'' => ''Venue'...
2007 Sep 18
2
rSpec / Nested Routes / Mocks
...d --items_controller-- def create @item = Item.new(params[:item]) @item.user = User.find(params[:user_id]) respond_to do |format| if @item.save ....etc..... --items_controller_spec-- describe ItemsController, "create action" do before do @item = mock_model(Item, :to_param => "1") @user = mock_model(User, :to_param => "1") Item.stub!(:new).and_return(@course) User.stub!(:find).and_return(@user) end def post_with_successful_save ***** @item.should_receive(:user) @item.should_receive(:save).and_return(true) post :cr...
2010 Jan 04
2
to_parm and how it can be used in a helper
is there a way to pass the data returned by the to_parm function in a helper? i followed the info provided at http://www.jroller.com/obie/entry/seo_optimization_of_urls_in and am able to successfully get the correct urls, now i want to be able to get the same (id-whatever) text and pass it to a helper function for further processing. Any ideas as to how this can be achieved? -- Posted via
2007 Sep 28
2
form action url example
Hi, I have the following example: it ''should have a form with an action attribute'' do response.should have_tag( "form[action=?]", ''/users/1/machines/1/trouble_tickets'') end for a form like so: <% form_for( :trouble_ticket, :url => { :action => ''create'', :user_id => @machine.current_owner,
2007 Feb 09
2
Re: customizing map.resources for REST
Yeah... I''m totally struggling to grok resource routes too... seems like they''ve totally blown the beautiful simplicity of the old url pattern stuff out of the water. Would love to hear an answer to this question!!! b Andy Triboletti wrote: > I want to customize map.resources so it uses a uid in the URL instead > of the database id. The uid is a field on my object.
2006 May 17
6
ActiveRecord#to_param
Hello, to implement some some kind of optimistic locking, I want to build a view, where an object is displayed together with a link containing the data of the displayed object. My first try looked something like <%= object.object_discription %> <%= link_to "action", :action => "take_action", :data => object %> this won''t work because object is of
2006 Jul 23
4
Anything like with_scope for ActionController?
...is working with routes, however I need to tack on an extra parameter to all the url generating functions (url_for, form_start_tag, named_route_url...) to get the mapping to pick up the custom URL parameter. Having to remember to append :short_name=>@my_object.short_name (with or without to_param magic), is getting annoying and the repetition is getting ugly. Is there anything like ActiveRecord''s with_scope function to "bind" this extra parameter once and make ActionController smart about propagating the extra parameter everywhere? Thank you. Eric
2007 May 20
9
How to test for exceptions
...blem. I tried looking through the documentation but I still don''t know what I missed. Thanks in advance, Blake describe VenuesController, "on update" do before(:each) do @venue = mock("venue") @venue.stub!(:new_record?).and_return(false) @venue.stub!(:to_param).and_return(''1'') controller.class.send(:define_method, :rescue_action) { |e| raise e } end it "should raise an error if record is invalid" do stub_authorized_login Venue.should_receive(:find).and_return(@venue) @venue.should_receive(:update_attribute...
2007 Jan 11
5
ASF: cannot determine document number from primary key
I''m getting this exception from acts_as_ferret: A RuntimeError occurred in search#similar: cannot determine document number from primary key: #<MyClass:0x9feba20> [RAILS_ROOT]/vendor/plugins/acts_as_ferret/lib/instance_methods.rb:132:in `document_number'' As a result of this call: object.more_like_this The relevant backtrace:
2007 Jul 12
3
Agh, this is annoying. Why is this happening?
...#39;'Task_1005'' received unexpected message :user_id= with (1) No matter what I do to try to stub that out it will still fail out and give me that message. Here is my spec describe TasksController, "handling POST /tasks" do before(:each) do @task = mock_model(Task, :to_param => "1", :save => true) Task.stub!(:new).and_return(@task) @user = mock_model(User) @user.stub!(:id).and_return(1) @user.stub!(:login).and_return("moo") User.stub!(:find).and_return(@user) @params = {} end def do_post @request.session[:user]...
2007 Mar 03
5
url_for and arrays parameters (diffs between rails 1.1.6 and 1.2.2)
Hello, I posted this to the main rails list (http://www.ruby-forum.com/topic/99845), but haven''t received any replies yet, so maybe this question is better suited here. Sorry if this has been brought up before, I couldn''t find any previous discussion on this. To summarize the post... When using the latest Rails (1.2.2) I''m passing an array to url_for like so...
2006 Jan 04
5
routing title in url
I''ve set up my app to display a post by retrieving its title instead of id, which works fine, except it looks like this "/post/the+title+of+post%3F" and I want it to be "the_title_of_post?" with underscores instead of plusses. Can anyone shed light? -- Posted via http://www.ruby-forum.com/.
2007 Oct 08
6
spec''in controllers request for nested routes
describe PlayersController, "handling GET /saltmines/games/1/players" do before do @game = mock_model(Game, :to_param => "1") @game.stub_association!(:players, :find => mock_model(Player)) end def do_get get :index, :game_id => @game end it "should be successful" do do_get response.should be_success end it "should render index template" do d...
2007 Oct 05
7
Easy AR association stubbing
I''ve added a method to the mock class that makes it pretty easy to stub associations in rails. I''ve been using it for awhile and it seems to cut down on a lot of setup code for the controller and model specs that use associations. #before @person = mock_model(Person) posts = mock(''post_proxy'') posts.stub!(:build).and_return(mock_model(Post, :save => true))