public
Last active

  • Download Gist
application.html.erb
HTML+ERB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
<!DOCTYPE html>
<html>
<head>
<title>Pragprog Books Online Store</title>
<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tag %>
</head>
<body class="<%= controller.controller_name %>">
<div id="banner">
<%= image_tag("logo.png") %>
<%= @page_title || "Pragmatic Bookshelf" %>
</div>
<div id="columns">
<div id="side">
<% if @cart %>
<%= hidden_div_if(@cart.line_items.empty?, id: 'cart') do %>
<%= render @cart %>
<% end %>
<% end %>
 
<%= DateTime.now %>
<% if (session[:counter] > 5) %>
<%= session[:counter] %>
<% end %>
 
<ul>
<li><a href="http://www..../home">Home</a></li>
<li><a href="http://www..../faq">Quations</a></li>
<li><a href="http://www..../news">News</a></li>
<li><a href="http://www..../contact">Contact</a></li>
</ul>
 
</div>
 
<div id="main">
<%= yield %>
</div>
</div>
</body>
</html>
gistfile1.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
Error:
test_update_shipping_date(UserStoriesTest):
ActionView::Template::Error: undefined method `>' for nil:NilClass
 
require 'test_helper'
 
class UserStoriesTest < ActionDispatch::IntegrationTest
fixtures :products
fixtures :pay_types
fixtures :orders
 
test "purchase_product" do
LineItem.delete_all
Order.delete_all
ruby_book = products(:ruby)
 
get "/"
assert_response :success
assert_template "index"
 
xml_http_request :post, '/line_items', product_id: ruby_book.id
assert_response :success
 
cart = Cart.find(session[:cart_id])
assert_equal 1, cart.line_items.size
assert_equal ruby_book, cart.line_items[0].product
 
get "/orders/new"
assert_response :success
assert_template "new"
 
post_via_redirect "/orders",
order: { name: "Dmitriy Borowskiy",
address: "MyText",
email: "d.borowskij@gmail.com",
pay_type_id: pay_types(:one).id }
 
assert_response :success
assert_template "index"
cart = Cart.find(session[:cart_id])
assert_equal 0, cart.line_items.size
 
orders = Order.all
assert_equal 1, orders.size
order = orders[0]
 
assert_equal "Dmitriy Borowskiy", order.name
assert_equal "MyText", order.address
assert_equal "d.borowskij@.gmail.com", order.email
assert_equal "Check", order.pay_type.name
 
assert_equal 1, order.line_items.size
line_item = order.line_items[0]
assert_equal ruby_book, line_item.product
 
mail = ActionMailer::Base.deliveries.last
assert_equal ["d.borowskij@gmail.com"], mail.to
assert_equal 'Dmitriy Borowskiy <d.borowskij@gmail.com>', mail[:from].value
assert_equal 'Подтверждение заказа в магазине', mail.subject
 
end
 
test "update_shipping_date" do
order_before = orders(:one)
 
get "/orders/1/edit"
assert_response :success
assert_template "edit"
 
post_via_redirect "/orders",
order: { name: "Dmitriy Borowskiy",
address: "MyText",
email: "d.borowskij@gmail.com",
pay_type_id: pay_types(:one).id,
ship_date: "2013-04-04" }
 
assert_template 'show'
assert_equal order_before.ship_date, order.ship_date
end
end
 
orders.yml
 
 
one:
id: 1
name: Dmitriy Borowskiy
address: MyText
email: d.borowskij@gmail.com
ship_date:
 
 

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.