Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

Commit

Permalink
Merge branch 'feature/bitzesty-ci-containerisation' into feature/dock…
Browse files Browse the repository at this point in the history
…er-containerisation-phusion-image
  • Loading branch information
Lubosky authored Sep 27, 2023
2 parents cd0bdb3 + 82020dc commit 3ea67e4
Show file tree
Hide file tree
Showing 26 changed files with 967 additions and 175 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ gem 'lograge', '~> 0.11.2'
gem 'mail-notify', '~> 1.1.0 '
gem 'nilify_blanks', '~> 1.3'
gem 'pg', '~> 1.1'
gem 'puma', '~> 4.3'
gem 'puma', '~> 5.6'
gem "rails", "~> 7.0.0"
gem 'rails-i18n', '~> 7.0.5'
gem 'redis', '~> 4.1.3'
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ GEM
method_source (~> 1.0)
psych (3.3.4)
public_suffix (5.0.1)
puma (4.3.12)
puma (5.6.7)
nio4r (~> 2.0)
racc (1.7.1)
rack (2.2.7)
Expand Down Expand Up @@ -480,7 +480,7 @@ DEPENDENCIES
pg (~> 1.1)
pry (~> 0.14.1)
psych (< 4)
puma (~> 4.3)
puma (~> 5.6)
rails (~> 7.0.0)
rails-controller-testing (~> 1.0.4)
rails-i18n (~> 7.0.5)
Expand Down
18 changes: 18 additions & 0 deletions app/controllers/organisation/mission_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ def update

logger.info "Updating mission for organisation ID: #{@organisation.id}"

ensure_mission_params

@organisation.validate_mission = true

@organisation.update(organisation_params)
Expand Down Expand Up @@ -40,4 +42,20 @@ def organisation_params

end

# This method ensures that if no mission is chosen by the user
# the mission array is set back to empty.
def ensure_mission_params

if params[:organisation]

params[:organisation][:mission] ||= []

else

params[:organisation] = { mission: [] }

end

end

end
9 changes: 9 additions & 0 deletions app/controllers/user/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,14 @@ def create_person(resource)
NotifyMailer.confirmation_instructions_copy(resource).deliver_later

end

# Override the Devise::RegistrationsController update_resource method
# Ensures the email is not provided as a param to prevent it being updated
def update_resource(resource, params)

params.delete(:email)

super
end

end
23 changes: 23 additions & 0 deletions app/helpers/admin_portal_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ module AdminPortalHelper
PEF = 4
EOI = 5
UNKNOWN = 6
MIGRATED_MEDIUM_OVER_100k = 7

# Creates an array of hashes for the applications and
# pre-applications belonging to a main applicant.
Expand Down Expand Up @@ -74,6 +75,16 @@ def get_main_contact_apps(org_id, user_id)
type = MEDIUM
end

if fa.migrated_medium_over_100k?
type = MIGRATED_MEDIUM_OVER_100k

salesforce_api_client= SalesforceApiClient.new

title = salesforce_api_client
.get_project_title(fa.salesforce_case_id)
.Project_Title__c
end

if fa.project.present?
title = fa.project.project_title
type = SMALL
Expand Down Expand Up @@ -163,6 +174,8 @@ def move_app_to_new_user(chosen_app_hash, new_contact_id, new_org_id)
move_3_to_10k(chosen_app_hash, new_contact_id, new_org_id)
when MEDIUM
move_10_to_250k(chosen_app_hash, new_contact_id, new_org_id)
when MIGRATED_MEDIUM_OVER_100k
move_migrated_medium_over_100k(chosen_app_hash, new_org_id)
when LARGE
move_large(chosen_app_hash, new_org_id)
when PEF
Expand Down Expand Up @@ -354,6 +367,16 @@ def move_large(chosen_app_hash, new_org_id)

end

# uses exactly the same as move_large for migrating medium over 100k
# @param [Hash] chosen_app_hash App that we are moving: example
# {:id=>"", :ref_no=>"", :type=>1, :title=>"", salesforce_id => ""}
# @param [String] new_org_id FFE GUID for new organisation
def move_migrated_medium_over_100k(chosen_app_hash, new_org_id)

move_large(chosen_app_hash, new_org_id)

