moving model spec to good old fashioed minitests
This commit is contained in:
19
test/models/merged/card_style_test.rb
Normal file
19
test/models/merged/card_style_test.rb
Normal file
@ -0,0 +1,19 @@
|
||||
require "test_helper"
|
||||
|
||||
module Merged
|
||||
class PageTest < ActiveSupport::TestCase
|
||||
def first_card
|
||||
CardStyle.all.first
|
||||
end
|
||||
|
||||
def test_has_all
|
||||
assert_equal CardStyle.all.length , 5
|
||||
end
|
||||
|
||||
def test_has_fields
|
||||
assert_equal first_card.fields.class , Array
|
||||
assert_equal first_card.fields.length , 2
|
||||
assert_equal first_card.fields.first , "header"
|
||||
end
|
||||
end
|
||||
end
|
33
test/models/merged/card_test.rb
Normal file
33
test/models/merged/card_test.rb
Normal file
@ -0,0 +1,33 @@
|
||||
require "git"
|
||||
require "test_helper"
|
||||
|
||||
module Merged
|
||||
class CardTest < ActiveSupport::TestCase
|
||||
include CardHelper
|
||||
|
||||
def test_has_all
|
||||
assert_equal 20 , Card.all.length
|
||||
end
|
||||
def test_has_cards
|
||||
assert_equal first.class , Card
|
||||
end
|
||||
def test_has_index
|
||||
assert_equal first.index , 1
|
||||
end
|
||||
|
||||
def test_first_has_no_previous
|
||||
assert_equal first.index , 1
|
||||
assert_nil first.previous_card
|
||||
end
|
||||
def test_first_has_next
|
||||
assert_equal first.next_card.index , 2
|
||||
end
|
||||
|
||||
def test_create_new
|
||||
card = Card.new_card("card_normal_square" , 1 , 1)
|
||||
assert_equal card.index , 1
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
23
test/models/merged/card_write_test.rb
Normal file
23
test/models/merged/card_write_test.rb
Normal file
@ -0,0 +1,23 @@
|
||||
require "git"
|
||||
require "test_helper"
|
||||
|
||||
module Merged
|
||||
class CardWriteTest < ActiveSupport::TestCase
|
||||
include CardHelper
|
||||
include Cleanup
|
||||
|
||||
def test_deletes
|
||||
id = first.id
|
||||
first.delete
|
||||
assert_raises(ActiveHash::RecordNotFound) {Card.find(id) }
|
||||
end
|
||||
|
||||
def test_destroys
|
||||
id = first.id
|
||||
first.delete
|
||||
Card.reload
|
||||
assert_raises(ActiveHash::RecordNotFound) {Card.find(id) }
|
||||
end
|
||||
|
||||
end
|
||||
end
|
28
test/models/merged/image_test.rb
Normal file
28
test/models/merged/image_test.rb
Normal file
@ -0,0 +1,28 @@
|
||||
require "test_helper"
|
||||
|
||||
module Merged
|
||||
class ImageTest < ActiveSupport::TestCase
|
||||
|
||||
def first
|
||||
Image.first
|
||||
end
|
||||
|
||||
def test_has_all
|
||||
assert_equal Image.all.length , 17
|
||||
end
|
||||
def test_has_image
|
||||
assert_equal first.class , Image
|
||||
end
|
||||
def test_has_name
|
||||
assert_equal first.name , "Common spaces"
|
||||
end
|
||||
def test_has_height_and_width
|
||||
assert_equal first.height , 300
|
||||
assert_equal first.width , 560
|
||||
end
|
||||
def test_aspect
|
||||
assert_equal first.aspect_ratio , [13,7]
|
||||
end
|
||||
|
||||
end
|
||||
end
|
23
test/models/merged/option_definition_test.rb
Normal file
23
test/models/merged/option_definition_test.rb
Normal file
@ -0,0 +1,23 @@
|
||||
require "test_helper"
|
||||
|
||||
module Merged
|
||||
class OptionDefinitionTest < ActiveSupport::TestCase
|
||||
|
||||
def first
|
||||
OptionDefinition.first
|
||||
end
|
||||
|
||||
def test_has_first
|
||||
assert_equal OptionDefinition.first.class , OptionDefinition
|
||||
end
|
||||
def test_there_options
|
||||
assert_equal OptionDefinition.all.length , 18
|
||||
end
|
||||
def test_has_option_objects
|
||||
assert_equal first.class , OptionDefinition
|
||||
end
|
||||
def test_has_values
|
||||
assert_equal first.values.class , Array
|
||||
end
|
||||
end
|
||||
end
|
21
test/models/merged/page_style_test.rb
Normal file
21
test/models/merged/page_style_test.rb
Normal file
@ -0,0 +1,21 @@
|
||||
require "test_helper"
|
||||
|
||||
module Merged
|
||||
class PageTest < ActiveSupport::TestCase
|
||||
def first
|
||||
PageStyle.all.first
|
||||
end
|
||||
|
||||
def test_finds_stye
|
||||
spacer = PageStyle.find_by_type("page")
|
||||
assert spacer
|
||||
end
|
||||
|
||||
def test_has_sections
|
||||
assert_equal PageStyle.all.length , 1
|
||||
end
|
||||
def test_Spacer_has_no_fields
|
||||
assert first.description
|
||||
end
|
||||
end
|
||||
end
|
38
test/models/merged/page_test.rb
Normal file
38
test/models/merged/page_test.rb
Normal file
@ -0,0 +1,38 @@
|
||||
require "test_helper"
|
||||
|
||||
module Merged
|
||||
class PageTest < ActiveSupport::TestCase
|
||||
|
||||
def index
|
||||
Page.find_by_name('index')
|
||||
end
|
||||
|
||||
def test_all
|
||||
assert_equal 2 , Page.all.length
|
||||
end
|
||||
def test_creates_page
|
||||
name = "randomname"
|
||||
page = Page.new_page( name)
|
||||
assert_equal page.name , name
|
||||
end
|
||||
|
||||
def test_has_type
|
||||
assert_equal index.type , "page"
|
||||
end
|
||||
|
||||
def test_has_index_page
|
||||
assert_equal index.class , Page
|
||||
end
|
||||
def test_has_sections
|
||||
assert_equal index.sections.length , 10
|
||||
end
|
||||
def test_has_section_array
|
||||
assert_equal index.sections.first.class , Section
|
||||
end
|
||||
def test_has_section_indexes
|
||||
index.sections.each_with_index do |section, index|
|
||||
assert_equal section.index , index + 1 # because we have human index
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
40
test/models/merged/page_write_test.rb
Normal file
40
test/models/merged/page_write_test.rb
Normal file
@ -0,0 +1,40 @@
|
||||
require "test_helper"
|
||||
|
||||
module Merged
|
||||
class PageWriteTests < ActiveSupport::TestCase
|
||||
include Cleanup
|
||||
|
||||
def index
|
||||
Page.find_by_name('index')
|
||||
end
|
||||
|
||||
def test_deletes
|
||||
id = index.id
|
||||
index.delete
|
||||
assert_raises(ActiveHash::RecordNotFound){Page.find(id) }
|
||||
end
|
||||
def test_destroys
|
||||
id = index.id
|
||||
index.destroy
|
||||
Section.reload
|
||||
assert_raises(ActiveHash::RecordNotFound){Page.find(id) }
|
||||
end
|
||||
def test_destroys_sections
|
||||
id = index.sections.first.id
|
||||
index.destroy
|
||||
Section.reload
|
||||
assert_raises(ActiveHash::RecordNotFound){Page.find(id) }
|
||||
end
|
||||
def test_creates_simple_section
|
||||
s = index.new_section("section_spacer")
|
||||
assert s
|
||||
assert_equal s.template , "section_spacer"
|
||||
end
|
||||
def test_creates_section_with_right_index
|
||||
should_be = index.sections.last.index + 1
|
||||
s = index.new_section("section_spacer")
|
||||
assert_equal s.index , should_be
|
||||
end
|
||||
|
||||
end
|
||||
end
|
26
test/models/merged/section_style_test.rb
Normal file
26
test/models/merged/section_style_test.rb
Normal file
@ -0,0 +1,26 @@
|
||||
require "test_helper"
|
||||
|
||||
module Merged
|
||||
class SectionStyleTest < ActiveSupport::TestCase
|
||||
|
||||
def first_section
|
||||
SectionStyle.all.first
|
||||
end
|
||||
|
||||
def test_finds_stye
|
||||
spacer = SectionStyle.find_by_template("section_spacer")
|
||||
assert spacer
|
||||
end
|
||||
def test_has_sections
|
||||
assert_equal SectionStyle.all.length , 7
|
||||
end
|
||||
def test_finds_section_by_template
|
||||
spacer = SectionStyle.find_by_template("section_spacer")
|
||||
assert spacer
|
||||
end
|
||||
def test_Spacer_has_no_fields
|
||||
spacer = SectionStyle.find_by_template("section_spacer")
|
||||
assert_nil spacer.fields
|
||||
end
|
||||
end
|
||||
end
|
46
test/models/merged/section_test.rb
Normal file
46
test/models/merged/section_test.rb
Normal file
@ -0,0 +1,46 @@
|
||||
require "test_helper"
|
||||
|
||||
module Merged
|
||||
class SectionTest < ActiveSupport::TestCase
|
||||
include SectionHelper
|
||||
|
||||
def test_has_all
|
||||
assert_equal Section.all.length , 14
|
||||
end
|
||||
def test_has_index_page
|
||||
assert_equal last.class , Section
|
||||
end
|
||||
def test_has_index
|
||||
assert_equal last.index , 10
|
||||
end
|
||||
def test_has_cards
|
||||
assert_equal last.cards.length , 5
|
||||
end
|
||||
def test_has_cards_array
|
||||
assert_equal last.cards.class , ActiveHash::Relation
|
||||
end
|
||||
def test_has_options
|
||||
assert_equal last.options.class , Hash
|
||||
assert_equal first.options.length , 4
|
||||
end
|
||||
def test_has_option_definitions
|
||||
assert_equal last.option_definitions.class , Array
|
||||
assert_equal last.option_definitions.length , 4
|
||||
assert_equal last.option_definitions.second.class , OptionDefinition
|
||||
assert_equal last.option_definitions.second.name , "handler"
|
||||
end
|
||||
def test_last_has_previous
|
||||
assert_equal last.previous_section.index , 9
|
||||
end
|
||||
def test_first_has_no_previous
|
||||
assert_equal first.index , 1
|
||||
assert_nil first.previous_section
|
||||
end
|
||||
def test_first_has_next
|
||||
assert_equal first.next_section.index , 2
|
||||
end
|
||||
def test_last_has_no_next
|
||||
assert_nil last.next_section
|
||||
end
|
||||
end
|
||||
end
|
40
test/models/merged/section_write_test.rb
Normal file
40
test/models/merged/section_write_test.rb
Normal file
@ -0,0 +1,40 @@
|
||||
require "test_helper"
|
||||
|
||||
module Merged
|
||||
class SectionTest < 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
|
||||
|
||||
def test_destroys
|
||||
last_id = last.id
|
||||
last.destroy
|
||||
Section.reload
|
||||
assert_raises(ActiveHash::RecordNotFound){Section.find(last_id) }
|
||||
end
|
||||
def test_destroys_cards
|
||||
card_id = last.cards.first.id
|
||||
last.destroy
|
||||
Section.reload
|
||||
assert_raises(ActiveHash::RecordNotFound){Card.find(card_id) }
|
||||
end
|
||||
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user