Skip to content

Commit 7557eb3

Browse files
Merge pull request #231 from DFE-Digital/add-dependabot-yml
Add dependabot yml
2 parents 814cd16 + bdadae7 commit 7557eb3

2 files changed

Lines changed: 35 additions & 12 deletions

File tree

.github/dependabot.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: bundler
4+
directories:
5+
- "/"
6+
- "/gemfiles"
7+
schedule:
8+
interval: weekly
9+
open-pull-requests-limit: 5
10+
labels:
11+
- dependencies
12+
- ruby
13+
- package-ecosystem: github-actions
14+
directory: "/"
15+
schedule:
16+
interval: weekly
17+
open-pull-requests-limit: 5
18+
labels:
19+
- DevOps
20+
- dependencies
21+
- github_actions

spec/dfe/analytics/services/entity_table_checks_spec.rb

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,10 @@
9494
end
9595

9696
it 'uses created_at if it exists and has no null values' do
97-
Candidate.create!(id: 1, email_address: 'first@example.com')
98-
Candidate.create!(id: 2, email_address: 'second@example.com')
97+
Candidate.create!(id: 1, email_address: 'first@example.com', created_at: 2.days.ago, updated_at: 2.days.ago)
98+
Candidate.create!(id: 2, email_address: 'second@example.com', created_at: 1.day.ago, updated_at: 1.day.ago)
9999

100-
table_ids = Candidate.order(:created_at).pluck(:id)
100+
table_ids = Candidate.where('created_at < ?', checksum_calculated_at).order(:created_at).pluck(:id)
101101
checksum = Digest::MD5.hexdigest(table_ids.join)
102102

103103
described_class.call(entity_name: candidate_entity, entity_type: entity_type, entity_tag: nil)
@@ -139,14 +139,16 @@
139139
end
140140

141141
it 'defaults to created_at when updated_at is null but created_at exists' do
142-
Candidate.create!(id: 1, email_address: 'first@example.com', updated_at: nil, created_at: 2.hours.ago)
143-
Candidate.create!(id: 2, email_address: 'second@example.com', updated_at: nil, created_at: 1.hour.ago)
144-
Candidate.create!(id: 3, email_address: 'third@example.com', updated_at: nil, created_at: 3.hours.ago)
142+
cutoff = Time.zone.parse(checksum_calculated_at)
143+
144+
Candidate.create!(id: 1, email_address: 'first@example.com', updated_at: nil, created_at: cutoff - 3.hours)
145+
Candidate.create!(id: 2, email_address: 'second@example.com', updated_at: nil, created_at: cutoff - 2.hours)
146+
Candidate.create!(id: 3, email_address: 'third@example.com', updated_at: nil, created_at: cutoff - 1.hour)
145147

146148
# Ensure updated_at is not nil
147-
Candidate.update_all(updated_at: Time.now)
149+
Candidate.update_all(updated_at: cutoff - 30.minutes)
148150

149-
table_ids = Candidate.order(:created_at).pluck(:id)
151+
table_ids = Candidate.where('created_at < ?', checksum_calculated_at).order(:created_at).pluck(:id)
150152
checksum = Digest::MD5.hexdigest(table_ids.join)
151153

152154
described_class.call(entity_name: candidate_entity, entity_type: entity_type, entity_tag: nil)
@@ -166,7 +168,7 @@
166168
order_column = 'CREATED_AT'
167169
[123, 124, 125].map { |id| Application.create(id: id) }
168170
application_entities = DfE::Analytics.entities_for_analytics.select { |entity| entity.to_s.include?('application') }
169-
table_ids = Application.where('created_at < ?', checksum_calculated_at).order(created_at: :asc).pluck(:id)
171+
table_ids = Application.where('created_at < ?', checksum_calculated_at).order(:created_at).pluck(:id)
170172
checksum = Digest::MD5.hexdigest(table_ids.join)
171173

172174
application_entities.each do |application|
@@ -186,7 +188,7 @@
186188
it 'sends an entity table check event' do
187189
[130, 131, 132].map { |id| Candidate.create(id: id) }
188190
candidate_entities = DfE::Analytics.entities_for_analytics.select { |entity| entity.to_s.include?('candidate') }
189-
table_ids = Candidate.where('created_at < ?', checksum_calculated_at).order(created_at: :asc).pluck(:id)
191+
table_ids = Candidate.where('created_at < ?', checksum_calculated_at).order(:created_at).pluck(:id)
190192
checksum = Digest::MD5.hexdigest(table_ids.join)
191193

192194
candidate_entities.each do |candidate|
@@ -211,7 +213,7 @@
211213

212214
Candidate.update_all(created_at: DateTime.parse(checksum_calculated_at) - 1.hour)
213215

214-
table_ids = Candidate.where('created_at < ?', checksum_calculated_at).order(:updated_at).pluck(:id)
216+
table_ids = Candidate.where('created_at < ?', checksum_calculated_at).order(:created_at).pluck(:id)
215217
checksum = Digest::MD5.hexdigest(table_ids.join)
216218

217219
described_class.call(entity_name: candidate_entity, entity_type: entity_type, entity_tag: nil)
@@ -228,7 +230,7 @@
228230
end
229231

230232
it 'returns zero rows and checksum if table is empty' do
231-
table_ids = Candidate.where('created_at < ?', checksum_calculated_at).order(created_at: :asc).pluck(:id)
233+
table_ids = Candidate.where('created_at < ?', checksum_calculated_at).order(:created_at).pluck(:id)
232234
checksum = Digest::MD5.hexdigest(table_ids.join)
233235
described_class.call(entity_name: candidate_entity, entity_type: entity_type, entity_tag: nil)
234236

0 commit comments

Comments
 (0)