diff --git a/test/dummy/app/controllers/application_controller.rb b/test/dummy/app/controllers/application_controller.rb index 32bb34d..f65796a 100644 --- a/test/dummy/app/controllers/application_controller.rb +++ b/test/dummy/app/controllers/application_controller.rb @@ -2,4 +2,7 @@ class ApplicationController < ActionController::Base def authenticate_member! true end + def current_member + Member.new(email: "torsten@villataika.fi") + end end diff --git a/test/dummy/app/models/member.rb b/test/dummy/app/models/member.rb new file mode 100644 index 0000000..42509a1 --- /dev/null +++ b/test/dummy/app/models/member.rb @@ -0,0 +1,6 @@ +class Member + attr_reader :email + def initialize(hash) + @email = hash[:email] + end +end diff --git a/test/integration/cards_test.rb b/test/integration/cards_test.rb new file mode 100644 index 0000000..f56f913 --- /dev/null +++ b/test/integration/cards_test.rb @@ -0,0 +1,28 @@ +require "test_helper" + +class CardsTest < ActionDispatch::IntegrationTest + include Devise::Test::IntegrationHelpers # Rails >= 5 + + def go_edit + visit "/merged/sections/11" + find_link("View and Edit Cards").click + end + def test_edit_is + go_edit + assert_equal page.current_path , "/merged/sections/11/cards" + end + + def test_update + go_edit + within("#card_6") do + find_button("Update" , match: :first).click + end + end + + def _test_update + go_edit + within(".content_update") do + find_button("Update").click + end + end +end diff --git a/test/integration/navigation_test.rb b/test/integration/navigation_test.rb deleted file mode 100644 index ebbc098..0000000 --- a/test/integration/navigation_test.rb +++ /dev/null @@ -1,7 +0,0 @@ -require "test_helper" - -class NavigationTest < ActionDispatch::IntegrationTest - # test "the truth" do - # assert true - # end -end diff --git a/test/integration/sections_test.rb b/test/integration/sections_test.rb new file mode 100644 index 0000000..2f960c8 --- /dev/null +++ b/test/integration/sections_test.rb @@ -0,0 +1,36 @@ +require "test_helper" + +class SectionsTest < ActionDispatch::IntegrationTest + include Devise::Test::IntegrationHelpers # Rails >= 5 + + def go_index + visit "/merged/pages" + click_on ("index") + end + def go_edit + go_index + within("#section_31") do + find_link("Edit").click + end + end + def test_edit_is + go_index + within("#section_31") do + assert has_link?("Edit") + end + end + + def test_edit_ok + go_index + within("#section_31") do + find_link("Edit").click + end + end + + def test_update + go_edit + within(".content_update") do + find_button("Update").click + end + end +end diff --git a/test/test_helper.rb b/test/test_helper.rb index 120f7ae..4f0da57 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -3,4 +3,21 @@ ENV["RAILS_ENV"] = "test" require_relative "../test/dummy/config/environment" require "rails/test_help" +require 'capybara/rails' +require 'capybara/minitest' +require "devise" +require "devise/test/integration_helpers" +class ActionDispatch::IntegrationTest + #include Devise::Test::IntegrationHelpers + #include FactoryBot::Syntax::Methods + # Make the Capybara DSL available in all integration tests + include Capybara::DSL + include Capybara::Minitest::Assertions #### THIS LINE changes minitest assert_select ##### + + # Reset sessions and driver between tests + teardown do + Capybara.reset_sessions! + Capybara.use_default_driver + end +end