first commit
This commit is contained in:
5
test/application_system_test_case.rb
Normal file
5
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
|
||||
13
test/channels/application_cable/connection_test.rb
Normal file
13
test/channels/application_cable/connection_test.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
require "test_helper"
|
||||
|
||||
module ApplicationCable
|
||||
class ConnectionTest < ActionCable::Connection::TestCase
|
||||
# test "connects with cookies" do
|
||||
# cookies.signed[:user_id] = 42
|
||||
#
|
||||
# connect
|
||||
#
|
||||
# assert_equal connection.user_id, "42"
|
||||
# end
|
||||
end
|
||||
end
|
||||
0
test/controllers/.keep
Normal file
0
test/controllers/.keep
Normal file
48
test/controllers/suggestions_controller_test.rb
Normal file
48
test/controllers/suggestions_controller_test.rb
Normal file
@@ -0,0 +1,48 @@
|
||||
require "test_helper"
|
||||
|
||||
class SuggestionsControllerTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
@suggestion = suggestions(:one)
|
||||
end
|
||||
|
||||
test "should get index" do
|
||||
get suggestions_url
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get new" do
|
||||
get new_suggestion_url
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should create suggestion" do
|
||||
assert_difference("Suggestion.count") do
|
||||
post suggestions_url, params: { suggestion: { body: @suggestion.body, sent: @suggestion.sent, subject: @suggestion.subject } }
|
||||
end
|
||||
|
||||
assert_redirected_to suggestion_url(Suggestion.last)
|
||||
end
|
||||
|
||||
test "should show suggestion" do
|
||||
get suggestion_url(@suggestion)
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get edit" do
|
||||
get edit_suggestion_url(@suggestion)
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should update suggestion" do
|
||||
patch suggestion_url(@suggestion), params: { suggestion: { body: @suggestion.body, sent: @suggestion.sent, subject: @suggestion.subject } }
|
||||
assert_redirected_to suggestion_url(@suggestion)
|
||||
end
|
||||
|
||||
test "should destroy suggestion" do
|
||||
assert_difference("Suggestion.count", -1) do
|
||||
delete suggestion_url(@suggestion)
|
||||
end
|
||||
|
||||
assert_redirected_to suggestions_url
|
||||
end
|
||||
end
|
||||
0
test/fixtures/files/.keep
vendored
Normal file
0
test/fixtures/files/.keep
vendored
Normal file
11
test/fixtures/suggestions.yml
vendored
Normal file
11
test/fixtures/suggestions.yml
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
subject: MyString
|
||||
body: MyText
|
||||
sent: false
|
||||
|
||||
two:
|
||||
subject: MyString
|
||||
body: MyText
|
||||
sent: false
|
||||
0
test/helpers/.keep
Normal file
0
test/helpers/.keep
Normal file
0
test/integration/.keep
Normal file
0
test/integration/.keep
Normal file
0
test/mailers/.keep
Normal file
0
test/mailers/.keep
Normal file
0
test/models/.keep
Normal file
0
test/models/.keep
Normal file
7
test/models/suggestion_test.rb
Normal file
7
test/models/suggestion_test.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
require "test_helper"
|
||||
|
||||
class SuggestionTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
0
test/system/.keep
Normal file
0
test/system/.keep
Normal file
45
test/system/suggestions_test.rb
Normal file
45
test/system/suggestions_test.rb
Normal file
@@ -0,0 +1,45 @@
|
||||
require "application_system_test_case"
|
||||
|
||||
class SuggestionsTest < ApplicationSystemTestCase
|
||||
setup do
|
||||
@suggestion = suggestions(:one)
|
||||
end
|
||||
|
||||
test "visiting the index" do
|
||||
visit suggestions_url
|
||||
assert_selector "h1", text: "Suggestions"
|
||||
end
|
||||
|
||||
test "should create suggestion" do
|
||||
visit suggestions_url
|
||||
click_on "New suggestion"
|
||||
|
||||
fill_in "Body", with: @suggestion.body
|
||||
check "Sent" if @suggestion.sent
|
||||
fill_in "Subject", with: @suggestion.subject
|
||||
click_on "Create Suggestion"
|
||||
|
||||
assert_text "Suggestion was successfully created"
|
||||
click_on "Back"
|
||||
end
|
||||
|
||||
test "should update Suggestion" do
|
||||
visit suggestion_url(@suggestion)
|
||||
click_on "Edit this suggestion", match: :first
|
||||
|
||||
fill_in "Body", with: @suggestion.body
|
||||
check "Sent" if @suggestion.sent
|
||||
fill_in "Subject", with: @suggestion.subject
|
||||
click_on "Update Suggestion"
|
||||
|
||||
assert_text "Suggestion was successfully updated"
|
||||
click_on "Back"
|
||||
end
|
||||
|
||||
test "should destroy Suggestion" do
|
||||
visit suggestion_url(@suggestion)
|
||||
click_on "Destroy this suggestion", match: :first
|
||||
|
||||
assert_text "Suggestion was successfully destroyed"
|
||||
end
|
||||
end
|
||||
15
test/test_helper.rb
Normal file
15
test/test_helper.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
ENV["RAILS_ENV"] ||= "test"
|
||||
require_relative "../config/environment"
|
||||
require "rails/test_help"
|
||||
|
||||
module ActiveSupport
|
||||
class TestCase
|
||||
# Run tests in parallel with specified workers
|
||||
parallelize(workers: :number_of_processors)
|
||||
|
||||
# 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
|
||||
end
|
||||
Reference in New Issue
Block a user