Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assorted tidying up #1238

Merged
merged 6 commits into from
Jun 24, 2024
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
8 changes: 1 addition & 7 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def navigation_items
{
text: "External links",
href: recommended_links_path,
active: is_current?(recommended_links_path),
active: controller.controller_name == "recommended_links",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

},
{
text: current_user.name,
Expand All @@ -18,10 +18,4 @@ def navigation_items
},
]
end

def is_current?(link)
recognized = Rails.application.routes.recognize_path(link)
recognized[:controller] == params[:controller] &&
recognized[:action] == params[:action]
end
end
6 changes: 3 additions & 3 deletions app/helpers/forms_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ module FormsHelper
def error_items(record, field)
return unless record.errors[field].any?

record.errors[field].map do |error|
{ text: "#{field.to_s.humanize} #{error}" }
record.errors.full_messages_for(field).map do |error|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

{ text: error }
end
end

def error_summary_items(record)
record.errors.map do |error|
{
text: "#{error.attribute.to_s.humanize} #{error.message}",
text: error.full_message,
href: "##{record.class.name.underscore}_#{error.attribute}",
}
end
Expand Down
6 changes: 0 additions & 6 deletions app/helpers/icon_helper.rb

This file was deleted.

17 changes: 0 additions & 17 deletions app/mailers/bets_mailer.rb

This file was deleted.

35 changes: 0 additions & 35 deletions spec/factories.rb
Original file line number Diff line number Diff line change
@@ -1,39 +1,4 @@
FactoryBot.define do
sequence :numeric_position do |n|
n
end

factory :bet do
link { "/death-and-taxes" }
expiration_date { Time.zone.now + 1.day }

trait(:worst) do
is_best { false }
end

trait(:best) do
is_best { true }
position { generate :numeric_position }
end

trait(:permanent) do
permanent { true }
end

user
end

factory :query do
query { "tax" }
match_type { "exact" }

trait :with_best_bet do
after(:create) do |query|
create(:bet, :best, query:)
end
end
end

factory :recommended_link do
title { "Tax online" }
link { "https://www.tax.service.gov.uk/" }
Expand Down
9 changes: 9 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@

config.include FactoryBot::Syntax::Methods

config.before(:all, type: :system) do
@user = create(:user)
GDS::SSO.test_user = @user
end

config.after(:all, type: :system) do
@user.destroy!
end

config.before(:each, type: :system) do
driven_by :rack_test
end
Expand Down
4 changes: 0 additions & 4 deletions spec/system/recommended_links_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
RSpec.describe "Recommended links" do
before do
# TODO: Refactor me out into a support file (once we have more system specs and old
# controller specs are gone that this might conflict with)
GDS::SSO.test_user = create(:user)

stub_external_content_publisher
end

Expand Down
Loading