First commit

This commit is contained in:
Vikram Rangnekar
2019-03-24 09:57:29 -04:00
commit b9d38a5e9d
153 changed files with 18120 additions and 0 deletions

View File

@ -0,0 +1,5 @@
require "test_helper"
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
driven_by :selenium, using: :chrome, screen_size: [1400, 1400]
end

View File

View 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
View File

11
example/test/fixtures/customers.yml vendored Normal file
View 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
View File

11
example/test/fixtures/products.yml vendored Normal file
View 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
View 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

View File

View File

View File

View File

View File

@ -0,0 +1,7 @@
require 'test_helper'
class CustomerTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

View File

@ -0,0 +1,7 @@
require 'test_helper'
class ProductTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

View File

@ -0,0 +1,7 @@
require 'test_helper'
class UserTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

View File

View 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

View 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