added virtuals
This commit is contained in:
48
test/controllers/virtuals_controller_test.rb
Normal file
48
test/controllers/virtuals_controller_test.rb
Normal file
@@ -0,0 +1,48 @@
|
||||
require "test_helper"
|
||||
|
||||
class VirtualsControllerTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
@virtual = virtuals(:one)
|
||||
end
|
||||
|
||||
test "should get index" do
|
||||
get virtuals_url
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get new" do
|
||||
get new_virtual_url
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should create virtual" do
|
||||
assert_difference("Virtual.count") do
|
||||
post virtuals_url, params: { virtual: { destination: @virtual.destination, email: @virtual.email } }
|
||||
end
|
||||
|
||||
assert_redirected_to virtual_url(Virtual.last)
|
||||
end
|
||||
|
||||
test "should show virtual" do
|
||||
get virtual_url(@virtual)
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get edit" do
|
||||
get edit_virtual_url(@virtual)
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should update virtual" do
|
||||
patch virtual_url(@virtual), params: { virtual: { destination: @virtual.destination, email: @virtual.email } }
|
||||
assert_redirected_to virtual_url(@virtual)
|
||||
end
|
||||
|
||||
test "should destroy virtual" do
|
||||
assert_difference("Virtual.count", -1) do
|
||||
delete virtual_url(@virtual)
|
||||
end
|
||||
|
||||
assert_redirected_to virtuals_url
|
||||
end
|
||||
end
|
||||
4
test/fixtures/domains.yml
vendored
4
test/fixtures/domains.yml
vendored
@@ -1,7 +1,7 @@
|
||||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
domain: MyString
|
||||
domain: example.net
|
||||
|
||||
two:
|
||||
domain: MyString
|
||||
domain: example.org
|
||||
|
||||
20
test/fixtures/users.yml
vendored
20
test/fixtures/users.yml
vendored
@@ -1,11 +1,11 @@
|
||||
# Read about fixtures at https://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
|
||||
# # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
#
|
||||
one: {}
|
||||
# column: value
|
||||
#
|
||||
two: {}
|
||||
# column: value
|
||||
# # 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
|
||||
|
||||
9
test/fixtures/virtuals.yml
vendored
Normal file
9
test/fixtures/virtuals.yml
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
email: MyString
|
||||
destination: MyString
|
||||
|
||||
two:
|
||||
email: MyString
|
||||
destination: MyString
|
||||
@@ -8,11 +8,11 @@ class DomainTest < ActiveSupport::TestCase
|
||||
|
||||
test "domain can no tbe duplicated" do
|
||||
@d1 = Domain.new
|
||||
@d1.name = "example.com"
|
||||
@d1.domain = "example.com"
|
||||
assert @d1.save
|
||||
|
||||
@d2 = Domain.new
|
||||
@d2.name = "example.com"
|
||||
@d2.domain = "example.com"
|
||||
assert !@d2.save
|
||||
end
|
||||
end
|
||||
|
||||
7
test/models/virtual_test.rb
Normal file
7
test/models/virtual_test.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
require "test_helper"
|
||||
|
||||
class VirtualTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
43
test/system/virtuals_test.rb
Normal file
43
test/system/virtuals_test.rb
Normal file
@@ -0,0 +1,43 @@
|
||||
require "application_system_test_case"
|
||||
|
||||
class VirtualsTest < ApplicationSystemTestCase
|
||||
setup do
|
||||
@virtual = virtuals(:one)
|
||||
end
|
||||
|
||||
test "visiting the index" do
|
||||
visit virtuals_url
|
||||
assert_selector "h1", text: "Virtuals"
|
||||
end
|
||||
|
||||
test "should create virtual" do
|
||||
visit virtuals_url
|
||||
click_on "New virtual"
|
||||
|
||||
fill_in "Destination", with: @virtual.destination
|
||||
fill_in "Email", with: @virtual.email
|
||||
click_on "Create Virtual"
|
||||
|
||||
assert_text "Virtual was successfully created"
|
||||
click_on "Back"
|
||||
end
|
||||
|
||||
test "should update Virtual" do
|
||||
visit virtual_url(@virtual)
|
||||
click_on "Edit this virtual", match: :first
|
||||
|
||||
fill_in "Destination", with: @virtual.destination
|
||||
fill_in "Email", with: @virtual.email
|
||||
click_on "Update Virtual"
|
||||
|
||||
assert_text "Virtual was successfully updated"
|
||||
click_on "Back"
|
||||
end
|
||||
|
||||
test "should destroy Virtual" do
|
||||
visit virtual_url(@virtual)
|
||||
click_on "Destroy this virtual", match: :first
|
||||
|
||||
assert_text "Virtual was successfully destroyed"
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user