fix card and section delete

This commit is contained in:
2023-01-05 21:34:14 +02:00
parent b28b28da02
commit db82bc5655
8 changed files with 42 additions and 6 deletions

View File

@ -12,6 +12,13 @@ module Merged
assert_raises(ActiveHash::RecordNotFound) {Card.find(id) }
end
def test_delete_index
section = first.section
index = first.index
first.delete_and_reset_index
assert_equal index , section.cards.second.index
end
def test_adds
card = Card.first.section.new_card
card.add_save!

View File

@ -12,7 +12,7 @@ module Merged
assert spacer
end
def test_has_sections
assert_equal SectionStyle.all.length , 9
assert SectionStyle.all.length > 9
end
def test_finds_section_by_template
spacer = SectionStyle.find_by_template("section_spacer")

View File

@ -1,7 +1,7 @@
require "test_helper"
module Merged
class SectionTest < ActiveSupport::TestCase
class SectionWriteTest < ActiveSupport::TestCase
include SectionHelper
include Cleanup
@ -23,6 +23,21 @@ module Merged
assert_raises(ActiveHash::RecordNotFound){Section.find(last_id) }
end
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
def test_destroys
last_id = last.id
last.delete