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 @id = id
@header = hsh["header"] @header = hsh["header"]
@description = hsh["description"] @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"] @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 @subsection = subsection
end end

2
app/models/form/section.rb

@ -5,6 +5,6 @@ class Form::Section
@id = id @id = id
@label = hsh["label"] @label = hsh["label"]
@form = form @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
end end

2
app/models/form/subsection.rb

@ -5,7 +5,7 @@ class Form::Subsection
@id = id @id = id
@label = hsh["label"] @label = hsh["label"]
@depends_on = hsh["depends_on"] @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 @section = section
end end

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

@ -2,7 +2,7 @@
<%= link_to 'Back', :back, class: "govuk-back-link" %> <%= link_to 'Back', :back, class: "govuk-back-link" %>
<% end %> <% 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-row">
<div class="govuk-grid-column-two-thirds"> <div class="govuk-grid-column-two-thirds">
<h1 class="govuk-heading-l">Change your personal details</h1> <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] class AddNameEmailRoleOrgToUsers < ActiveRecord::Migration[6.1]
def change def change
add_column :users, :name, :string change_table :users, bulk: true do |t|
add_column :users, :role, :string t.column :name, :string
add_column :users, :organisation, :string t.column :role, :string
t.column :organisation, :string
end
end end
end end

4
spec/features/user_spec.rb

@ -54,8 +54,8 @@ RSpec.describe "User Features" do
visit("/users/password/new") visit("/users/password/new")
fill_in("user_email", with: user.email) fill_in("user_email", with: user.email)
click_button("Send email") click_button("Send email")
expect(page).to have_css '.govuk-notification-banner.govuk-notification-banner--success' expect(page).to have_css ".govuk-notification-banner.govuk-notification-banner--success"
end end
end end
context "If a not logged in user tries to access pages that need permissions" do 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 { expect {
CaseLog.create!( CaseLog.create!(
reasonpref: "No", reasonpref: "No",
rp_medwel: "Yes" rp_medwel: "Yes",
) )
}.to raise_error(ActiveRecord::RecordInvalid) }.to raise_error(ActiveRecord::RecordInvalid)
end end

5
spec/rails_helper.rb

@ -12,10 +12,7 @@ Capybara.register_driver :headless do |app|
options = Selenium::WebDriver::Firefox::Options.new options = Selenium::WebDriver::Firefox::Options.new
options.add_argument("--headless") options.add_argument("--headless")
Capybara::Selenium::Driver.new(app, Capybara::Selenium::Driver.new(app, browser: :firefox, capabilities: options)
browser: :firefox,
capabilities: options
)
end end
Capybara.javascript_driver = :headless 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, id: case_log.id,
case_log: { case_log: {
page: page_id, page: page_id,
age1: answer age1: answer,
} },
} }
end end

Loading…
Cancel
Save