added virtuals

This commit is contained in:
2023-05-10 15:14:06 +01:00
parent 793e944b5f
commit 8f1fe8c7c2
27 changed files with 297 additions and 15 deletions

View 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

View File

@@ -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

View File

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

View File

@@ -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

View File

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

View 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