From 0a5f40c12fd60b330764077cbf7d84bd32bc6965 Mon Sep 17 00:00:00 2001 From: moveson Date: Sun, 22 Dec 2024 01:09:10 -0700 Subject: [PATCH] Remove results_ prefix from relations; get specs passing --- app/controllers/event_groups_controller.rb | 21 +- .../resources/results_category_resource.rb | 4 +- .../results_template_category_resource.rb | 4 +- .../resources/results_template_resource.rb | 4 +- app/models/results_category.rb | 4 +- app/models/results_template.rb | 16 +- app/models/results_template_category.rb | 12 +- app/presenters/event_series_presenter.rb | 2 +- app/presenters/podium_presenter.rb | 2 +- app/services/results/compute.rb | 2 +- app/views/courses/index.html.erb | 4 +- app/views/courses/show.html.erb | 2 +- app/views/efforts/_effort_header.html.erb | 2 +- .../efforts/_entrant_for_roster.html.erb | 2 +- app/views/event_groups/_setup_header.html.erb | 4 +- app/views/event_groups/new.html.erb | 4 +- app/views/event_series/show.html.erb | 2 +- .../events/_course_setup_splits.html.erb | 2 +- .../_force_pull_times_button.html.erb | 4 +- .../event_groups/_pull_times_button.html.erb | 4 +- .../live/event_groups/live_entry.html.erb | 5 +- app/views/lotteries/draw_tickets.html.erb | 2 +- app/views/lotteries/show.html.erb | 2 +- .../organizations/_organization_tabs.html.erb | 2 +- app/views/organizations/show.html.erb | 4 +- .../_categories_card.html.erb | 4 +- spec/fixtures/results_template_categories.yml | 216 +++++++++--------- spec/models/results_template_category_spec.rb | 8 +- spec/rails_helper.rb | 2 +- 29 files changed, 171 insertions(+), 175 deletions(-) diff --git a/app/controllers/event_groups_controller.rb b/app/controllers/event_groups_controller.rb index bb9d20586..b1016c070 100644 --- a/app/controllers/event_groups_controller.rb +++ b/app/controllers/event_groups_controller.rb @@ -9,10 +9,10 @@ class EventGroupsController < ApplicationController # GET /event_groups def index scoped_event_groups = policy_scope(EventGroup) - .search(params[:search]) - .by_group_start_time - .preload(:events) - .paginate(page: params[:page], per_page: 25) + .search(params[:search]) + .by_group_start_time + .preload(:events) + .paginate(page: params[:page], per_page: 25) @presenter = EventGroupsCollectionPresenter.new(scoped_event_groups, params, current_user) session[:return_to] = event_groups_path end @@ -113,9 +113,9 @@ def setup_summary # GET /event_groups/1/efforts def efforts @efforts = policy_scope(@event_group.efforts) - .order(prepared_params[:sort] || :bib_number, :last_name, :first_name) - .where(prepared_params[:filter]) - .finish_info_subquery + .order(prepared_params[:sort] || :bib_number, :last_name, :first_name) + .where(prepared_params[:filter]) + .finish_info_subquery render partial: "event_groups/finish_line_effort", locals: { efforts: @efforts } end @@ -437,9 +437,10 @@ def delete_duplicate_raw_times private - def bib_assignment_hash(params_hash) - params_hash.select { |key, _| key.include?("bib_for") } - .transform_keys { |key| key.delete("^0-9").to_i } + def bib_assignment_hash(event_group_params) + event_group_params.to_unsafe_h + .select { |key, _| key.include?("bib_for") } + .transform_keys { |key| key.delete("^0-9").to_i } end def redirect_if_no_events diff --git a/app/madmin/resources/results_category_resource.rb b/app/madmin/resources/results_category_resource.rb index 722ac966a..a31f69c06 100644 --- a/app/madmin/resources/results_category_resource.rb +++ b/app/madmin/resources/results_category_resource.rb @@ -16,8 +16,8 @@ class ResultsCategoryResource < Madmin::Resource # Associations attribute :organization - attribute :results_template_categories - attribute :results_templates + attribute :template_categories + attribute :templates # Uncomment this to customize the display name of records in the admin area. def self.display_name(record) diff --git a/app/madmin/resources/results_template_category_resource.rb b/app/madmin/resources/results_template_category_resource.rb index 16a9e8cdc..2e7a34956 100644 --- a/app/madmin/resources/results_template_category_resource.rb +++ b/app/madmin/resources/results_template_category_resource.rb @@ -7,8 +7,8 @@ class ResultsTemplateCategoryResource < Madmin::Resource attribute :fixed_position # Associations - attribute :results_template - attribute :results_category + attribute :template + attribute :category # Uncomment this to customize the display name of records in the admin area. def self.display_name(record) diff --git a/app/madmin/resources/results_template_resource.rb b/app/madmin/resources/results_template_resource.rb index 54a19a694..65744ae40 100644 --- a/app/madmin/resources/results_template_resource.rb +++ b/app/madmin/resources/results_template_resource.rb @@ -12,8 +12,8 @@ class ResultsTemplateResource < Madmin::Resource # Associations attribute :slugs attribute :organization - attribute :results_template_categories - attribute :results_categories + attribute :template_categories + attribute :categories # Uncomment this to customize the display name of records in the admin area. def self.display_name(record) diff --git a/app/models/results_category.rb b/app/models/results_category.rb index 5cafdf4f2..98f63a4fc 100644 --- a/app/models/results_category.rb +++ b/app/models/results_category.rb @@ -8,8 +8,8 @@ class ResultsCategory < ApplicationRecord friendly_id :organization_genders_ages, use: [:sequentially_slugged, :history] belongs_to :organization, optional: true - has_many :results_template_categories, dependent: :destroy - has_many :results_templates, through: :results_template_categories + has_many :template_categories, dependent: :destroy, class_name: "ResultsTemplateCategory" + has_many :templates, through: :template_categories, class_name: "ResultsTemplate" validates_presence_of :name validates_uniqueness_of :name, scope: :organization diff --git a/app/models/results_template.rb b/app/models/results_template.rb index 64703803f..d6a8ce279 100644 --- a/app/models/results_template.rb +++ b/app/models/results_template.rb @@ -7,14 +7,12 @@ class ResultsTemplate < ApplicationRecord friendly_id :name, use: [:slugged, :history] belongs_to :organization, optional: true - has_many :results_template_categories, -> { order(position: :asc) }, dependent: :destroy - has_many :results_categories, through: :results_template_categories - - alias_method :categories, :results_categories + has_many :template_categories, -> { order(position: :asc) }, dependent: :destroy, class_name: "ResultsTemplateCategory" + has_many :categories, through: :template_categories, class_name: "ResultsCategory" scope :standard, lambda { select("results_templates.*, count(results_categories.id) as category_count") - .joins(:results_categories).where(organization: nil).group(:id).order("category_count") + .joins(:categories).where(organization: nil).group(:id).order("category_count") } validates_presence_of :name, :aggregation_method @@ -30,21 +28,21 @@ def dup_with_categories set_category_positions template = dup - template.results_categories = results_categories.map(&:dup) + template.categories = categories.map(&:dup) template end # @return [Boolean] def includes_nonbinary? - results_categories.where(nonbinary: true).exists? + categories.where(nonbinary: true).exists? end private def set_category_positions - indexed_rtcs = results_template_categories.index_by(&:results_category_id) + indexed_rtcs = template_categories.index_by(&:results_category_id) - results_categories.each do |rc| + categories.each do |rc| rtc = indexed_rtcs[rc.id] rc.position = rtc.position rc.fixed_position = rtc.fixed_position diff --git a/app/models/results_template_category.rb b/app/models/results_template_category.rb index 546e1f1dd..e39769974 100644 --- a/app/models/results_template_category.rb +++ b/app/models/results_template_category.rb @@ -1,17 +1,17 @@ # frozen_string_literal: true class ResultsTemplateCategory < ApplicationRecord - belongs_to :results_template, optional: false - belongs_to :results_category, optional: false + belongs_to :template, optional: false, class_name: "ResultsTemplate", foreign_key: :results_template_id + belongs_to :category, optional: false, class_name: "ResultsCategory", foreign_key: :results_category_id - acts_as_list scope: :results_template - validates_presence_of :results_category, :results_template + acts_as_list scope: :template + validates_presence_of :category, :template def category_description - results_category.description + category.description end def category_name - results_category.name + category.name end end diff --git a/app/presenters/event_series_presenter.rb b/app/presenters/event_series_presenter.rb index e42227ad4..f4b4a8a02 100644 --- a/app/presenters/event_series_presenter.rb +++ b/app/presenters/event_series_presenter.rb @@ -4,7 +4,7 @@ class EventSeriesPresenter < BasePresenter attr_reader :event_series delegate :name, :organization, :scoring_method, to: :event_series - delegate :results_categories, to: :completed_template + delegate :categories, to: :completed_template def initialize(event_series, view_context) @event_series = event_series || [] diff --git a/app/presenters/podium_presenter.rb b/app/presenters/podium_presenter.rb index ae120df78..c4c910a9e 100644 --- a/app/presenters/podium_presenter.rb +++ b/app/presenters/podium_presenter.rb @@ -16,7 +16,7 @@ def initialize(event, view_context, template:) # @return [Array] def categories - template&.results_categories || [] + template&.categories || [] end # @return [Array] diff --git a/app/services/results/compute.rb b/app/services/results/compute.rb index f27c98ab0..69f162242 100644 --- a/app/services/results/compute.rb +++ b/app/services/results/compute.rb @@ -38,7 +38,7 @@ def point_system end def categories - template.results_categories + template.categories end def fill(category) diff --git a/app/views/courses/index.html.erb b/app/views/courses/index.html.erb index 3bdeabdef..8ce3d8668 100644 --- a/app/views/courses/index.html.erb +++ b/app/views/courses/index.html.erb @@ -7,9 +7,9 @@
- <%= render "organizations/organization_heading", presenter: @presenter %> + <%= render partial: "organizations/organization_heading", locals: { presenter: @presenter } %> - <%= render "organizations/organization_tabs", presenter: @presenter %> + <%= render partial: "organizations/organization_tabs", locals: { presenter: @presenter } %>
diff --git a/app/views/courses/show.html.erb b/app/views/courses/show.html.erb index 9b5469591..688f991e3 100644 --- a/app/views/courses/show.html.erb +++ b/app/views/courses/show.html.erb @@ -48,7 +48,7 @@ <% end %> <% else %> <% if @presenter.events.present? %> - <%= render "events/events", presenter: @presenter, events: @presenter.events, show_grouping_button: false %> + <%= render "events/events", events: @presenter.events %> <% else %>

