govuk_content_models 37.0.0 → 38.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 509f173b9c1d06101cb2b41fb74ae031a30fd99e
4
- data.tar.gz: f2e8f1137985b74e33009062e68404774cc08be9
3
+ metadata.gz: 5df2ae51cb9c82fd594961e0d80a96d6ebe6bc0c
4
+ data.tar.gz: 48f4278dd4f2cea25927987c2e73beaf078274d1
5
5
  SHA512:
6
- metadata.gz: 19d98c962dcb6fcaf9bc02f4c083ede71233ef2fb2b94a350cca2165b9edab0933b67e9990194ce6008d48e1fbe26a33f99a95ee5bb60116349427edf0a592a7
7
- data.tar.gz: 3c873f461815c6b99b35675f6daf0446ffb64cbb0484f63768c0af40ab0b9d72a4d048567be3619efb1d813d279fe8a84fbaed5b74969395e13c80ee6a701cfb
6
+ metadata.gz: 086b090dfd1932c064b6ae360b84df33aead4ad44bd2ee4c4a107726c18db158553e872a65061d65544e7c89e7598b1b3f81caee933ab2d25967691c4ae7ce1d
7
+ data.tar.gz: 477ea838b3c2522868a69729af1ed696348890498233745563388d5ec77368d209e2d2cb4357b51c40cefc796b28f5b55a3acf0c985e049e4e589bcc3576e2ad
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 38.0.0
4
+
5
+ - Removed LocalInteraction model as this information is now obtained from Local
6
+ Links Manager [#389](https://github.com/alphagov/govuk_content_models/pull/389)
7
+
8
+ ## 37.0.0
9
+
10
+ - Removed old style (organ donor registration) promotion code [#387](https://github.com/alphagov/govuk_content_models/pull/387)
11
+
3
12
  ## 36.0.0
4
13
 
5
14
  - Remove fields from LocalAuthority
@@ -1,12 +1,9 @@
1
1
  require "csv"
2
- require "local_interaction"
3
2
  require "safe_html"
4
3
 
5
4
  class LocalAuthority
6
5
  include Mongoid::Document
7
6
 
8
- embeds_many :local_interactions
9
-
10
7
  field :name, type: String
11
8
  field :snac, type: String
12
9
  field :local_directgov_id, type: Integer
@@ -22,31 +19,4 @@ class LocalAuthority
22
19
  for_snacs([snac]).first
23
20
  end
24
21
 
25
- def provides_service?(lgsl_code, lgil_code = nil)
26
- interactions_for(lgsl_code, lgil_code).any?
27
- end
28
-
29
- def interactions_for(lgsl_code, lgil_code = nil)
30
- interactions = local_interactions.where(lgsl_code: lgsl_code)
31
- if lgil_code
32
- interactions.where(lgil_code: lgil_code)
33
- else
34
- interactions
35
- end
36
- end
37
-
38
- def preferred_interaction_for(lgsl_code, lgil_code = nil)
39
- interactions = local_interactions.where(lgsl_code: lgsl_code)
40
- if lgil_code
41
- interactions.where(lgil_code: lgil_code).first
42
- else
43
- interactions.excludes(
44
- lgil_code: LocalInteraction::LGIL_CODE_PROVIDING_INFORMATION
45
- ).order_by(lgil_code: :asc).first ||
46
- interactions.where(
47
- lgil_code: LocalInteraction::LGIL_CODE_PROVIDING_INFORMATION
48
- ).first
49
- end
50
- end
51
-
52
22
  end
@@ -19,11 +19,6 @@ class LocalService
19
19
  LocalService.where(lgsl_code: lgsl_code).first
20
20
  end
21
21
 
22
- def preferred_interaction(snac_or_snac_list, lgil_override = nil)
23
- provider = preferred_provider(snac_or_snac_list)
24
- provider && provider.preferred_interaction_for(lgsl_code, lgil_override)
25
- end
26
-
27
22
  def preferred_provider(snac_or_snac_list)
28
23
  snac_list = [*snac_or_snac_list]
29
24
  providers = LocalAuthority.for_snacs(snac_list)
@@ -31,8 +26,7 @@ class LocalService
31
26
  end
32
27
 
33
28
  def provided_by
34
- LocalAuthority.where("local_interactions.lgsl_code" => lgsl_code)
35
- .any_in(tier: providing_tier)
29
+ LocalAuthority.any_in(tier: providing_tier)
36
30
  end
37
31
 
38
32
  private
@@ -32,7 +32,7 @@ class LocalTransactionEdition < Edition
32
32
 
33
33
  def service_provided_by?(snac)
34
34
  authority = LocalAuthority.find_by_snac(snac)
35
- authority && authority.provides_service?(lgsl_code)
35
+ authority && service.provided_by.include?(authority)
36
36
  end
37
37
 
38
38
  def whole_body
@@ -216,13 +216,6 @@ FactoryGirl.define do
216
216
  tier "county"
217
217
  end
218
218
 
219
- factory :local_interaction do
220
- association :local_authority
221
- url "http://some.council.gov/do.html"
222
- sequence(:lgsl_code) {|n| 120 + n }
223
- lgil_code 0
224
- end
225
-
226
219
  factory :place_edition, parent: :edition, class: 'PlaceEdition' do
227
220
  title "Far far away"
228
221
  introduction "Test introduction"
@@ -2,23 +2,15 @@ module LocalServicesHelper
2
2
  def make_authority(tier, options)
3
3
  authority = FactoryGirl.create(:local_authority,
4
4
  snac: options[:snac], tier: tier)
5
- add_service_interaction(authority, options[:lgsl]) if options[:lgsl]
6
5
  authority
7
6
  end
8
7
 
9
- def add_service_interaction(existing_authority, lgsl_code)
10
- FactoryGirl.create(:local_interaction, local_authority: existing_authority,
11
- lgsl_code: lgsl_code)
12
- end
13
-
14
8
  def make_service(lgsl_code, providing_tier)
15
9
  LocalService.create!(lgsl_code: lgsl_code, providing_tier: providing_tier)
16
10
  end
17
11
 
18
- def make_authority_providing(lgsl_code)
19
- council = FactoryGirl.create(:local_authority, snac: "00AA", tier: "county")
20
- FactoryGirl.create(:local_interaction, local_authority: council,
21
- lgsl_code: lgsl_code)
12
+ def make_authority_providing(_lgsl_code, tier = 'county')
13
+ council = FactoryGirl.create(:local_authority, snac: "00AA", tier: tier)
22
14
  council
23
15
  end
24
16
  end
@@ -1,4 +1,4 @@
1
1
  module GovukContentModels
2
2
  # Changing this causes Jenkins to tag and release the gem into the wild
3
- VERSION = "37.0.0"
3
+ VERSION = "38.0.0"
4
4
  end
@@ -21,87 +21,4 @@ describe LocalAuthority do
21
21
  assert_equal "county", authority.tier
22
22
  assert_equal "http://example.gov/", authority.homepage_url
23
23
  end
24
-
25
- describe "validating local_interactions" do
26
- before :each do
27
- @authority = FactoryGirl.create(:local_authority)
28
- end
29
-
30
- it "should require a lgsl_code and lgil_code" do
31
- li = @authority.local_interactions.build
32
- refute li.valid?
33
- assert_equal ["can't be blank"], li.errors[:lgsl_code]
34
- assert_equal ["can't be blank"], li.errors[:lgil_code]
35
- end
36
-
37
- it "should not allow duplicate lgsl/lgil pairs" do
38
- li1 = @authority.local_interactions.create!(:lgsl_code => 42, :lgil_code => 8, :url => "http://www.example.com/one")
39
- li2 = @authority.local_interactions.build(:lgsl_code => 42, :lgil_code => 8, :url => "http://www.example.com/two")
40
-
41
- refute li2.valid?
42
- assert_equal ["is already taken"], li2.errors[:lgil_code]
43
-
44
- li2.lgil_code = 3
45
- assert li2.valid?
46
- end
47
-
48
- it "should only validate uniqueness within the authority" do
49
- authority2 = FactoryGirl.create(:local_authority)
50
- li1 = @authority.local_interactions.create!(:lgsl_code => 42, :lgil_code => 8, :url => "http://www.example.com/one")
51
- li2 = authority2.local_interactions.build(:lgsl_code => 42, :lgil_code => 8, :url => "http://www.example.com/two")
52
-
53
- assert li2.valid?
54
- end
55
- end
56
-
57
- describe "preferred_interaction_for" do
58
- before :each do
59
- @authority = FactoryGirl.create(:local_authority)
60
- @lgsl_code = "142"
61
- end
62
-
63
- describe "with no LIGL specified" do
64
- it "should return the lowest LGIL that's not 8" do
65
- @interaction1 = FactoryGirl.create(:local_interaction, :local_authority => @authority, :lgsl_code => @lgsl_code,
66
- :lgil_code => 12)
67
- @interaction2 = FactoryGirl.create(:local_interaction, :local_authority => @authority, :lgsl_code => @lgsl_code,
68
- :lgil_code => LocalInteraction::LGIL_CODE_PROVIDING_INFORMATION)
69
- @interaction3 = FactoryGirl.create(:local_interaction, :local_authority => @authority, :lgsl_code => @lgsl_code,
70
- :lgil_code => 9)
71
-
72
- assert_equal @interaction3, @authority.preferred_interaction_for(@lgsl_code)
73
- end
74
-
75
- it "should return LGIL 8 if there are no others" do
76
- @interaction2 = FactoryGirl.create(:local_interaction, :local_authority => @authority, :lgsl_code => @lgsl_code,
77
- :lgil_code => LocalInteraction::LGIL_CODE_PROVIDING_INFORMATION)
78
-
79
- assert_equal @interaction2, @authority.preferred_interaction_for(@lgsl_code)
80
- end
81
- end
82
-
83
- describe "with an LGIL specified" do
84
- it "should return the interaction for the specified LGIL" do
85
- @interaction1 = FactoryGirl.create(:local_interaction, :local_authority => @authority, :lgsl_code => @lgsl_code,
86
- :lgil_code => 12)
87
- @interaction2 = FactoryGirl.create(:local_interaction, :local_authority => @authority, :lgsl_code => @lgsl_code,
88
- :lgil_code => LocalInteraction::LGIL_CODE_PROVIDING_INFORMATION)
89
- @interaction3 = FactoryGirl.create(:local_interaction, :local_authority => @authority, :lgsl_code => @lgsl_code,
90
- :lgil_code => 9)
91
-
92
- assert_equal @interaction2, @authority.preferred_interaction_for(@lgsl_code, 8)
93
- end
94
-
95
- it "should return nil if there is no interaction with the specified LGIL" do
96
- @interaction1 = FactoryGirl.create(:local_interaction, :local_authority => @authority, :lgsl_code => @lgsl_code,
97
- :lgil_code => 12)
98
- @interaction2 = FactoryGirl.create(:local_interaction, :local_authority => @authority, :lgsl_code => @lgsl_code,
99
- :lgil_code => LocalInteraction::LGIL_CODE_PROVIDING_INFORMATION)
100
- @interaction3 = FactoryGirl.create(:local_interaction, :local_authority => @authority, :lgsl_code => @lgsl_code,
101
- :lgil_code => 9)
102
-
103
- assert_equal nil, @authority.preferred_interaction_for(@lgsl_code, 3)
104
- end
105
- end
106
- end
107
24
  end
@@ -20,141 +20,52 @@ class LocalServiceTest < ActiveSupport::TestCase
20
20
  tier: "county",
21
21
  snac: "AA00"
22
22
  )
23
- FactoryGirl.create(
24
- :local_interaction,
25
- local_authority: @county_council,
26
- lgsl_code: @lgsl_code,
27
- url: "http://some.county.council.gov/do-123.html"
28
- )
29
23
  @district_council = FactoryGirl.create(
30
24
  :local_authority,
31
25
  tier: "district",
32
26
  snac: "AA"
33
27
  )
34
- FactoryGirl.create(
35
- :local_interaction,
36
- local_authority: @district_council,
37
- lgsl_code: @lgsl_code,
38
- url: "http://some.district.council.gov/do-123.html"
39
- )
40
28
  @unitary_authority = FactoryGirl.create(
41
29
  :local_authority,
42
30
  tier: "unitary",
43
31
  snac: "BB00"
44
32
  )
45
- FactoryGirl.create(
46
- :local_interaction,
47
- local_authority: @unitary_authority,
48
- lgsl_code: @lgsl_code,
49
- url: "http://some.unitary.council.gov/do-123.html"
50
- )
51
33
  end
52
34
 
53
- test "should return county URL for county/UA service in county" do
54
- service = create_service_for_tiers(:county, :unitary)
55
- councils = [@county_council.snac, @district_council.snac]
56
- assert_equal "http://some.county.council.gov/do-123.html",
57
- service.preferred_interaction(councils).url
58
- end
35
+ test "should not list a county as providing a service for districts" do
36
+ service = create_service_for_tiers(:district, :unitary)
59
37
 
60
- test "should return UA URL for county/UA service in UA" do
61
- service = create_service_for_tiers(:county, :unitary)
62
- councils = [@unitary_authority.snac]
63
- assert_equal "http://some.unitary.council.gov/do-123.html",
64
- service.preferred_interaction(councils).url
38
+ refute_includes service.provided_by.map(&:snac), @county_council.snac
65
39
  end
66
40
 
67
- test "should return nil for county/UA service in district" do
41
+ test "should not list a district as providing a service for counties" do
68
42
  service = create_service_for_tiers(:county, :unitary)
69
- councils = [@district_council.snac]
70
- assert_nil service.preferred_interaction(councils)
71
- end
72
43
 
73
- test "should allow overriding returned LGIL" do
74
- FactoryGirl.create(:local_interaction,
75
- local_authority: @county_council,
76
- lgsl_code: @lgsl_code,
77
- lgil_code: 12,
78
- url: "http://some.county.council.gov/do-456.html"
79
- )
80
- service = create_service_for_tiers(:county, :unitary)
81
- councils = [@county_council.snac, @district_council.snac]
82
- assert_equal "http://some.county.council.gov/do-456.html",
83
- service.preferred_interaction(councils, 12).url
44
+ refute_includes service.provided_by.map(&:snac), @district_council.snac
84
45
  end
85
46
 
86
- test "should not list a county (in a UA) as providing a service it does not provide" do
47
+ test "should list a county as providing a service for counties and unitaries" do
87
48
  service = create_service_for_tiers(:county, :unitary)
88
- other_service = service.lgsl_code.to_i + 1
89
- FactoryGirl.create(
90
- :local_interaction,
91
- local_authority: @county_council,
92
- lgsl_code: other_service
93
- )
94
- authority = FactoryGirl.create(
95
- :local_authority,
96
- tier: "county",
97
- snac: "CC00"
98
- )
99
- FactoryGirl.create(
100
- :local_interaction,
101
- local_authority: authority,
102
- lgsl_code: other_service
103
- )
104
49
 
105
- refute_includes service.provided_by.map(&:snac), "CC00"
50
+ assert_includes service.provided_by.map(&:snac), @county_council.snac
106
51
  end
107
52
 
108
- test "should not list a UA as providing a service it does not provide" do
109
- service = create_service_for_tiers(:county, :unitary)
110
- other_service = service.lgsl_code.to_i + 1
111
- FactoryGirl.create(
112
- :local_interaction,
113
- local_authority: @county_council,
114
- lgsl_code: other_service
115
- )
116
- authority = FactoryGirl.create(
117
- :local_authority,
118
- tier: "unitary",
119
- snac: "CC01"
120
- )
121
- FactoryGirl.create(
122
- :local_interaction,
123
- local_authority: authority,
124
- lgsl_code: other_service
125
- )
53
+ test "should list a district as providing a service for districts and unitaries" do
54
+ service = create_service_for_tiers(:district, :unitary)
126
55
 
127
- refute_includes service.provided_by.map(&:snac), "CC01"
56
+ assert_includes service.provided_by.map(&:snac), @district_council.snac
128
57
  end
129
58
 
130
- test "should list a county (in a UA) that provides a service" do
59
+ test "should list a UA as providing a service for counties and unitaries" do
131
60
  service = create_service_for_tiers(:county, :unitary)
132
- assert_includes service.provided_by.map(&:snac), @county_council.snac
133
- end
134
61
 
135
- test "should list a UA that provides a service" do
136
- service = create_service_for_tiers(:county, :unitary)
137
62
  assert_includes service.provided_by.map(&:snac), @unitary_authority.snac
138
63
  end
139
64
 
140
- test "should return district URL for district/UA service in county/district" do
141
- service = create_service_for_tiers(:district, :unitary)
142
- councils = [@county_council.snac, @district_council.snac]
143
- assert_equal "http://some.district.council.gov/do-123.html",
144
- service.preferred_interaction(councils).url
145
- end
146
-
147
- test "should return UA URL for district/UA service in UA" do
148
- service = create_service_for_tiers(:district, :unitary)
149
- councils = [@unitary_authority.snac]
150
- assert_match "http://some.unitary.council.gov/do-123.html",
151
- service.preferred_interaction(councils).url
152
- end
65
+ test "should list a UA as providing a service for districts and unitaries" do
66
+ service = create_service_for_tiers(:county, :unitary)
153
67
 
154
- test "should return nil for district/UA service in county" do
155
- service = create_service_for_tiers(:district, :unitary)
156
- councils = [@county_council.snac]
157
- assert_nil service.preferred_interaction(councils)
68
+ assert_includes service.provided_by.map(&:snac), @unitary_authority.snac
158
69
  end
159
70
 
160
71
  test "should list only districts and UAs as providers" do
@@ -165,29 +76,6 @@ class LocalServiceTest < ActiveSupport::TestCase
165
76
  assert_includes providers.map(&:snac), @unitary_authority.snac
166
77
  end
167
78
 
168
- test "should return district URL for both-tier service in county/district" do
169
- service = create_service_for_tiers("district", "unitary", "county")
170
- councils = [@county_council.snac, @district_council.snac]
171
- url = service.preferred_interaction(councils).url
172
- assert_equal "http://some.district.council.gov/do-123.html", url
173
- end
174
-
175
- test "should return UA URL for both-tier service in UA" do
176
- service = create_service_for_tiers("district", "unitary", "county")
177
- councils = [@unitary_authority.snac]
178
- url = service.preferred_interaction(councils).url
179
- assert_equal "http://some.unitary.council.gov/do-123.html", url
180
- end
181
-
182
- # This shouldn't really ever happen and suggests that the data
183
- # is incorrect somehow, but we might as well fall back to county council
184
- test "should return county URL for both-tier service in county" do
185
- service = create_service_for_tiers("district", "unitary", "county")
186
- councils = [@county_council.snac]
187
- url = service.preferred_interaction(councils).url
188
- assert_equal "http://some.county.council.gov/do-123.html", url
189
- end
190
-
191
79
  test "should list all authorities providing a both-tier service" do
192
80
  service = create_service_for_tiers("district", "unitary", "county")
193
81
  make_authority("county", snac: "CC00", lgsl: 124)
@@ -11,25 +11,37 @@ class LocalTransactionEditionTest < ActiveSupport::TestCase
11
11
  @artefact = FactoryGirl.create(:artefact)
12
12
  end
13
13
 
14
- test "should report that an authority provides a service" do
14
+ test "should report that an authority provides a service if the snac references a real authority in the same tier" do
15
15
  bins_transaction = LocalTransactionEdition.new(
16
16
  lgsl_code: BINS,
17
17
  title: "Transaction",
18
18
  slug: "slug",
19
19
  panopticon_id: @artefact.id
20
20
  )
21
- county_council = make_authority_providing(BINS)
21
+ make_service(BINS, %w(county unitary))
22
+ county_council = make_authority('county', snac: '00PP')
22
23
  assert bins_transaction.service_provided_by?(county_council.snac)
23
24
  end
24
25
 
25
- test "should report that an authority does not provide a service" do
26
+ test "should report that an authority does not provide a service if the snac does not reference a real authority" do
26
27
  bins_transaction = LocalTransactionEdition.new(
27
28
  lgsl_code: BINS,
28
29
  title: "Transaction",
29
30
  slug: "slug",
30
31
  panopticon_id: @artefact.id
31
32
  )
32
- county_council = make_authority_providing(HOUSING_BENEFIT)
33
+ refute bins_transaction.service_provided_by?('No-Such-SNAC')
34
+ end
35
+
36
+ test "should report that an authority does not provide a service if the snac references a real authority in the wrong tier" do
37
+ bins_transaction = LocalTransactionEdition.new(
38
+ lgsl_code: BINS,
39
+ title: "Transaction",
40
+ slug: "slug",
41
+ panopticon_id: @artefact.id
42
+ )
43
+ make_service(BINS, %w(district unitary))
44
+ county_council = make_authority('county', snac: '00ZZ')
33
45
  refute bins_transaction.service_provided_by?(county_council.snac)
34
46
  end
35
47
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_content_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 37.0.0
4
+ version: 38.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Battley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-27 00:00:00.000000000 Z
11
+ date: 2016-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bson_ext
@@ -342,7 +342,6 @@ files:
342
342
  - app/models/help_page_edition.rb
343
343
  - app/models/licence_edition.rb
344
344
  - app/models/local_authority.rb
345
- - app/models/local_interaction.rb
346
345
  - app/models/local_service.rb
347
346
  - app/models/local_transaction_edition.rb
348
347
  - app/models/overview_dashboard.rb
@@ -1,17 +0,0 @@
1
- require "csv"
2
- require "safe_html"
3
-
4
- class LocalInteraction
5
- include Mongoid::Document
6
-
7
- LGIL_CODE_PROVIDING_INFORMATION = 8
8
-
9
- field :lgsl_code, type: Integer
10
- field :lgil_code, type: Integer
11
- field :url, type: String
12
-
13
- embedded_in :local_authority
14
-
15
- validates_presence_of :url, :lgil_code, :lgsl_code
16
- validates_uniqueness_of :lgil_code, :scope => :lgsl_code
17
- end