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

@ -9,10 +9,11 @@
background: solid_blue
color: white
align: left
:updated_at: &1 2022-12-09 17:50:02.733622073 +02:00
:updated_at: 2023-01-05 21:33:46.577677395 +02:00
:section_id: 11
:index: 1
:image_id: 35
:updated_by: torsten@villataika.fi
- :header: Large
:text: The old four patient rooms are basically twice the size as the small. They
are large enough to be shared. The size is about 30m2 and the cost 240e. Like
@ -23,7 +24,7 @@
background: solid_blue
color: white
align: left
:updated_at: *1
:updated_at: &1 2022-12-09 17:50:02.733622073 +02:00
:section_id: 11
:index: 2
:image_id: 17
@ -129,6 +130,7 @@
:section_id: 13
:index: 4
:image_id:
:options: {}
- :id: 17
:header: Message
:text: ''

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