No events have been held on this course.

<% end %> diff --git a/app/views/efforts/_effort_header.html.erb b/app/views/efforts/_effort_header.html.erb index 3898238c0..662d28724 100644 --- a/app/views/efforts/_effort_header.html.erb +++ b/app/views/efforts/_effort_header.html.erb @@ -1,4 +1,4 @@ -<%# locals: (view_object:) -%> +<%# locals: (view_object:, title: nil) -%>
diff --git a/app/views/efforts/_entrant_for_roster.html.erb b/app/views/efforts/_entrant_for_roster.html.erb index d2e308efd..8da2b1330 100644 --- a/app/views/efforts/_entrant_for_roster.html.erb +++ b/app/views/efforts/_entrant_for_roster.html.erb @@ -1,4 +1,4 @@ -<%# locals: (effort:, multiple_events, :started_efforts_present:) -%> +<%# locals: (effort:, multiple_events:, started_efforts_present:) -%> +<%# locals: (presenter:, breadcrumbs: []) -%>
@@ -25,7 +25,7 @@
- <%= render "event_groups/setup_widget", presenter: presenter %> + <%= render partial: "event_groups/setup_widget", locals: { presenter: presenter } %>
diff --git a/app/views/event_groups/new.html.erb b/app/views/event_groups/new.html.erb index a1db6abd7..619966cd7 100644 --- a/app/views/event_groups/new.html.erb +++ b/app/views/event_groups/new.html.erb @@ -2,8 +2,8 @@ <% "OpenSplitTime: New Event Group" %> <% end %> -<%= render "shared/mode_widget", event_group: @presenter.event_group %> -<%= render "setup_header", presenter: @presenter %> +<%= render partial: "shared/mode_widget", locals: { event_group: @presenter.event_group } %> +<%= render partial: "setup_header", locals: { presenter: @presenter } %>

