Skip to content

Instantly share code, notes, and snippets.

@dborovsky
Last active December 15, 2015 20:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dborovsky/5319125 to your computer and use it in GitHub Desktop.
Save dborovsky/5319125 to your computer and use it in GitHub Desktop.
<!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>
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:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment