merged/test/models/section_write_test.rb

56 lines
1.4 KiB
Ruby
Raw Normal View History

require "test_helper"
module Merged
2023-01-05 20:34:14 +01:00
class SectionWriteTest < ActiveSupport::TestCase
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
def test_destroys
last_id = last.id
last.delete
Section.reload
assert_raises(ActiveHash::RecordNotFound){Section.find(last_id) }
end
def test_destroys_cards
card_id = last.cards.first.id
last.delete
Section.reload
assert_raises(ActiveHash::RecordNotFound){Card.find(card_id) }
end
end
end