Browse Source

Rubocop

pull/112/head
baarkerlounger 3 years ago
parent
commit
1c0c4813f0
  1. 9
      app/helpers/account_helper.rb
  2. 4
      app/models/form/page.rb
  3. 2
      app/models/form/section.rb
  4. 2
      app/models/form/subsection.rb
  5. 2
      app/views/users/account/personal_details.html.erb
  6. 8
      db/migrate/20211125114400_add_name_email_role_org_to_users.rb
  7. 4
      spec/features/user_spec.rb
  8. 2
      spec/models/case_log_spec.rb
  9. 5
      spec/rails_helper.rb
  10. 4
      spec/requests/case_log_controller_spec.rb

9
app/helpers/account_helper.rb

@ -1,9 +0,0 @@
module AccountHelper
def resource_name
:user
end
def resource
@resource = current_user
end
end

4
app/models/form/page.rb

@ -6,9 +6,9 @@ class Form::Page
@id = id
@header = hsh["header"]
@description = hsh["description"]
@questions = hsh["questions"].map { |id, q| Form::Question.new(id, q, self) }
@questions = hsh["questions"].map { |q_id, q| Form::Question.new(q_id, q, self) }
@depends_on = hsh["depends_on"]
@soft_validations = hsh["soft_validations"]&.map { |id, s| Form::Question.new(id, s, self) }
@soft_validations = hsh["soft_validations"]&.map { |sv_id, s| Form::Question.new(sv_id, s, self) }
@subsection = subsection
end

2
app/models/form/section.rb

@ -5,6 +5,6 @@ class Form::Section
@id = id
@label = hsh["label"]
@form = form
@subsections = hsh["subsections"].map { |id, s| Form::Subsection.new(id, s, self) }
@subsections = hsh["subsections"].map { |s_id, s| Form::Subsection.new(s_id, s, self) }
end
end

2
app/models/form/subsection.rb

@ -5,7 +5,7 @@ class Form::Subsection
@id = id
@label = hsh["label"]
@depends_on = hsh["depends_on"]
@pages = hsh["pages"].map { |id, p| Form::Page.new(id, p, self) }
@pages = hsh["pages"].map { |s_id, p| Form::Page.new(s_id, p, self) }
@section = section
end

2
app/views/users/account/personal_details.html.erb

@ -2,7 +2,7 @@
<%= link_to 'Back', :back, class: "govuk-back-link" %>
<% end %>
<%= form_for(resource, as: resource_name, url: account_update_path(), html: { method: :patch }) do |f| %>
<%= form_for(current_user, as: :user, url: account_update_path(), html: { method: :patch }) do |f| %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h1 class="govuk-heading-l">Change your personal details</h1>

8
db/migrate/20211125114400_add_name_email_role_org_to_users.rb

@ -1,7 +1,9 @@
class AddNameEmailRoleOrgToUsers < ActiveRecord::Migration[6.1]
def change
add_column :users, :name, :string
add_column :users, :role, :string
add_column :users, :organisation, :string
change_table :users, bulk: true do |t|
t.column :name, :string
t.column :role, :string
t.column :organisation, :string
end
end
end

4
spec/features/user_spec.rb

@ -54,8 +54,8 @@ RSpec.describe "User Features" do
visit("/users/password/new")
fill_in("user_email", with: user.email)
click_button("Send email")
expect(page).to have_css '.govuk-notification-banner.govuk-notification-banner--success'
end
expect(page).to have_css ".govuk-notification-banner.govuk-notification-banner--success"
end
end
context "If a not logged in user tries to access pages that need permissions" do

2
spec/models/case_log_spec.rb

@ -62,7 +62,7 @@ RSpec.describe Form, type: :model do
expect {
CaseLog.create!(
reasonpref: "No",
rp_medwel: "Yes"
rp_medwel: "Yes",
)
}.to raise_error(ActiveRecord::RecordInvalid)
end

5
spec/rails_helper.rb

@ -12,10 +12,7 @@ Capybara.register_driver :headless do |app|
options = Selenium::WebDriver::Firefox::Options.new
options.add_argument("--headless")
Capybara::Selenium::Driver.new(app,
browser: :firefox,
capabilities: options
)
Capybara::Selenium::Driver.new(app, browser: :firefox, capabilities: options)
end
Capybara.javascript_driver = :headless

4
spec/requests/case_log_controller_spec.rb

@ -286,8 +286,8 @@ RSpec.describe CaseLogsController, type: :request do
id: case_log.id,
case_log: {
page: page_id,
age1: answer
}
age1: answer,
},
}
end

Loading…
Cancel
Save