2022-12-23 13:40:05 +01:00
|
|
|
require "test_helper"
|
|
|
|
|
|
|
|
module Merged
|
2023-01-05 20:34:14 +01:00
|
|
|
class SectionWriteTest < ActiveSupport::TestCase
|
2022-12-23 13:40:05 +01:00
|
|
|
include SectionHelper
|
|
|
|
include Cleanup
|
|
|
|
|
|
|
|
def test_creates_new_spacer_section
|
|
|
|
s = Section.new_section("section_spacer" , 1 , 1)
|
|
|
|
assert_equal s.template , "section_spacer"
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_creates_card_with_right_index
|
|
|
|
s = Section.find_by_template("section_cards")
|
|
|
|
length = s.cards.length
|
|
|
|
c = s.new_card
|
|
|
|
assert_equal c.index , length + 1
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_deletes
|
|
|
|
last_id = last.id
|
|
|
|
last.delete
|
|
|
|
assert_raises(ActiveHash::RecordNotFound){Section.find(last_id) }
|
|
|
|
end
|
|
|
|
|
2023-01-05 20:34:14 +01:00
|
|
|
def test_delete_index_section
|
|
|
|
eleven = Section.find 11
|
|
|
|
page = eleven.page
|
|
|
|
eleven.delete
|
|
|
|
assert_equal eleven.index + 1 , page.sections.second.index
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_delete_index_page
|
|
|
|
eleven = Section.find 11
|
|
|
|
page = eleven.page
|
|
|
|
index = eleven.index
|
|
|
|
eleven.delete_and_reset_index
|
|
|
|
assert_equal index , page.sections.second.index
|
|
|
|
end
|
|
|
|
|
2022-12-23 13:40:05 +01:00
|
|
|
def test_destroys
|
|
|
|
last_id = last.id
|
2022-12-26 17:09:31 +01:00
|
|
|
last.delete
|
2022-12-23 13:40:05 +01:00
|
|
|
Section.reload
|
|
|
|
assert_raises(ActiveHash::RecordNotFound){Section.find(last_id) }
|
|
|
|
end
|
|
|
|
def test_destroys_cards
|
|
|
|
card_id = last.cards.first.id
|
2022-12-26 17:09:31 +01:00
|
|
|
last.delete
|
2022-12-23 13:40:05 +01:00
|
|
|
Section.reload
|
|
|
|
assert_raises(ActiveHash::RecordNotFound){Card.find(card_id) }
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|