end

# Moves a pre_application to a new user
# Amends pre_applications rows
# Writes audit row of changes
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/import_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ def populate_temporary_table_and_run_report(projects_for_reconnection)
project.Project_Reference_Number__c)

pop_temp_table_sql << "INSERT INTO reconnection_projects VALUES (" \
"#{name}, #{title}, #{ref}, #{area});"
"#{name}, #{title}, #{area}, #{ref} );"

end

Expand Down
4 changes: 3 additions & 1 deletion app/models/legal_signatory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ class LegalSignatory < ApplicationRecord

validates :name, length: { minimum: 1, maximum: 80 }

# the custom regex below ensures that a domain
# is present and also allows tags.
validates :email_address,
format: { with: URI::MailTo::EMAIL_REGEXP }
format: { with: /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i }

def validate_role?
validate_role == true
Expand Down
1 change: 1 addition & 0 deletions app/models/organisation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class Organisation < ApplicationRecord
validates :custom_org_type, presence: true, if: :validate_custom_org_type?
validate :validate_mission_array, if: :validate_mission?
validates :name, presence: true, if: :validate_name?
validates :name, length: { maximum: 255 }
validates :name, presence: true, if: :validate_address?
validates :line1, presence: true, if: :validate_address?
validates :townCity, presence: true, if: :validate_address?
Expand Down
23 changes: 21 additions & 2 deletions app/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ def to_salesforce_json
json.cashContributions self.cash_contributions do |cash_contribution|
json.description cash_contribution.description
json.amount cash_contribution.amount
json.secured cash_contribution.secured&.dasherize
json.secured format_secured_for_salesforce(cash_contribution)
json.id cash_contribution.id
end
json.set!('organisationSalesforceAccountId',
Expand Down Expand Up @@ -470,4 +470,23 @@ def get_organisation_type_for_salesforce_json

end

end
# Formats the secured value of a cash contribution for Salesforce.
#
# Given a cash contribution with a particular secured value, this method
# will either return the "not sure" string or a dasherized version of the
# value, depending on the original value.
#
# @param [object] cash contribution object
# @param [string] :secured for the answer/value of the 'is your cash
# contribution secured?' question
#
# @return [string] - A formatted string value. Either 'not sure' or
# a dasherized value
def format_secured_for_salesforce(cash_contribution)
if cash_contribution.secured == 'x_not_sure'
'not sure'
else
cash_contribution.secured&.dasherize
end
end
end
3 changes: 2 additions & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ class User < ApplicationRecord
:recoverable,
:rememberable,
:validatable,
:confirmable
:confirmable,
:timeoutable

enum role: [:user, :admin]
after_initialize :set_default_role, :if => :new_record?
Expand Down
14 changes: 6 additions & 8 deletions app/views/admin_portal/reconnection_report/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
<thead class="govuk-table__head">
<tr class="govuk-table__row">
<th scope="col" class="govuk-table__header">Project Owner</th>
<th scope="col" class="govuk-table__header">Project Reference Number</th>
<th scope="col" class="govuk-table__header">Project Title</th>
<th scope="col" class="govuk-table__header">Project Area/Country</th>
<th scope="col" class="govuk-table__header">Project Reference Number</th>
<th scope="col" class="govuk-table__header">Reconnection Date</th>
</tr>
</thead>
Expand All @@ -22,17 +22,15 @@
<tr class="govuk-table__row">
<%# This could be a nested loop, but to be explicit: %>
<%# row[0] - Project Owner%>
<%# row[2] - Project Reference Number%>
<%# row[3] - Project Title%>
<%# row[1] - Project area/country%>
<%# row[1] - Project Title%>
<%# row[2] - Project area/country%>
<%# row[3] - Project Reference Number%>
<%# row[4] - Project Reconnection Date%>
<th scope="row" class="govuk-table__header"><%=row[0]%></th>
<td class="govuk-table__cell"><%=row[2]%></td>
<td class="govuk-table__cell"><%=row[1]%></td>
<td class="govuk-table__cell"><%=row[2].present? ? row[2]: 'Not specified'%></td>
<td class="govuk-table__cell"><%=row[3]%></td>
<td class="govuk-table__cell"><%=row[1].present? ? row[1]: 'Not specified'%></td>
<td class="govuk-table__cell"><%=row[4].present? ? row[4].strftime('%d-%m-%Y').to_s : 'Not reconnected' %></td>


</tr>
<% end %>
</tbody>
Expand Down
7 changes: 3 additions & 4 deletions app/views/user/registrations/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,9 @@
</span>

<%=
f.text_field :email,
autofocus: true,
autocomplete: "email",
class: "govuk-input govuk-input--width-20"
f.label :email,
@user.email,
class: "govuk-label govuk-!-margin-top-2 govuk-!-font-weight-bold"
%>

</div>
Expand Down
13 changes: 10 additions & 3 deletions config/initializers/devise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,19 @@
# Email regex used to validate email formats. It simply asserts that
# one (and only one) @ exists in the given string. This is mainly
# to give user feedback and not to assert the e-mail validity.
config.email_regexp = /\A[^@\s]+@[^@\s]+\z/
# original email_regexp /\A[^@\s]+@[^@\s]+\z/

# a custom regex has now been added below, this ensures that a domain
# is present and also allows tags.
config.email_regexp =/\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i


# ==> Configuration for :timeoutable
# The time you want to timeout the user session without activity. After this
# time the user will be asked for credentials again. Default is 30 minutes.
# config.timeout_in = 30.minutes
# time the user will be asked for credentials again.
# Gone for WCAG 20 hour exception to meet level A criteria.
# https://www.w3.org/WAI/WCAG21/Understanding/timing-adjustable.html
config.timeout_in = 20.hours

# ==> Configuration for :lockable
# Defines which strategy will be used to lock an account.
Expand Down
1 change: 1 addition & 0 deletions config/locales/cy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ cy:
not_a_number: "Mae'n rhaid i rif cwmni fod yn rhif, fel 12345678"
name:
blank: "Rhowch enw eich sefydliad"
too_long: "Rhaid i Enw Sefydliad fod yn 225 nod neu lai"
line1:
blank: "Rhowch linell gyntaf cyfeiriad eich sefydliad"
townCity:
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ en-GB:
not_a_number: "Company number must be a number, like 12345678"
name:
blank: "Enter the name of your organisation"
too_long: "Organisation name must be 255 characters or fewer"
line1:
blank: "Enter the first line of your organisation's address"
townCity:
Expand Down
2 changes: 1 addition & 1 deletion lib/apis/salesforce/import/import_salesforce_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def retrieve_existing_account_info(name, postcode, org_id)

def get_projects_selected_for_reconnection
query = "SELECT Owner.Name, Project_Title__c, " \
"Project_Reference_Number__c, Region__c " \
"Region__c, Project_Reference_Number__c " \
"FROM Case where Export_to_IMS_Portal__c = true "

restforce_response = run_salesforce_query(
Expand Down
3 changes: 2 additions & 1 deletion manifest-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ applications:
processes:
- type: web
command: bundle exec rake cf:on_first_instance db:migrate && rails s -p $PORT
memory: 256M
memory: 2GB
disk_quota: 3GB
instances: 2
health-check-type: http
health-check-http-endpoint: /health
Expand Down
3 changes: 2 additions & 1 deletion manifest-uat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ applications:
processes:
- type: web
command: bundle exec rake cf:on_first_instance db:migrate && rails s -p $PORT
memory: 256M
memory: 2GB
disk_quota: 3GB
instances: 2
health-check-type: http
health-check-http-endpoint: /health
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,32 @@

end

it "should raise email error based on invalid email validation " \
"when email without a domain is passed" do

put :update,
params: {
application_id: @funding_application.id,
legal_signatory:{
name: "John Smith",
email_address: "john@smith",
role: "Trustee"
}
}

expect(response).to have_http_status(:success)
expect(response).to render_template(:show)

expect(assigns(:funding_application).errors.empty?).to eq(false)

expect(assigns(:funding_application).errors.count)
.to eq(1)

expect(assigns(:funding_application).errors[:"legal_signatories.email_address"][0])
.to eq("Enter a valid email address")

end

it "should raise email error based matching email address of " \
"legal signatory 1 and legal signatory 2" do

Expand Down
Loading

0 comments on commit 3ea67e4

Please sign in to comment.