We will first need some basic information about your Event Group

diff --git a/app/views/event_series/show.html.erb b/app/views/event_series/show.html.erb index c56ddb10f..030b03c39 100644 --- a/app/views/event_series/show.html.erb +++ b/app/views/event_series/show.html.erb @@ -40,7 +40,7 @@
- <% @presenter.results_categories.each do |category| %> + <% @presenter.categories.each do |category| %> <% if category.invalid_efforts? %> <%= render 'invalid_results_category', category: category %> <% else %> diff --git a/app/views/events/_course_setup_splits.html.erb b/app/views/events/_course_setup_splits.html.erb index 18de3665e..25fe57efe 100644 --- a/app/views/events/_course_setup_splits.html.erb +++ b/app/views/events/_course_setup_splits.html.erb @@ -1,4 +1,4 @@ -<%# locals: (event:, splits:, aid_stations_by_split_id) -%> +<%# locals: (event:, splits:, aid_stations_by_split_id:) -%>
- -<% count ||= nil %> +<%# locals: (event_group:, count: nil) -%> diff --git a/app/views/lotteries/draw_tickets.html.erb b/app/views/lotteries/draw_tickets.html.erb index 8f9a7a462..3cbb8ef3d 100644 --- a/app/views/lotteries/draw_tickets.html.erb +++ b/app/views/lotteries/draw_tickets.html.erb @@ -17,7 +17,7 @@ <%= turbo_stream_from division, :lottery_draws, class: "d-none" %> <%= turbo_stream_from division, :lottery_draw_header, class: "d-none" %>
- <%= render "lottery_divisions/draw_tickets_header", division: division %> + <%= render partial: "lottery_divisions/draw_tickets_header", locals: { lottery_division: division } %>
<%= render partial: "lottery_draws/lottery_draw_admin", collection: division.draws.with_entrant_and_ticket.most_recent_first, as: :lottery_draw %> diff --git a/app/views/lotteries/show.html.erb b/app/views/lotteries/show.html.erb index b466c5d62..68d393608 100644 --- a/app/views/lotteries/show.html.erb +++ b/app/views/lotteries/show.html.erb @@ -99,7 +99,7 @@ <%= turbo_stream_from division, :lottery_header, class: "d-none" %>
<%= division.name %>
- <%= render partial: "lottery_divisions/tickets_progress_bars", locals: { division: division, show_pre_selected: false } %> + <%= render partial: "lottery_divisions/tickets_progress_bars", locals: { lottery_division: division, show_pre_selected: false } %>
<% end %>
diff --git a/app/views/organizations/_organization_tabs.html.erb b/app/views/organizations/_organization_tabs.html.erb index 01b5b340d..04ffb535c 100644 --- a/app/views/organizations/_organization_tabs.html.erb +++ b/app/views/organizations/_organization_tabs.html.erb @@ -1,4 +1,4 @@ -<%# locals: (presenter) -%> +<%# locals: (presenter:) -%>
- <% template.results_template_categories.includes(:results_category).each do |rtc| %> + <% template.template_categories.includes(:category).each do |rtc| %> @@ -12,7 +12,7 @@ <% end %> - <% if template.results_template_categories.any?(&:fixed_position?) %> + <% if template.template_categories.any?(&:fixed_position?) %> diff --git a/spec/fixtures/results_template_categories.yml b/spec/fixtures/results_template_categories.yml index d73065394..46be5edf5 100644 --- a/spec/fixtures/results_template_categories.yml +++ b/spec/fixtures/results_template_categories.yml @@ -1,271 +1,271 @@ --- results_template_category_0001: - results_template: masters_and_grandmasters_with_nonbinary - results_category: female_40_to_49 + template: masters_and_grandmasters_with_nonbinary + category: female_40_to_49 position: 5 fixed_position: results_template_category_0002: - results_template: masters_and_decades - results_category: male_up_to_19 + template: masters_and_decades + category: male_up_to_19 position: 5 fixed_position: results_template_category_0003: - results_template: masters_and_grandmasters_with_nonbinary - results_category: female_50_and_up + template: masters_and_grandmasters_with_nonbinary + category: female_50_and_up position: 7 fixed_position: results_template_category_0004: - results_template: overall_30s_40s_50s_seniors - results_category: male_40_to_49_2 + template: overall_30s_40s_50s_seniors + category: male_40_to_49_2 position: 7 fixed_position: results_template_category_0005: - results_template: overall_30s_40s_50s_seniors - results_category: male_up_to_29 + template: overall_30s_40s_50s_seniors + category: male_up_to_29 position: 3 fixed_position: results_template_category_0006: - results_template: masters_and_decades - results_category: male_20_to_29 + template: masters_and_decades + category: male_20_to_29 position: 7 fixed_position: results_template_category_0007: - results_template: masters_and_decades - results_category: male_50_to_59 + template: masters_and_decades + category: male_50_to_59 position: 13 fixed_position: results_template_category_0008: - results_template: overall_30s_40s_50s_seniors - results_category: female_50_to_59 + template: overall_30s_40s_50s_seniors + category: female_50_to_59 position: 10 fixed_position: results_template_category_0009: - results_template: masters_and_grandmasters - results_category: female_50_and_up + template: masters_and_grandmasters + category: female_50_and_up position: 6 fixed_position: results_template_category_0010: - results_template: overall_30s_40s_50s_seniors - results_category: female_overall + template: overall_30s_40s_50s_seniors + category: female_overall position: 2 fixed_position: results_template_category_0011: - results_template: overall_30s_40s_50s_seniors - results_category: female_40_to_49_2 + template: overall_30s_40s_50s_seniors + category: female_40_to_49_2 position: 8 fixed_position: results_template_category_0012: - results_template: sub_masters_masters_and_grandmasters - results_category: female_up_to_39 + template: sub_masters_masters_and_grandmasters + category: female_up_to_39 position: 4 fixed_position: results_template_category_0013: - results_template: masters_and_grandmasters_with_nonbinary - results_category: nonbinary_overall + template: masters_and_grandmasters_with_nonbinary + category: nonbinary_overall position: 3 fixed_position: results_template_category_0014: - results_template: masters_and_grandmasters_with_nonbinary - results_category: male_overall + template: masters_and_grandmasters_with_nonbinary + category: male_overall position: 1 fixed_position: results_template_category_0015: - results_template: overall_30s_40s_50s_seniors - results_category: male_50_to_59 + template: overall_30s_40s_50s_seniors + category: male_50_to_59 position: 9 fixed_position: results_template_category_0016: - results_template: sub_masters_masters_and_grandmasters - results_category: male_up_to_39 + template: sub_masters_masters_and_grandmasters + category: male_up_to_39 position: 3 fixed_position: results_template_category_0017: - results_template: masters_and_decades - results_category: male_30_to_39 + template: masters_and_decades + category: male_30_to_39 position: 9 fixed_position: results_template_category_0018: - results_template: masters_and_grandmasters_with_nonbinary - results_category: male_40_to_49 + template: masters_and_grandmasters_with_nonbinary + category: male_40_to_49 position: 4 fixed_position: results_template_category_0019: - results_template: simple_with_nonbinary - results_category: female_overall + template: simple_with_nonbinary + category: female_overall position: 2 fixed_position: results_template_category_0020: - results_template: sub_masters_masters_and_grandmasters - results_category: male_40_to_49 + template: sub_masters_masters_and_grandmasters + category: male_40_to_49 position: 5 fixed_position: results_template_category_0021: - results_template: overall_30s_40s_50s_seniors - results_category: male_overall + template: overall_30s_40s_50s_seniors + category: male_overall position: 1 fixed_position: results_template_category_0022: - results_template: sub_masters_masters_and_grandmasters - results_category: female_40_to_49 + template: sub_masters_masters_and_grandmasters + category: female_40_to_49 position: 6 fixed_position: results_template_category_0023: - results_template: simple_with_nonbinary - results_category: male_overall + template: simple_with_nonbinary + category: male_overall position: 1 fixed_position: results_template_category_0024: - results_template: masters_and_decades - results_category: female_40_and_up + template: masters_and_decades + category: female_40_and_up position: 4 fixed_position: true results_template_category_0025: - results_template: masters_and_grandmasters - results_category: female_overall + template: masters_and_grandmasters + category: female_overall position: 2 fixed_position: results_template_category_0026: - results_template: masters_and_decades - results_category: male_40_and_up + template: masters_and_decades + category: male_40_and_up position: 3 fixed_position: true results_template_category_0027: - results_template: overall_30s_40s_50s_seniors - results_category: female_up_to_29 + template: overall_30s_40s_50s_seniors + category: female_up_to_29 position: 4 fixed_position: results_template_category_0028: - results_template: masters_and_decades - results_category: female_up_to_19 + template: masters_and_decades + category: female_up_to_19 position: 6 fixed_position: results_template_category_0029: - results_template: masters_and_decades - results_category: male_overall + template: masters_and_decades + category: male_overall position: 1 fixed_position: true results_template_category_0030: - results_template: masters_and_grandmasters - results_category: male_50_and_up + template: masters_and_grandmasters + category: male_50_and_up position: 5 fixed_position: results_template_category_0031: - results_template: overall_30s_40s_50s_seniors - results_category: female_30_to_39 + template: overall_30s_40s_50s_seniors + category: female_30_to_39 position: 6 fixed_position: results_template_category_0032: - results_template: masters_and_grandmasters_with_nonbinary - results_category: female_overall + template: masters_and_grandmasters_with_nonbinary + category: female_overall position: 2 fixed_position: results_template_category_0033: - results_template: overall_30s_40s_50s_seniors - results_category: female_60_and_up + template: overall_30s_40s_50s_seniors + category: female_60_and_up position: 12 fixed_position: results_template_category_0034: - results_template: sub_masters_masters_and_grandmasters - results_category: female_50_and_up + template: sub_masters_masters_and_grandmasters + category: female_50_and_up position: 8 fixed_position: results_template_category_0035: - results_template: simple - results_category: male_overall + template: simple + category: male_overall position: 1 fixed_position: results_template_category_0036: - results_template: masters_and_decades - results_category: female_40_to_49_2 + template: masters_and_decades + category: female_40_to_49_2 position: 12 fixed_position: results_template_category_0037: - results_template: masters_and_decades - results_category: male_60_to_69 + template: masters_and_decades + category: male_60_to_69 position: 15 fixed_position: results_template_category_0038: - results_template: masters_and_grandmasters - results_category: female_40_to_49 + template: masters_and_grandmasters + category: female_40_to_49 position: 4 fixed_position: results_template_category_0039: - results_template: masters_and_grandmasters_with_nonbinary - results_category: male_50_and_up + template: masters_and_grandmasters_with_nonbinary + category: male_50_and_up position: 6 fixed_position: results_template_category_0040: - results_template: overall_30s_40s_50s_seniors - results_category: male_60_and_up + template: overall_30s_40s_50s_seniors + category: male_60_and_up position: 11 fixed_position: results_template_category_0041: - results_template: sub_masters_masters_and_grandmasters - results_category: female_overall + template: sub_masters_masters_and_grandmasters + category: female_overall position: 2 fixed_position: results_template_category_0042: - results_template: masters_and_decades - results_category: female_20_to_29 + template: masters_and_decades + category: female_20_to_29 position: 8 fixed_position: results_template_category_0043: - results_template: simple - results_category: female_overall + template: simple + category: female_overall position: 2 fixed_position: results_template_category_0044: - results_template: masters_and_decades - results_category: female_50_to_59 + template: masters_and_decades + category: female_50_to_59 position: 14 fixed_position: results_template_category_0045: - results_template: masters_and_decades - results_category: male_40_to_49_2 + template: masters_and_decades + category: male_40_to_49_2 position: 11 fixed_position: results_template_category_0046: - results_template: simple_with_nonbinary - results_category: nonbinary_overall + template: simple_with_nonbinary + category: nonbinary_overall position: 3 fixed_position: results_template_category_0047: - results_template: masters_and_grandmasters - results_category: male_overall + template: masters_and_grandmasters + category: male_overall position: 1 fixed_position: results_template_category_0048: - results_template: overall_30s_40s_50s_seniors - results_category: male_30_to_39 + template: overall_30s_40s_50s_seniors + category: male_30_to_39 position: 5 fixed_position: results_template_category_0049: - results_template: masters_and_decades - results_category: female_30_to_39 + template: masters_and_decades + category: female_30_to_39 position: 10 fixed_position: results_template_category_0050: - results_template: masters_and_grandmasters - results_category: male_40_to_49 + template: masters_and_grandmasters + category: male_40_to_49 position: 3 fixed_position: results_template_category_0051: - results_template: sub_masters_masters_and_grandmasters - results_category: male_50_and_up + template: sub_masters_masters_and_grandmasters + category: male_50_and_up position: 7 fixed_position: results_template_category_0052: - results_template: sub_masters_masters_and_grandmasters - results_category: male_overall + template: sub_masters_masters_and_grandmasters + category: male_overall position: 1 fixed_position: results_template_category_0053: - results_template: masters_and_decades - results_category: female_60_to_69 + template: masters_and_decades + category: female_60_to_69 position: 16 fixed_position: results_template_category_0054: - results_template: masters_and_decades - results_category: female_overall + template: masters_and_decades + category: female_overall position: 2 fixed_position: true diff --git a/spec/models/results_template_category_spec.rb b/spec/models/results_template_category_spec.rb index 70bff2f23..b131e0c65 100644 --- a/spec/models/results_template_category_spec.rb +++ b/spec/models/results_template_category_spec.rb @@ -3,24 +3,24 @@ require "rails_helper" RSpec.describe ResultsTemplateCategory do - subject(:results_template_category) { ResultsTemplateCategory.first } + subject(:template_category) { ResultsTemplateCategory.first } describe "#initialize" do it "is valid when it has both a results category and a results template" do - expect(results_template_category).to be_valid + expect(template_category).to be_valid end end describe "methods" do describe "#category_description" do it "returns the description of the associated results_category" do - expect(results_template_category.category_description).to eq(results_template_category.results_category.description) + expect(template_category.category_description).to eq(template_category.category.description) end end describe "#category_name" do it "returns the name of the associated results_category" do - expect(results_template_category.category_name).to eq(results_template_category.results_category.name) + expect(template_category.category_name).to eq(template_category.category.name) end end end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 7800ff1fe..b3c9ed8b4 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -82,7 +82,7 @@ :users, ] - config.fixture_path = "#{::Rails.root}/spec/fixtures" + config.fixture_path = ["#{::Rails.root}/spec/fixtures"] # If you're not using ActiveRecord, or you'd prefer not to run each of your # examples within a transaction, remove the following line or assign false
<%= "#{'*' if rtc.fixed_position}" %> <%= "#{rtc.position}." %>
* Position is fixed