2017-02-13 14:38:28 +01:00
|
|
|
require 'test_helper'
|
|
|
|
|
|
|
|
class SpaceTest < ActiveSupport::TestCase
|
2017-02-13 15:53:12 +01:00
|
|
|
bio_lab = {
|
2018-12-12 13:49:14 +01:00
|
|
|
name: 'Bio-lab',
|
|
|
|
description: 'An biological laboratory to experiment bio-technologies',
|
|
|
|
default_places: 5
|
2017-02-13 15:53:12 +01:00
|
|
|
}
|
|
|
|
|
2017-02-13 14:38:28 +01:00
|
|
|
test 'create a space' do
|
2017-02-13 15:53:12 +01:00
|
|
|
space = Space.create!(bio_lab)
|
2017-02-13 14:38:28 +01:00
|
|
|
assert_not_nil space
|
|
|
|
subtype = StatisticSubType.find_by(key: space.slug)
|
|
|
|
assert_not_nil subtype
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'update a space' do
|
|
|
|
new_name = 'Bio-tech lab'
|
2017-02-13 15:53:12 +01:00
|
|
|
space = Space.create!(bio_lab)
|
2018-12-12 13:49:14 +01:00
|
|
|
space.update_attributes(name: new_name)
|
2017-02-13 14:38:28 +01:00
|
|
|
subtype = StatisticSubType.find_by(key: space.slug)
|
|
|
|
assert_equal new_name, subtype.label
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'delete a space' do
|
2017-02-13 15:53:12 +01:00
|
|
|
space = Space.create!(bio_lab)
|
2017-02-13 14:38:28 +01:00
|
|
|
slug = space.slug
|
|
|
|
space.destroy!
|
|
|
|
assert_nil Space.find_by(slug: slug)
|
|
|
|
assert_nil StatisticSubType.find_by(key: slug)
|
|
|
|
end
|
|
|
|
end
|