Displaying 20 results from an estimated 2000 matches similar to: "post_via_redirect - testing problem"
2008 Apr 25
2
Can't Understand Why This Works
I have 3 methods:
def add_to_cart
# do some stuff
redirect_to_index
end
def empty_cart
# do some stuff
redirect_to_index("your cart was emptied")
end
def redirect_to_index(msg = nil)
flash[:notice] = msg if msg
redirect_to :action => :index
end
How come the flash notice works if I''m setting msg = nil? For example,
if I''m in empty_cart and pass
2006 May 05
1
Agile Rails (1st edition), depot TDD "exercise"
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I''ve been working my way through the Agile book and just completed
the depot sample application. I learned quite a bit along the way.
On page 171 we are led through the creation of a test (that fails)
for new code. The new code (a search function) is left as an exercise
for the reader. Well, I think I solved it but I''m not
2005 Dec 25
2
[repost] newbie questions
Hi all,
I''m following the shop example in ''Agile Web Development with Rails''.
I would like to extend the checkout screen, in such a way people can change
the number of items they have selected in there cart.
In my controller I have:
def checkout
@cart = find_cart
@items = @cart.items
if @items.empty?
2006 May 06
1
depot test-driven development exercise
(I posted this yesterday but within 20 minutes my thread was hijacked
so I''m not sure anyone really saw this.)
I''ve been working my way through the Agile book and just completed
the depot sample application. I learned quite a bit along the way.
On page 171 we are led through the creation of a test (that fails)
for new code. The new code (a search function) is left as an
2005 Dec 23
0
newbie question
Hi all,
I''m following the shop example in ''Agile Web Development with Rails''.
I would like to extend the checkout screen, in such a way people can change
the number of items they have selected in there cart.
In my controller I have:
def checkout
@cart = find_cart
@items = @cart.items
if @items.empty?
2006 Jul 03
0
Page 129 of Agile Web Dev on Rails (or pg141 of pdf!)
Hi - another question, sorry....
I''m trying to get the highlighting effect to work on the current_item.
The page refreshes fine, and then I get an error as the highlighting
code is fired:
page[:current_item].visual_effect :highlight,
:startcolor => "#88ff88",
:endcolor => "#114411"
The error
2006 Aug 12
0
insert into database failing
hi all,
i am trying a little project based on the agile book''s shopping cart
example and have hit a problem. the inserts are failing when saving a
quote which contains line_items. the models are as follows
(quote_line_item is using single table inheritance):
class Quote < ActiveRecord::Base
has_many :quote_line_items
end
class LineItem < ActiveRecord::Base
end
class
2008 Feb 06
1
Try-Catch AWDWR P3.0, Sect9.2,Mid pg 121.
On page 118, file store_controller.rb, the "redirect_to_index" is added.
At mid page 120, that line is removed. When the browser is first sent to
the ":3000/store", the page displays properly. But when the Add to Cart
button is clicked, the browser displays the text of a try-catch block
(see below). There is no error message - the browser clearly sees text
to be displayed. If I
2007 Jan 26
0
Problems with assert_select in integration tests
I''ve been battling with assert_select in my integration tests for
several evenings now. I''m testing a multi-step form, and after
submitting the first step, my assert_selects fail on the attempts to
find the form on the next page. However if I print out the response
object, it has the exact text of what I''m trying to match.
Here is the complete integration test. The
2005 Dec 23
6
Agile book - test error
Hi all,
I get an error when testing the "store_controller_test.rb"
The troublesome line is in the test below:
def test_add_to_cart
get :add_to_cart, :id => @version_control_book.id <<<
cart = session[:cart]
assert_equal @version_control_book.price, cart.total_price
assert_redirected_to :action => ''display_cart''
follow_redirect
2006 Jun 19
12
AWDWR- Question
I''m having a particularly difficult time undersanding one lesson from
this book. This is in relation ot how one would grab "search"
parameters from web forms to search for records in the database. I
understand the :conditions part of find() but am confused on the code:
1- name = params[:name]
pos = Order.find(:all,
:conditions => ["name = ? and pay_type =
2006 May 06
0
RE: Rails Digest, Vol 20, Issue 156
I am looking for a ruby hosting service. Can any one recommend one for me.
-----Original Message-----
From: rails-request@lists.rubyonrails.org [mailto:rails-request@lists.rubyonrails.org]
Sent: Saturday, May 06, 2006 7:37 AM
To: rails@lists.rubyonrails.org
Subject: Rails Digest, Vol 20, Issue 156
Send Rails mailing list submissions to
rails@lists.rubyonrails.org
To subscribe or
2006 Jan 10
5
using dynamic element ids with visual_effect
Mike and I demo an Ajaxified version of the Depot application in the
Rails Studio. Part of the demo is a cart in the sidebar which updates
when you add a product to it. As well as updating the div, it also
highlights the most recently added link item. Right now, we do it with:
<script language="JavaScript">
function flash_cart(request) {
var id =
2006 Jul 31
4
RJS to find an element
I''m trying to implement a remove from cart method based on the
examples in the second edition Agile book. I have everything working
except for the RJS that removes items from the cart. Ideally what
I''d like to do is highlight an element that I am deleting only if
there is more than one of that particular item in the cart. If the
item deleted is the only of
2006 Apr 19
6
undefined method `create_table'' for #<LoginController:0x5e60
I am geeting the foolowing error.
undefined method `create_table'' for #<LoginController:0x5e60110>
I wrote the crete action in application controller.
I am coping ther total worng please help me!
class ApplicationController < ActionController::Base
model :cart
model :line_item
before_filter :authorize
def create
# create_table() yields a TableDefinition instance
2008 Jan 21
3
Story runner "macros"
I''ve gotten quite a bit out of Pat Maddox''s screencast
http://evang.eli.st/blog/2007/10/8/story-runner-top-to-bottom-screencast
One thing I''m not sure of is the feature where he writes things like:
When "I POST to", "/articles", :post => {:title => "Title", :body
=> "Body") do | path, params|
post_via_redirect
2005 Dec 14
9
Passing quantity in a shopping cart
I am using this line on my index.rhtml page to capture the quantity
required of a particular item for a basic shopping cart app:
<%= text_field ''line_item'', ''quantity'', {:size=>3} %> </td>
but my next screen (a cart screen) doesn''t reflect what was entered in
that text field when the item is added to the cart. That is,
2007 Sep 23
4
Story Runner, autoincrementing
I''ve written a story and I run into a snag.
I''ve written the create_forum method and told it to set the id to 1
but when it creates the forum the id is autoincremented.
My forums table is empty but the id keeps incrementing the newest record on
creation.
When I run the story it comes out as something like 59 which fails my story
because I''m asking it to look at /forums/1
2008 Mar 23
0
Committing a record update to the DB from a test
Hi all, I hope someone can help me with this.
I''m trying to write a test to see if my versioning (acts_as_versioned)
works. In order to do that, I have a class which inherits from
ActiveRecord:
class Order < ActiveRecord::Base
However, when I try to update or to create a new order within the
test, my changes do not affect the DB:
o = Order.create(:name =>
2005 Dec 18
1
assert_template fails?
Hi All,
I have a seemingly simple problem - but can''t figure out the problem. I
have a simple functional test like so:
def test_should_show_search_dropdown
get :index
assert_response :success
assert_template :search
end
Inspite of having search.rhtml in /app/views/layout, it fails with an error:
1) Error:
test_should_show_search_dropdown(SearchControllerTest):