Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -110,27 +110,27 @@ GEM
rbtree3 (~> 0.6)
ast (2.4.3)
aws-eventstream (1.4.0)
aws-partitions (1.1186.0)
aws-sdk-core (3.239.0)
aws-partitions (1.1199.0)
aws-sdk-core (3.240.0)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.992.0)
aws-sigv4 (~> 1.9)
base64
bigdecimal
jmespath (~> 1, >= 1.6.1)
logger
aws-sdk-kms (1.117.0)
aws-sdk-core (~> 3, >= 3.234.0)
aws-sdk-kms (1.118.0)
aws-sdk-core (~> 3, >= 3.239.1)
aws-sigv4 (~> 1.5)
aws-sdk-s3 (1.205.0)
aws-sdk-s3 (1.209.0)
aws-sdk-core (~> 3, >= 3.234.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.5)
aws-sigv4 (1.12.1)
aws-eventstream (~> 1, >= 1.0.2)
base64 (0.3.0)
benchmark (0.5.0)
bigdecimal (3.3.1)
bigdecimal (4.0.1)
bstard (0.2.4)
builder (3.3.0)
byebug (12.0.0)
Expand All @@ -147,8 +147,8 @@ GEM
clamav-client (3.2.0)
climate_control (1.2.0)
coderay (1.1.3)
concurrent-ruby (1.3.5)
connection_pool (2.5.4)
concurrent-ruby (1.3.6)
connection_pool (3.0.2)
crack (1.0.1)
bigdecimal
rexml
Expand All @@ -166,7 +166,7 @@ GEM
defra_ruby_template (5.11.0)
diff-lcs (1.6.2)
docile (1.4.1)
dotenv (3.1.8)
dotenv (3.2.0)
drb (2.2.3)
erb (6.0.0)
erubi (1.13.1)
Expand All @@ -175,7 +175,7 @@ GEM
factory_bot_rails (6.5.1)
factory_bot (~> 6.5)
railties (>= 6.1.0)
faker (3.5.2)
faker (3.5.3)
i18n (>= 1.8.11, < 2)
faraday (2.14.0)
faraday-net_http (>= 2.0, < 3.5)
Expand All @@ -185,7 +185,7 @@ GEM
faraday (>= 0.8)
faraday-net_http (3.4.2)
net-http (~> 0.5)
faraday-retry (2.3.2)
faraday-retry (2.4.0)
faraday (~> 2.0)
github_changelog_generator (1.15.2)
activesupport
Expand All @@ -206,16 +206,16 @@ GEM
hashdiff (1.2.1)
html-attributes-utils (0.9.2)
activesupport (>= 6.1.4.4)
i18n (1.14.7)
i18n (1.14.8)
concurrent-ruby (~> 1.0)
io-console (0.8.1)
irb (1.15.3)
pp (>= 0.6.0)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
jmespath (1.6.2)
json (2.16.0)
json_schemer (2.4.0)
json (2.18.0)
json_schemer (2.5.0)
bigdecimal
hana (~> 1.3)
regexp_parser (~> 2.0)
Expand Down Expand Up @@ -250,9 +250,10 @@ GEM
method_source (1.1.0)
mini_mime (1.1.5)
mini_portile2 (2.8.9)
minitest (5.26.2)
minitest (6.0.1)
prism (~> 1.5)
multi_json (1.17.0)
net-http (0.8.0)
net-http (0.9.1)
uri (>= 0.11.1)
net-imap (0.5.12)
date
Expand All @@ -278,7 +279,7 @@ GEM
pp (0.6.3)
prettyprint
prettyprint (0.2.0)
prism (1.6.0)
prism (1.7.0)
pry (0.15.2)
coderay (~> 1.1)
method_source (~> 1.0)
Expand Down Expand Up @@ -368,15 +369,15 @@ GEM
rspec-retry (0.6.2)
rspec-core (> 3.3)
rspec-support (3.13.6)
rubocop (1.81.7)
rubocop (1.82.1)
json (~> 2.3)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.1.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.9.3, < 3.0)
rubocop-ast (>= 1.47.1, < 2.0)
rubocop-ast (>= 1.48.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.48.0)
Expand All @@ -388,7 +389,7 @@ GEM
rubocop-factory_bot (2.28.0)
lint_roller (~> 1.1)
rubocop (~> 1.72, >= 1.72.1)
rubocop-rails (2.34.1)
rubocop-rails (2.34.2)
activesupport (>= 4.2.0)
lint_roller (~> 1.1)
rack (>= 1.1)
Expand Down Expand Up @@ -440,11 +441,10 @@ GEM
concurrent-ruby (~> 1.0)
unicode-display_width (3.2.0)
unicode-emoji (~> 4.1)
unicode-emoji (4.1.0)
unicode-emoji (4.2.0)
uri (1.1.1)
useragent (0.16.11)
vcr (6.3.1)
base64
vcr (6.4.0)
webmock (3.26.1)
addressable (>= 2.8.0)
crack (>= 0.3.2)
Expand Down
21 changes: 6 additions & 15 deletions app/models/pafs_core/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,23 +157,14 @@ def first_financial_year
end

def carbon_values_calculate_hexdigest
# The presenter's net_carbon_with_blanks_calculated method involves most of the relevant attributes
# so a change to any one of the relevant values should result in a different hexdigest value.
# We also include the key years/months as these may also impact carbon calculations.
# There are extreme edge cases where changes to two attributs offset each other exactly
# but this is too unlikely to justify the build and maintenance effort of specifying each
# relevant attribute separately.
# We also include funding values as these have a bearing on carbon cost calculations.
presenter = PafsCore::CarbonImpactPresenter.new(project: self)

hash_input_data = {
net_carbon_with_blanks_calculated: presenter.net_carbon_with_blanks_calculated,
funding_values: funding_values.all.map { |fv| fv.attributes.sort_by { |k, _v| k }.sort }.sort,
start_construction_year: start_construction_year,
start_construction_month: start_construction_month,
ready_for_service_year: ready_for_service_year,
ready_for_service_month: ready_for_service_month
}
hash_input_data = [
presenter.capital_carbon_baseline,
presenter.operational_carbon_baseline,
presenter.capital_carbon_target,
presenter.operational_carbon_target
]

Digest::SHA1.hexdigest(hash_input_data.sort.inspect)
end
Expand Down
30 changes: 0 additions & 30 deletions spec/controllers/pafs_core/projects_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,6 @@
it_behaves_like "does not show the carbon values changes message"
end

context "when carbon input values have been updated since the hexdigest was stored" do
before do
project.update(carbon_cost_operation: project.carbon_cost_operation + 1)

get :show, params: { id: project.to_param }
end

it_behaves_like "shows the carbon values changed message"
end

context "when important dates have been updated since the hexdigest was stored" do
before do
project.carbon_values_update_hexdigest
Expand Down Expand Up @@ -137,26 +127,6 @@
it_behaves_like "shows the carbon values changed message"
end
end

context "when start construction date has been updated since the hexdigest was stored" do
before do
project.update(start_construction_month: project.start_construction_month + 1)

get :show, params: { id: project.to_param }
end

it_behaves_like "shows the carbon values changed message"
end

context "when ready for service date has been updated since the hexdigest was stored" do
before do
project.update(ready_for_service_month: project.ready_for_service_month + 1)

get :show, params: { id: project.to_param }
end

it_behaves_like "shows the carbon values changed message"
end
end
end
end
Expand Down
Loading