First commit
This commit is contained in:
5
example/test/application_system_test_case.rb
Normal file
5
example/test/application_system_test_case.rb
Normal file
@ -0,0 +1,5 @@
|
||||
require "test_helper"
|
||||
|
||||
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
|
||||
driven_by :selenium, using: :chrome, screen_size: [1400, 1400]
|
||||
end
|
0
example/test/controllers/.keep
Normal file
0
example/test/controllers/.keep
Normal file
48
example/test/controllers/products_controller_test.rb
Normal file
48
example/test/controllers/products_controller_test.rb
Normal file
@ -0,0 +1,48 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ProductsControllerTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
@product = products(:one)
|
||||
end
|
||||
|
||||
test "should get index" do
|
||||
get products_url
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get new" do
|
||||
get new_product_url
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should create product" do
|
||||
assert_difference('Product.count') do
|
||||
post products_url, params: { product: { description: @product.description, name: @product.name, price: @product.price } }
|
||||
end
|
||||
|
||||
assert_redirected_to product_url(Product.last)
|
||||
end
|
||||
|
||||
test "should show product" do
|
||||
get product_url(@product)
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get edit" do
|
||||
get edit_product_url(@product)
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should update product" do
|
||||
patch product_url(@product), params: { product: { description: @product.description, name: @product.name, price: @product.price } }
|
||||
assert_redirected_to product_url(@product)
|
||||
end
|
||||
|
||||
test "should destroy product" do
|
||||
assert_difference('Product.count', -1) do
|
||||
delete product_url(@product)
|
||||
end
|
||||
|
||||
assert_redirected_to products_url
|
||||
end
|
||||
end
|
0
example/test/fixtures/.keep
vendored
Normal file
0
example/test/fixtures/.keep
vendored
Normal file
11
example/test/fixtures/customers.yml
vendored
Normal file
11
example/test/fixtures/customers.yml
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
# This model initially had no columns defined. If you add columns to the
|
||||
# model remove the '{}' from the fixture names and add the columns immediately
|
||||
# below each fixture, per the syntax in the comments below
|
||||
#
|
||||
one: {}
|
||||
# column: value
|
||||
#
|
||||
two: {}
|
||||
# column: value
|
0
example/test/fixtures/files/.keep
vendored
Normal file
0
example/test/fixtures/files/.keep
vendored
Normal file
11
example/test/fixtures/products.yml
vendored
Normal file
11
example/test/fixtures/products.yml
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
name: MyString
|
||||
description: MyText
|
||||
price: 9.99
|
||||
|
||||
two:
|
||||
name: MyString
|
||||
description: MyText
|
||||
price: 9.99
|
11
example/test/fixtures/users.yml
vendored
Normal file
11
example/test/fixtures/users.yml
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
# This model initially had no columns defined. If you add columns to the
|
||||
# model remove the '{}' from the fixture names and add the columns immediately
|
||||
# below each fixture, per the syntax in the comments below
|
||||
#
|
||||
one: {}
|
||||
# column: value
|
||||
#
|
||||
two: {}
|
||||
# column: value
|
0
example/test/helpers/.keep
Normal file
0
example/test/helpers/.keep
Normal file
0
example/test/integration/.keep
Normal file
0
example/test/integration/.keep
Normal file
0
example/test/mailers/.keep
Normal file
0
example/test/mailers/.keep
Normal file
0
example/test/models/.keep
Normal file
0
example/test/models/.keep
Normal file
7
example/test/models/customer_test.rb
Normal file
7
example/test/models/customer_test.rb
Normal file
@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class CustomerTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
7
example/test/models/product_test.rb
Normal file
7
example/test/models/product_test.rb
Normal file
@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ProductTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
7
example/test/models/user_test.rb
Normal file
7
example/test/models/user_test.rb
Normal file
@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class UserTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
0
example/test/system/.keep
Normal file
0
example/test/system/.keep
Normal file
47
example/test/system/products_test.rb
Normal file
47
example/test/system/products_test.rb
Normal file
@ -0,0 +1,47 @@
|
||||
require "application_system_test_case"
|
||||
|
||||
class ProductsTest < ApplicationSystemTestCase
|
||||
setup do
|
||||
@product = products(:one)
|
||||
end
|
||||
|
||||
test "visiting the index" do
|
||||
visit products_url
|
||||
assert_selector "h1", text: "Products"
|
||||
end
|
||||
|
||||
test "creating a Product" do
|
||||
visit products_url
|
||||
click_on "New Product"
|
||||
|
||||
fill_in "Description", with: @product.description
|
||||
fill_in "Name", with: @product.name
|
||||
fill_in "Price", with: @product.price
|
||||
click_on "Create Product"
|
||||
|
||||
assert_text "Product was successfully created"
|
||||
click_on "Back"
|
||||
end
|
||||
|
||||
test "updating a Product" do
|
||||
visit products_url
|
||||
click_on "Edit", match: :first
|
||||
|
||||
fill_in "Description", with: @product.description
|
||||
fill_in "Name", with: @product.name
|
||||
fill_in "Price", with: @product.price
|
||||
click_on "Update Product"
|
||||
|
||||
assert_text "Product was successfully updated"
|
||||
click_on "Back"
|
||||
end
|
||||
|
||||
test "destroying a Product" do
|
||||
visit products_url
|
||||
page.accept_confirm do
|
||||
click_on "Destroy", match: :first
|
||||
end
|
||||
|
||||
assert_text "Product was successfully destroyed"
|
||||
end
|
||||
end
|
10
example/test/test_helper.rb
Normal file
10
example/test/test_helper.rb
Normal file
@ -0,0 +1,10 @@
|
||||
ENV['RAILS_ENV'] ||= 'test'
|
||||
require_relative '../config/environment'
|
||||
require 'rails/test_help'
|
||||
|
||||
class ActiveSupport::TestCase
|
||||
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
|
||||
fixtures :all
|
||||
|
||||
# Add more helper methods to be used by all tests here...
|
||||
end
|
Reference in New Issue
Block a user