govuk_content_models 42.0.0 → 42.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/app/traits/attachable.rb +2 -2
- data/govuk_content_models.gemspec +1 -2
- data/lib/govuk_content_models/version.rb +1 -1
- metadata +3 -83
- data/test/fixtures/uploads/image.jpg +0 -0
- data/test/models/action_test.rb +0 -13
- data/test/models/artefact_action_test.rb +0 -130
- data/test/models/artefact_external_link_test.rb +0 -32
- data/test/models/artefact_test.rb +0 -482
- data/test/models/business_support/business_size_test.rb +0 -25
- data/test/models/business_support/business_type_test.rb +0 -25
- data/test/models/business_support/location_test.rb +0 -25
- data/test/models/business_support/purpose_test.rb +0 -29
- data/test/models/business_support/sector_test.rb +0 -25
- data/test/models/business_support/stage_test.rb +0 -25
- data/test/models/business_support/support_type_test.rb +0 -25
- data/test/models/business_support_edition_test.rb +0 -282
- data/test/models/campaign_edition_test.rb +0 -91
- data/test/models/completed_transaction_edition_test.rb +0 -56
- data/test/models/downtime_test.rb +0 -93
- data/test/models/edition_scheduled_for_publishing_test.rb +0 -91
- data/test/models/edition_test.rb +0 -1185
- data/test/models/help_page_edition_test.rb +0 -43
- data/test/models/licence_edition_test.rb +0 -105
- data/test/models/local_service_test.rb +0 -6
- data/test/models/local_transaction_edition_test.rb +0 -37
- data/test/models/overview_dashboard_test.rb +0 -46
- data/test/models/parted_test.rb +0 -26
- data/test/models/prerendered_entity_tests.rb +0 -46
- data/test/models/rendered_manual_test.rb +0 -10
- data/test/models/simple_smart_answer_edition_test.rb +0 -211
- data/test/models/simple_smart_answer_node_test.rb +0 -134
- data/test/models/simple_smart_answer_option_test.rb +0 -97
- data/test/models/time_zone_test.rb +0 -48
- data/test/models/transaction_edition_test.rb +0 -36
- data/test/models/travel_advice_edition_test.rb +0 -469
- data/test/models/user_test.rb +0 -155
- data/test/models/video_edition_test.rb +0 -64
- data/test/models/workflow_test.rb +0 -498
- data/test/test_helper.rb +0 -61
- data/test/traits/attachable_test.rb +0 -244
- data/test/validators/link_validator_test.rb +0 -86
- data/test/validators/safe_html_validator_test.rb +0 -83
- data/test/validators/slug_validator_test.rb +0 -109
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class BusinessSupport::BusinessSizeTest < ActiveSupport::TestCase
|
4
|
-
setup do
|
5
|
-
@charity = BusinessSupport::BusinessSize.create(name: "Under 10", slug: "under-10")
|
6
|
-
end
|
7
|
-
|
8
|
-
test "should validate presence of name" do
|
9
|
-
refute BusinessSupport::BusinessSize.new(slug: "under-10").valid?
|
10
|
-
end
|
11
|
-
|
12
|
-
test "should validate uniqueness of name" do
|
13
|
-
another_type = BusinessSupport::BusinessSize.new(name: "Under 10", slug: "under-10")
|
14
|
-
refute another_type.valid?, "should validate uniqueness of name."
|
15
|
-
end
|
16
|
-
|
17
|
-
test "should validate presence of slug" do
|
18
|
-
refute BusinessSupport::BusinessSize.new(name: "Under 10").valid?
|
19
|
-
end
|
20
|
-
|
21
|
-
test "should validate uniqueness of slug" do
|
22
|
-
another_type = BusinessSupport::BusinessSize.new(name: "Under 10", slug: "under-10")
|
23
|
-
refute another_type.valid?, "should validate uniqueness of slug."
|
24
|
-
end
|
25
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class BusinessSupport::BusinessTypeTest < ActiveSupport::TestCase
|
4
|
-
setup do
|
5
|
-
@charity = BusinessSupport::BusinessType.create(name: "Charity", slug: "charity")
|
6
|
-
end
|
7
|
-
|
8
|
-
test "should validate presence of name" do
|
9
|
-
refute BusinessSupport::BusinessType.new(slug: "charity").valid?
|
10
|
-
end
|
11
|
-
|
12
|
-
test "should validate uniqueness of name" do
|
13
|
-
another_type = BusinessSupport::BusinessType.new(name: "Charity", slug: "charity")
|
14
|
-
refute another_type.valid?, "should validate uniqueness of name."
|
15
|
-
end
|
16
|
-
|
17
|
-
test "should validate presence of slug" do
|
18
|
-
refute BusinessSupport::BusinessType.new(name: "Charity").valid?
|
19
|
-
end
|
20
|
-
|
21
|
-
test "should validate uniqueness of slug" do
|
22
|
-
another_type = BusinessSupport::BusinessType.new(name: "Charity", slug: "charity")
|
23
|
-
refute another_type.valid?, "should validate uniqueness of slug."
|
24
|
-
end
|
25
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class BusinessSupport::LocationTest < ActiveSupport::TestCase
|
4
|
-
setup do
|
5
|
-
@region = BusinessSupport::Location.create(name: "Ecclefechan", slug: "ecclefechan")
|
6
|
-
end
|
7
|
-
|
8
|
-
test "should validates presence of name" do
|
9
|
-
refute BusinessSupport::Location.new(slug: "ecclefechan").valid?
|
10
|
-
end
|
11
|
-
|
12
|
-
test "should validate uniqueness of name" do
|
13
|
-
another_scheme = BusinessSupport::Location.new(name: "Ecclefechan", slug: "ecclefechan")
|
14
|
-
refute another_scheme.valid?, "should validate uniqueness of name."
|
15
|
-
end
|
16
|
-
|
17
|
-
test "should validate presence of slug" do
|
18
|
-
refute BusinessSupport::Location.new(name: "Ecclefechan").valid?
|
19
|
-
end
|
20
|
-
|
21
|
-
test "should validate uniqueness of slug" do
|
22
|
-
another_scheme = BusinessSupport::Location.new(name: "Ecclefechan", slug: "ecclefechan")
|
23
|
-
refute another_scheme.valid?, "should validate uniqueness of slug"
|
24
|
-
end
|
25
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class BusinessSupport::PurposeTest < ActiveSupport::TestCase
|
4
|
-
setup do
|
5
|
-
@purpose = BusinessSupport::Purpose.create(name: "Setting up your business",
|
6
|
-
slug: "setting-up-your-business")
|
7
|
-
end
|
8
|
-
|
9
|
-
test "should validates presence of name" do
|
10
|
-
refute BusinessSupport::Purpose.new(slug: "setting-up-your-business").valid?
|
11
|
-
end
|
12
|
-
|
13
|
-
test "should validate uniqueness of name" do
|
14
|
-
another_purpose = BusinessSupport::Purpose.new(name: "Setting up your business",
|
15
|
-
slug: "setting-up-your-business")
|
16
|
-
refute another_purpose.valid?, "should validate uniqueness of name."
|
17
|
-
end
|
18
|
-
|
19
|
-
test "should validates presence of slug" do
|
20
|
-
refute BusinessSupport::Purpose.new(name: "Setting up your business").valid?
|
21
|
-
end
|
22
|
-
|
23
|
-
test "should validate uniqueness of slug" do
|
24
|
-
another_scheme = BusinessSupport::Purpose.new(name: "Setting up your business",
|
25
|
-
slug: "setting-up-your-business")
|
26
|
-
refute another_scheme.valid?, "should validate uniqueness of name."
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class BusinessSupport::SectorTest < ActiveSupport::TestCase
|
4
|
-
setup do
|
5
|
-
@sector = BusinessSupport::Sector.create(name: "Manufacturing", slug: "manufacturing")
|
6
|
-
end
|
7
|
-
|
8
|
-
test "should validates presence of name" do
|
9
|
-
refute BusinessSupport::Sector.new(slug: "manufacturing").valid?
|
10
|
-
end
|
11
|
-
|
12
|
-
test "should validate uniqueness of name" do
|
13
|
-
another_scheme = BusinessSupport::Sector.new(name: "Manufacturing", slug: "manufacturing")
|
14
|
-
refute another_scheme.valid?, "should validate uniqueness of name."
|
15
|
-
end
|
16
|
-
|
17
|
-
test "should validates presence of slug" do
|
18
|
-
refute BusinessSupport::Sector.new(name: "Manufacturing").valid?
|
19
|
-
end
|
20
|
-
|
21
|
-
test "should validate uniqueness of slug" do
|
22
|
-
another_scheme = BusinessSupport::Sector.new(name: "Manufacturing", slug: "manufacturing")
|
23
|
-
refute another_scheme.valid?, "should validate uniqueness of name."
|
24
|
-
end
|
25
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class BusinessSupport::StageTest < ActiveSupport::TestCase
|
4
|
-
setup do
|
5
|
-
@stage = BusinessSupport::Stage.create(name: "Finance", slug: "finance")
|
6
|
-
end
|
7
|
-
|
8
|
-
test "should validates presence of name" do
|
9
|
-
refute BusinessSupport::Stage.new(slug: "finance").valid?
|
10
|
-
end
|
11
|
-
|
12
|
-
test "should validate uniqueness of name" do
|
13
|
-
another_scheme = BusinessSupport::Stage.new(name: "Finance", slug: "finance")
|
14
|
-
refute another_scheme.valid?, "should validate uniqueness of name."
|
15
|
-
end
|
16
|
-
|
17
|
-
test "should validates presence of slug" do
|
18
|
-
refute BusinessSupport::Stage.new(name: "Finance").valid?
|
19
|
-
end
|
20
|
-
|
21
|
-
test "should validate uniqueness of slug" do
|
22
|
-
another_scheme = BusinessSupport::Stage.new(name: "Finance", slug: "finance")
|
23
|
-
refute another_scheme.valid?, "should validate uniqueness of name."
|
24
|
-
end
|
25
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class BusinessSupport::SupportTypeTest < ActiveSupport::TestCase
|
4
|
-
setup do
|
5
|
-
@type = BusinessSupport::SupportType.create(name: "Loan", slug: "loan")
|
6
|
-
end
|
7
|
-
|
8
|
-
test "should validates presence of name" do
|
9
|
-
refute BusinessSupport::SupportType.new(slug: "short-term-loan").valid?
|
10
|
-
end
|
11
|
-
|
12
|
-
test "should validate uniqueness of name" do
|
13
|
-
another_scheme = BusinessSupport::SupportType.new(name: "Loan", slug: "short-term-loan")
|
14
|
-
refute another_scheme.valid?, "should validate uniqueness of name."
|
15
|
-
end
|
16
|
-
|
17
|
-
test "should validates presence of slug" do
|
18
|
-
refute BusinessSupport::SupportType.new(name: "Loan").valid?
|
19
|
-
end
|
20
|
-
|
21
|
-
test "should validate uniqueness of slug" do
|
22
|
-
another_scheme = BusinessSupport::SupportType.new(name: "Loan", slug: "loan")
|
23
|
-
refute another_scheme.valid?, "should validate uniqueness of name."
|
24
|
-
end
|
25
|
-
end
|
@@ -1,282 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require_relative "../test_helper"
|
3
|
-
|
4
|
-
class BusinessSupportEditionTest < ActiveSupport::TestCase
|
5
|
-
def setup
|
6
|
-
@artefact = FactoryGirl.create(:artefact)
|
7
|
-
end
|
8
|
-
|
9
|
-
should "have custom fields" do
|
10
|
-
support = FactoryGirl.create(
|
11
|
-
:business_support_edition,
|
12
|
-
panopticon_id: @artefact.id,
|
13
|
-
short_description: "The short description",
|
14
|
-
body: "The body",
|
15
|
-
eligibility: "The eligibility",
|
16
|
-
evaluation: "The evaluation",
|
17
|
-
additional_information: "The additional information",
|
18
|
-
min_value: 1000,
|
19
|
-
max_value: 3000,
|
20
|
-
max_employees: 2000,
|
21
|
-
organiser: "The business support people",
|
22
|
-
continuation_link: "http://www.gov.uk",
|
23
|
-
will_continue_on: "The GOVUK website",
|
24
|
-
contact_details: "123 The Street, Townsville, UK. 07324 123456",
|
25
|
-
priority: 2,
|
26
|
-
area_gss_codes: %w(G123 G345 G45 G9),
|
27
|
-
locations: %w(scotland england),
|
28
|
-
sectors: %w(education manufacturing),
|
29
|
-
support_types: %w(grant loan),
|
30
|
-
start_date: Date.parse("1 Jan 2000"),
|
31
|
-
end_date: Date.parse("1 Jan 2020"),
|
32
|
-
)
|
33
|
-
|
34
|
-
support.business_sizes << "up-to-249"
|
35
|
-
support.business_types << "charity"
|
36
|
-
support.purposes << "making-the-most-of-the-internet"
|
37
|
-
support.stages << "start-up"
|
38
|
-
|
39
|
-
assert_equal "The short description", support.short_description
|
40
|
-
assert_equal "The body", support.body
|
41
|
-
assert_equal "The eligibility", support.eligibility
|
42
|
-
assert_equal "The evaluation", support.evaluation
|
43
|
-
assert_equal "The additional information", support.additional_information
|
44
|
-
assert_equal 1000, support.min_value
|
45
|
-
assert_equal 3000, support.max_value
|
46
|
-
assert_equal 2000, support.max_employees
|
47
|
-
assert_equal "The business support people", support.organiser
|
48
|
-
assert_equal "http://www.gov.uk", support.continuation_link
|
49
|
-
assert_equal "The GOVUK website", support.will_continue_on
|
50
|
-
assert_equal "123 The Street, Townsville, UK. 07324 123456", support.contact_details
|
51
|
-
|
52
|
-
assert_equal 2, support.priority
|
53
|
-
|
54
|
-
assert_equal ["G123","G345","G45","G9"], support.area_gss_codes
|
55
|
-
assert_equal ["up-to-249"], support.business_sizes
|
56
|
-
assert_equal ["charity"], support.business_types
|
57
|
-
assert_equal ["scotland", "england"], support.locations
|
58
|
-
assert_equal ["making-the-most-of-the-internet"], support.purposes
|
59
|
-
assert_equal ["education", "manufacturing"], support.sectors
|
60
|
-
assert_equal ["start-up"], support.stages
|
61
|
-
assert_equal ["grant", "loan"], support.support_types
|
62
|
-
assert_equal Date.parse("1 Jan 2000"), support.start_date
|
63
|
-
assert_equal Date.parse("1 Jan 2020"), support.end_date
|
64
|
-
end
|
65
|
-
|
66
|
-
should "not allow max_value to be less than min_value" do
|
67
|
-
support = FactoryGirl.create(
|
68
|
-
:business_support_edition,
|
69
|
-
panopticon_id: @artefact.id,
|
70
|
-
)
|
71
|
-
support.min_value = 100
|
72
|
-
support.max_value = 50
|
73
|
-
|
74
|
-
refute support.valid?
|
75
|
-
end
|
76
|
-
|
77
|
-
context "numeric field validations" do
|
78
|
-
# https://github.com/mongoid/mongoid/issues/1735 Really Mongoid‽
|
79
|
-
[
|
80
|
-
:min_value,
|
81
|
-
:max_value,
|
82
|
-
:max_employees,
|
83
|
-
].each do |field|
|
84
|
-
should "require an integer #{field}" do
|
85
|
-
@support = FactoryGirl.build(:business_support_edition)
|
86
|
-
[
|
87
|
-
'sadfsadf',
|
88
|
-
'100,000',
|
89
|
-
1.23,
|
90
|
-
].each do |value|
|
91
|
-
@support.send("#{field}=", value)
|
92
|
-
refute @support.valid?
|
93
|
-
assert_equal 1, @support.errors[field].count
|
94
|
-
end
|
95
|
-
|
96
|
-
@support.send("#{field}=", "100")
|
97
|
-
@support.save!
|
98
|
-
s = BusinessSupportEdition.find(@support.id)
|
99
|
-
assert_equal 100, s.send(field)
|
100
|
-
|
101
|
-
@support.send("#{field}=", "")
|
102
|
-
@support.save!
|
103
|
-
s = BusinessSupportEdition.find(@support.id)
|
104
|
-
assert_equal nil, s.send(field)
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
context "continuation_link validation" do
|
110
|
-
|
111
|
-
setup do
|
112
|
-
@bs = FactoryGirl.create(
|
113
|
-
:business_support_edition,
|
114
|
-
panopticon_id: @artefact.id,
|
115
|
-
)
|
116
|
-
end
|
117
|
-
|
118
|
-
should "not validate the continuation link when blank" do
|
119
|
-
@bs.continuation_link = ""
|
120
|
-
assert @bs.valid?, "continuation link validation should not be triggered when the field is blank"
|
121
|
-
end
|
122
|
-
should "fail validation when the continuation link has an invalid url" do
|
123
|
-
@bs.continuation_link = "not&a+valid_url"
|
124
|
-
assert !@bs.valid?, "continuation link validation should fail with a invalid url"
|
125
|
-
end
|
126
|
-
should "pass validation with a valid continuation link url" do
|
127
|
-
@bs.continuation_link = "http://www.hmrc.gov.uk"
|
128
|
-
assert @bs.valid?, "continuation_link validation should pass with a valid url"
|
129
|
-
end
|
130
|
-
|
131
|
-
end
|
132
|
-
|
133
|
-
should "clone extra fields when cloning edition" do
|
134
|
-
support = FactoryGirl.create(
|
135
|
-
:business_support_edition,
|
136
|
-
:panopticon_id => @artefact.id,
|
137
|
-
:state => "published",
|
138
|
-
:short_description => "Short description of support format",
|
139
|
-
:body => "Body to be cloned",
|
140
|
-
:min_value => 1,
|
141
|
-
:max_value => 2,
|
142
|
-
:max_employees => 3,
|
143
|
-
:organiser => "Organiser to be cloned",
|
144
|
-
:eligibility => "Eligibility to be cloned",
|
145
|
-
:evaluation => "Evaluation to be cloned",
|
146
|
-
:additional_information => "Additional info to be cloned",
|
147
|
-
:will_continue_on => "Continuation text to be cloned",
|
148
|
-
:continuation_link => "http://www.gov.uk",
|
149
|
-
:contact_details => "Contact details to be cloned",
|
150
|
-
:priority => 2,
|
151
|
-
:area_gss_codes => ['G123','G9999'],
|
152
|
-
:business_sizes => ['up-to-249'],
|
153
|
-
:locations => ['london'],
|
154
|
-
:purposes => ['start-up'],
|
155
|
-
:sectors => ['agriculture','manufacturing'],
|
156
|
-
:stages => ['grow-and-sustain'],
|
157
|
-
:support_types => ['grant','loan'],
|
158
|
-
:start_date => 1.year.ago(Date.today),
|
159
|
-
:end_date => 1.year.since(Date.today),
|
160
|
-
)
|
161
|
-
|
162
|
-
new_support = support.build_clone
|
163
|
-
|
164
|
-
assert_equal support.short_description, new_support.short_description
|
165
|
-
assert_equal support.body, new_support.body
|
166
|
-
assert_equal support.min_value, new_support.min_value
|
167
|
-
assert_equal support.max_value, new_support.max_value
|
168
|
-
assert_equal support.max_employees, new_support.max_employees
|
169
|
-
assert_equal support.organiser, new_support.organiser
|
170
|
-
assert_equal support.eligibility, new_support.eligibility
|
171
|
-
assert_equal support.evaluation, new_support.evaluation
|
172
|
-
assert_equal support.additional_information, new_support.additional_information
|
173
|
-
assert_equal support.will_continue_on, new_support.will_continue_on
|
174
|
-
assert_equal support.continuation_link, new_support.continuation_link
|
175
|
-
assert_equal support.contact_details, new_support.contact_details
|
176
|
-
|
177
|
-
assert_equal support.priority, new_support.priority
|
178
|
-
assert_equal support.area_gss_codes, new_support.area_gss_codes
|
179
|
-
assert_equal support.business_sizes, new_support.business_sizes
|
180
|
-
assert_equal support.locations, new_support.locations
|
181
|
-
assert_equal support.purposes, new_support.purposes
|
182
|
-
assert_equal support.sectors, new_support.sectors
|
183
|
-
assert_equal support.stages, new_support.stages
|
184
|
-
assert_equal support.support_types, new_support.support_types
|
185
|
-
assert_equal support.start_date, new_support.start_date
|
186
|
-
assert_equal support.end_date, new_support.end_date
|
187
|
-
end
|
188
|
-
|
189
|
-
context "for facets" do
|
190
|
-
setup do
|
191
|
-
@e1 = FactoryGirl.create(
|
192
|
-
:business_support_edition,
|
193
|
-
:area_gss_codes => ['G2345', 'G1234'],
|
194
|
-
:business_sizes => ['1', 'up-to-1000000'],
|
195
|
-
:locations => ['narnia'],
|
196
|
-
:purposes => ['world-domination'],
|
197
|
-
:sectors => ['agriculture', 'healthcare'],
|
198
|
-
:stages => ['pivoting'],
|
199
|
-
:support_types => ['award', 'grant', 'loan'],
|
200
|
-
)
|
201
|
-
@e2 = FactoryGirl.create(
|
202
|
-
:business_support_edition,
|
203
|
-
:area_gss_codes => ['G1212', 'G1234', 'G999'],
|
204
|
-
:business_sizes => ['1', 'up-to-1000000'],
|
205
|
-
:locations => ['hades', 'narnia'],
|
206
|
-
:purposes => ['business-growth-and-expansion'],
|
207
|
-
:sectors => ['education', 'healthcare'],
|
208
|
-
:stages => ['start-up', 'pivoting'],
|
209
|
-
:support_types => ['grant', 'loan', 'equity'],
|
210
|
-
)
|
211
|
-
@e3 = FactoryGirl.create(
|
212
|
-
:business_support_edition,
|
213
|
-
:area_gss_codes => ['G1234'],
|
214
|
-
:business_sizes => ['up-to-249', 'up-to-1000000'],
|
215
|
-
:locations => ['hades', 'chicken-town'],
|
216
|
-
:purposes => ['making-the-most-of-the-internet'],
|
217
|
-
:sectors => ['utilities'],
|
218
|
-
:stages => ['start-up'],
|
219
|
-
:support_types => ['grant'],
|
220
|
-
)
|
221
|
-
end
|
222
|
-
|
223
|
-
should "only return editions matching the facet values provided" do
|
224
|
-
editions = BusinessSupportEdition.for_facets({
|
225
|
-
:purposes => 'business-growth-and-expansion',
|
226
|
-
:support_types => 'equity',
|
227
|
-
})
|
228
|
-
assert_equal [@e2], editions
|
229
|
-
editions = BusinessSupportEdition.for_facets({
|
230
|
-
:business_sizes => '1,up-to-1000000',
|
231
|
-
:locations => 'narnia',
|
232
|
-
})
|
233
|
-
assert_equal [@e1, @e2], editions
|
234
|
-
end
|
235
|
-
should "support searching with all the facet values" do
|
236
|
-
editions = BusinessSupportEdition.for_facets({
|
237
|
-
:area_gss_codes => 'G1234',
|
238
|
-
:business_sizes => 'up-to-1000000',
|
239
|
-
:locations => 'narnia,hades,chicken-town',
|
240
|
-
:purposes => 'business-growth-and-expansion,making-the-most-of-the-internet,world-domination',
|
241
|
-
:sectors => 'agriculture,healthcare,utilities',
|
242
|
-
:stages => 'pivoting,start-up',
|
243
|
-
:support_types => 'award,grant,loan',
|
244
|
-
})
|
245
|
-
assert_equal [@e1, @e2, @e3], editions
|
246
|
-
end
|
247
|
-
should "return nothing where no facet values match" do
|
248
|
-
editions = BusinessSupportEdition.for_facets({
|
249
|
-
:business_sizes => 'up-to-a-bizillion',
|
250
|
-
:locations => 'ecclefechan',
|
251
|
-
})
|
252
|
-
assert_empty editions
|
253
|
-
end
|
254
|
-
end
|
255
|
-
|
256
|
-
context "scheme dates" do
|
257
|
-
should "should have year with 4 digits length" do
|
258
|
-
invalid_edition = FactoryGirl.build(
|
259
|
-
:business_support_edition,
|
260
|
-
start_date: Date.new(99, 12, 31),
|
261
|
-
end_date: Date.new(99, 12, 31),
|
262
|
-
)
|
263
|
-
|
264
|
-
refute invalid_edition.valid?
|
265
|
-
|
266
|
-
edition_errors = invalid_edition.errors.full_messages
|
267
|
-
assert_includes edition_errors, "Start date year must be 4 digits"
|
268
|
-
assert_includes edition_errors, "End date year must be 4 digits"
|
269
|
-
end
|
270
|
-
|
271
|
-
should "have start date earlier than end date" do
|
272
|
-
invalid_edition = FactoryGirl.build(
|
273
|
-
:business_support_edition,
|
274
|
-
start_date: 1.week.ago,
|
275
|
-
end_date: 2.weeks.ago,
|
276
|
-
)
|
277
|
-
|
278
|
-
refute invalid_edition.valid?
|
279
|
-
assert_includes invalid_edition.errors.full_messages, "Start date can't be later than end date"
|
280
|
-
end
|
281
|
-
end
|
282
|
-
end
|