2022-12-23 16:37:49 +01:00
|
|
|
require "test_helper"
|
|
|
|
|
|
|
|
class PageTest < ActionDispatch::IntegrationTest
|
|
|
|
include Devise::Test::IntegrationHelpers # Rails >= 5
|
|
|
|
|
|
|
|
def test_returns_success
|
|
|
|
visit "/merged/pages"
|
|
|
|
assert_title page, "Dummy"
|
|
|
|
assert_text page, "Pages"
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_has_an_index_page
|
|
|
|
visit "merged/pages"
|
|
|
|
click_on ("index")
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_edit_page_works
|
|
|
|
visit "/merged/pages"
|
|
|
|
within("#index") do
|
|
|
|
click_on ("Edit")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class PagesWrite < ActionDispatch::IntegrationTest
|
|
|
|
include Devise::Test::IntegrationHelpers # Rails >= 5
|
|
|
|
include Merged::Cleanup
|
|
|
|
def test_edit_page_works
|
|
|
|
visit "/merged/pages/2"
|
|
|
|
within(".options") do
|
|
|
|
click_on ("Update")
|
|
|
|
end
|
|
|
|
end
|
2022-12-27 15:47:57 +01:00
|
|
|
def test_new_handles_noinput
|
2022-12-23 16:37:49 +01:00
|
|
|
visit "/merged/pages"
|
|
|
|
within(".new_page") do
|
|
|
|
click_on ("New Page")
|
|
|
|
end
|
2022-12-26 19:29:43 +01:00
|
|
|
assert_equal "/merged/pages" , current_path
|
2022-12-23 16:37:49 +01:00
|
|
|
end
|
2022-12-27 15:47:57 +01:00
|
|
|
def test_new_page_works_with_name
|
2022-12-23 16:37:49 +01:00
|
|
|
visit "/merged/pages"
|
|
|
|
within(".new_page") do
|
|
|
|
fill_in 'Name', with: 'New Page'
|
|
|
|
click_on ("New Page")
|
|
|
|
end
|
2022-12-26 19:29:43 +01:00
|
|
|
assert_equal "/merged/sections/41/select_template" , current_path
|
|
|
|
end
|
|
|
|
|
2022-12-27 15:47:57 +01:00
|
|
|
def test_new_blog_works_with_name
|
|
|
|
visit "/merged/pages"
|
|
|
|
within(".new_page") do
|
|
|
|
fill_in 'Name', with: 'New Page'
|
|
|
|
click_on ("New Blog")
|
|
|
|
end
|
|
|
|
assert_equal "/merged/sections/41" , current_path
|
|
|
|
end
|
|
|
|
|
2022-12-26 19:29:43 +01:00
|
|
|
def test_delete_works
|
|
|
|
id = Merged::Page.first.id
|
|
|
|
visit merged.page_sections_path(id)
|
|
|
|
within(".delete_page") do
|
|
|
|
click_on ("Delete Page")
|
|
|
|
end
|
|
|
|
assert_equal "/merged/pages" , current_path
|
|
|
|
assert_raise(ActiveHash::RecordNotFound) {visit merged.page_path(id)}
|
2022-12-23 16:37:49 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|