From eb33a6535d84552ccc24cb8d5dd71b8c4f7cd27d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 5 Jun 2025 05:31:12 +0000 Subject: [PATCH 01/22] Bump rack from 3.1.14 to 3.1.16 in the bundler group across 1 directory Bumps the bundler group with 1 update in the / directory: [rack](https://github.com/rack/rack). Updates `rack` from 3.1.14 to 3.1.16 - [Release notes](https://github.com/rack/rack/releases) - [Changelog](https://github.com/rack/rack/blob/main/CHANGELOG.md) - [Commits](https://github.com/rack/rack/compare/v3.1.14...v3.1.16) --- updated-dependencies: - dependency-name: rack dependency-version: 3.1.16 dependency-type: indirect dependency-group: bundler ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index bfc51257..daf162a5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -317,7 +317,7 @@ GEM rspec-mocks (~> 3.12) rspec-support (~> 3.12) racc (1.8.1) - rack (3.1.14) + rack (3.1.16) rack-accept (0.4.5) rack (>= 0.4) rack-protection (4.1.1) From 4f8021b4e2def0e505758bf23496b7efa6106f7c Mon Sep 17 00:00:00 2001 From: rsmokeUM Date: Thu, 5 Jun 2025 17:15:09 -0400 Subject: [PATCH 02/22] Remove unused address building logic in ProfilesController - Eliminated the building of home and campus address attributes in the `show` action, streamlining profile loading. - Updated strong parameters to reflect the removal of address attributes, ensuring cleaner data handling. --- app/controllers/profiles_controller.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb index af7c1e83..6ca25811 100644 --- a/app/controllers/profiles_controller.rb +++ b/app/controllers/profiles_controller.rb @@ -28,8 +28,6 @@ def new Rails.logger.debug { "^^^^^^^^^^^^^^^^ Profile is nil for user: #{current_user.inspect}" } else authorize @profile - @profile.build_home_address - @profile.build_campus_address end end @@ -86,8 +84,6 @@ def profile_params :major, :department, :grad_date, :degree, :receiving_financial_aid, :accepted_financial_aid_notice, :financial_aid_description, - :hometown_publication, :pen_name, - home_address_attributes: %i[id address1 address2 city state zip country address_type_id], - campus_address_attributes: %i[id address1 address2 city state zip country address_type_id]) + :hometown_publication, :pen_name) end end From 0f3058dc00b1349db2752f651e50f9ab1b077cfd Mon Sep 17 00:00:00 2001 From: rsmokeUM Date: Thu, 5 Jun 2025 17:15:51 -0400 Subject: [PATCH 03/22] Remove AddressCopyController and its registration from Stimulus application - Deleted the AddressCopyController, which was responsible for copying address fields between home and campus addresses. - Removed the controller's registration from the main Stimulus application index, streamlining the JavaScript codebase by eliminating unused functionality. --- .../controllers/address_copy_controller.js | 17 ----------------- app/javascript/controllers/index.js | 3 --- 2 files changed, 20 deletions(-) delete mode 100644 app/javascript/controllers/address_copy_controller.js diff --git a/app/javascript/controllers/address_copy_controller.js b/app/javascript/controllers/address_copy_controller.js deleted file mode 100644 index e09b4301..00000000 --- a/app/javascript/controllers/address_copy_controller.js +++ /dev/null @@ -1,17 +0,0 @@ -import { Controller } from "@hotwired/stimulus" - -export default class extends Controller { - static targets = [ - "homeAddress1", "homeAddress2", "homeCity", "homeState", "homeZip", "homeCountry", - "campusAddress1", "campusAddress2", "campusCity", "campusState", "campusZip", "campusCountry" - ] - - copy() { - this.homeAddress1Target.value = this.campusAddress1Target.value - this.homeAddress2Target.value = this.campusAddress2Target.value - this.homeCityTarget.value = this.campusCityTarget.value - this.homeStateTarget.value = this.campusStateTarget.value - this.homeZipTarget.value = this.campusZipTarget.value - this.homeCountryTarget.value = this.campusCountryTarget.value - } -} \ No newline at end of file diff --git a/app/javascript/controllers/index.js b/app/javascript/controllers/index.js index d4b7e30a..896a70fa 100644 --- a/app/javascript/controllers/index.js +++ b/app/javascript/controllers/index.js @@ -4,9 +4,6 @@ import { application } from "./application" -import AddressCopyController from "./address_copy_controller" -application.register("address-copy", AddressCopyController) - import CharacterCounterController from "./character_counter_controller" application.register("character-counter", CharacterCounterController) From 255ad39d820b20aa199b029e727f2ddd3fcc3459 Mon Sep 17 00:00:00 2001 From: rsmokeUM Date: Thu, 5 Jun 2025 17:16:11 -0400 Subject: [PATCH 04/22] Remove Address and AddressType models along with their associated logic - Deleted the Address and AddressType models, which were previously responsible for managing address-related data and validations. - This cleanup eliminates unused code and simplifies the application structure, enhancing maintainability. --- app/models/address.rb | 108 ------------------------------------- app/models/address_type.rb | 19 ------- 2 files changed, 127 deletions(-) delete mode 100644 app/models/address.rb delete mode 100644 app/models/address_type.rb diff --git a/app/models/address.rb b/app/models/address.rb deleted file mode 100644 index d24098fc..00000000 --- a/app/models/address.rb +++ /dev/null @@ -1,108 +0,0 @@ -# frozen_string_literal: true - -# == Schema Information -# -# Table name: addresses -# -# id :bigint not null, primary key -# address1 :string(255) -# address2 :string(255) -# city :string(255) -# country :string(255) -# state :string(255) -# zip :string(255) -# created_at :datetime not null -# updated_at :datetime not null -# address_type_id :bigint -# -# Indexes -# -# address_type_id_idx (address_type_id) -# id_unq_idx (id) UNIQUE -# index_addresses_on_address_type_id (address_type_id) -# -# Foreign Keys -# -# fk_rails_... (address_type_id => address_types.id) -# - -class Address < ApplicationRecord - belongs_to :address_type - has_many :home_profiles, class_name: 'Profile', foreign_key: 'home_address_id', dependent: :restrict_with_exception - has_many :campus_profiles, class_name: 'Profile', foreign_key: 'campus_address_id', dependent: :restrict_with_exception - - validates :address1, :city, :state, :zip, :country, presence: true - - STATES = - [ - [ 'Alabama', 'AL' ], - [ 'Alaska', 'AK' ], - [ 'Arizona', 'AZ' ], - [ 'Arkansas', 'AR' ], - [ 'California', 'CA' ], - [ 'Colorado', 'CO' ], - [ 'Connecticut', 'CT' ], - [ 'Delaware', 'DE' ], - [ 'District of Columbia', 'DC' ], - [ 'Florida', 'FL' ], - [ 'Georgia', 'GA' ], - [ 'Hawaii', 'HI' ], - [ 'Idaho', 'ID' ], - [ 'Illinois', 'IL' ], - [ 'Indiana', 'IN' ], - [ 'Iowa', 'IA' ], - [ 'Kansas', 'KS' ], - [ 'Kentucky', 'KY' ], - [ 'Louisiana', 'LA' ], - [ 'Maine', 'ME' ], - [ 'Maryland', 'MD' ], - [ 'Massachusetts', 'MA' ], - [ 'Michigan', 'MI' ], - [ 'Minnesota', 'MN' ], - [ 'Mississippi', 'MS' ], - [ 'Missouri', 'MO' ], - [ 'Montana', 'MT' ], - [ 'Nebraska', 'NE' ], - [ 'Nevada', 'NV' ], - [ 'New Hampshire', 'NH' ], - [ 'New Jersey', 'NJ' ], - [ 'New Mexico', 'NM' ], - [ 'New York', 'NY' ], - [ 'North Carolina', 'NC' ], - [ 'North Dakota', 'ND' ], - [ 'Ohio', 'OH' ], - [ 'Oklahoma', 'OK' ], - [ 'Oregon', 'OR' ], - [ 'Pennsylvania', 'PA' ], - [ 'Puerto Rico', 'PR' ], - [ 'Rhode Island', 'RI' ], - [ 'South Carolina', 'SC' ], - [ 'South Dakota', 'SD' ], - [ 'Tennessee', 'TN' ], - [ 'Texas', 'TX' ], - [ 'Utah', 'UT' ], - [ 'Vermont', 'VT' ], - [ 'Virginia', 'VA' ], - [ 'Washington', 'WA' ], - [ 'West Virginia', 'WV' ], - [ 'Wisconsin', 'WI' ], - [ 'Wyoming', 'WY' ] - ].freeze - - # def full_address - # "#{address1} #{address2} #{city}, #{state} #{zip}" - # end - def full_address - "#{address1}\n#{address2.present? ? "#{address2}\n" : ''}#{city}, #{state} #{zip}\n#{country_abbreviation}" - end - - def country_name - country_data = ISO3166::Country[country] - country_data.translations[I18n.locale.to_s] || country_data.name if country_data - end - - def country_abbreviation - country_data = ISO3166::Country[country] - country_data.alpha2 if country_data - end -end diff --git a/app/models/address_type.rb b/app/models/address_type.rb deleted file mode 100644 index d869c3a3..00000000 --- a/app/models/address_type.rb +++ /dev/null @@ -1,19 +0,0 @@ -# == Schema Information -# -# Table name: address_types -# -# id :bigint not null, primary key -# description :text(65535) -# kind :string(255) not null -# created_at :datetime not null -# updated_at :datetime not null -# -# Indexes -# -# id_unq_idx (id) UNIQUE -# index_address_types_on_kind (kind) UNIQUE -# -class AddressType < ApplicationRecord - has_many :addresses - validates :kind, presence: true, uniqueness: true -end From 375de2ea4423eed4aaafafe57c73473c0d40418e Mon Sep 17 00:00:00 2001 From: rsmokeUM Date: Thu, 5 Jun 2025 17:16:24 -0400 Subject: [PATCH 05/22] Remove AddressPolicy class to streamline authorization logic - Deleted the AddressPolicy class, which was responsible for managing authorization rules related to address actions. - This removal contributes to a cleaner codebase by eliminating unused policy logic, following the recent removal of address-related models and controllers. --- app/policies/address_policy.rb | 50 ---------------------------------- 1 file changed, 50 deletions(-) delete mode 100644 app/policies/address_policy.rb diff --git a/app/policies/address_policy.rb b/app/policies/address_policy.rb deleted file mode 100644 index cac3e2a1..00000000 --- a/app/policies/address_policy.rb +++ /dev/null @@ -1,50 +0,0 @@ -# app/policies/address_policy.rb -class AddressPolicy < ApplicationPolicy - def index? - axis_mundi? - end - - def show? - axis_mundi? || owner? - end - - def create? - axis_mundi? || owner? - end - - def new? - create? - end - - def update? - axis_mundi? || owner? - end - - def edit? - update? - end - - def destroy? - axis_mundi? - end - - private - - # Checks if the user owns the address via their profile - def owner? - user && ( - record == user.profile&.home_address || - record == user.profile&.campus_address - ) - end - - class Scope < Scope - def resolve - if user&.axis_mundi? - scope.all - else - scope.none - end - end - end -end From cd472aee91ce7b81cd225f7f274c6f7ae315d647 Mon Sep 17 00:00:00 2001 From: rsmokeUM Date: Thu, 5 Jun 2025 17:16:58 -0400 Subject: [PATCH 06/22] Refactor Profile model by removing address associations and validations - Eliminated the `home_address` and `campus_address` associations from the Profile model, streamlining the data structure. - Removed related validations for addresses, enhancing the model's clarity and focus on essential attributes. - This change aligns with recent cleanups of address-related logic, contributing to a more maintainable codebase. --- app/models/profile.rb | 41 +++++++++++++---------------------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/app/models/profile.rb b/app/models/profile.rb index 6c7b5e7e..20520d2c 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -20,34 +20,28 @@ # umid :string(255) # created_at :datetime not null # updated_at :datetime not null -# campus_address_id :bigint # campus_id :bigint # class_level_id :bigint -# home_address_id :bigint # school_id :bigint # user_id :bigint not null # # Indexes # -# campus_id_idx (campus_id) -# class_level_id_idx (class_level_id) -# id_unq_idx (id) UNIQUE -# index_profiles_on_campus_address_id (campus_address_id) -# index_profiles_on_campus_id (campus_id) -# index_profiles_on_class_level_id (class_level_id) -# index_profiles_on_home_address_id (home_address_id) -# index_profiles_on_school_id (school_id) -# index_profiles_on_umid (umid) UNIQUE -# index_profiles_on_user_id (user_id) -# school_id_idx (school_id) -# user_id_idx (user_id) +# campus_id_idx (campus_id) +# class_level_id_idx (class_level_id) +# id_unq_idx (id) UNIQUE +# index_profiles_on_campus_id (campus_id) +# index_profiles_on_class_level_id (class_level_id) +# index_profiles_on_school_id (school_id) +# index_profiles_on_umid (umid) UNIQUE +# index_profiles_on_user_id (user_id) +# school_id_idx (school_id) +# user_id_idx (user_id) # # Foreign Keys # -# fk_rails_... (campus_address_id => addresses.id) # fk_rails_... (campus_id => campuses.id) # fk_rails_... (class_level_id => class_levels.id) -# fk_rails_... (home_address_id => addresses.id) # fk_rails_... (school_id => schools.id) # fk_rails_... (user_id => users.id) # @@ -60,17 +54,11 @@ class Profile < ApplicationRecord belongs_to :campus, optional: true has_many :entries, dependent: :restrict_with_error - belongs_to :home_address, class_name: 'Address', optional: true - belongs_to :campus_address, class_name: 'Address', optional: true - - accepts_nested_attributes_for :home_address, allow_destroy: true - accepts_nested_attributes_for :campus_address, allow_destroy: true - validates :preferred_first_name, presence: true, length: { in: 1..255 } validates :preferred_last_name, presence: true, length: { in: 1..255 } - validates :umid, - presence: true, - uniqueness: true, + validates :umid, + presence: true, + uniqueness: true, length: { is: 8 }, format: { with: /\A\d{8}\z/, message: "must be exactly 8 digits" } validates :grad_date, presence: true @@ -79,9 +67,6 @@ class Profile < ApplicationRecord validates :class_level_id, presence: true validates :campus_id, presence: true validates :school_id, presence: true - validates :home_address, presence: true - validates :campus_address, presence: true - def display_name "#{preferred_first_name} #{preferred_last_name}" From e339d20982ce3f8b8d3a241c9e0a6e313e2d9691 Mon Sep 17 00:00:00 2001 From: rsmokeUM Date: Thu, 5 Jun 2025 17:17:19 -0400 Subject: [PATCH 07/22] Refactor profile form by removing address fields and associated logic - Eliminated the address input fields for campus and hometown addresses from the profile form, streamlining the user interface. - Removed the data-controller attribute for address copying, as the related functionality has been deprecated. - This change aligns with recent cleanups of address-related logic, contributing to a more focused and maintainable profile form. --- app/views/profiles/_form.html.erb | 73 ++----------------------------- 1 file changed, 4 insertions(+), 69 deletions(-) diff --git a/app/views/profiles/_form.html.erb b/app/views/profiles/_form.html.erb index b55288be..56c07f25 100644 --- a/app/views/profiles/_form.html.erb +++ b/app/views/profiles/_form.html.erb @@ -5,7 +5,7 @@ <%= f.error_notification %> <%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %> -
+

Contact Information

@@ -29,69 +29,6 @@ <%= f.input :pen_name, label: "Default pen name (optional)", hint: "Set a default pen name to use for future contest entries that require one. You can leave this blank if you prefer to enter a pen name each time. The pen name should bear no resemblance to your real name or any other personal information." %>
- -
-

Local (campus) Address

- (Please provide your current campus address) - <%= f.simple_fields_for :campus_address do |address_form| %> -
-
- <%= address_form.input :address1, input_html: { data: { target: "address-copy.campusAddress1" } } %> -
-
- <%= address_form.input :address2, input_html: { data: { target: "address-copy.campusAddress2" } } %> -
-
-
-
- <%= address_form.input :city, input_html: { data: { target: "address-copy.campusCity" } } %> -
-
- <%= address_form.input :state, collection: Address::STATES, input_html: { data: { target: "address-copy.campusState" } } %> -
-
-
-
- <%= address_form.input :zip, input_html: { data: { target: "address-copy.campusZip" } } %> -
-
- <%= address_form.input :country, priority: ["United States"], input_html: { data: { target: "address-copy.campusCountry" } } %> - <%= address_form.input :address_type_id, as: :hidden, input_html: { value: AddressType.find_by(kind: 'Campus').id } %> -
-
- <% end %> - - - -

Hometown Address

- <%= f.simple_fields_for :home_address do |address_form| %> -
-
- <%= address_form.input :address1, input_html: { data: { target: "address-copy.homeAddress1" } } %> -
-
- <%= address_form.input :address2, input_html: { data: { target: "address-copy.homeAddress2" } } %> -
-
-
-
- <%= address_form.input :city, input_html: { data: { target: "address-copy.homeCity" } } %> -
-
- <%= address_form.input :state, collection: Address::STATES, input_html: { data: { target: "address-copy.homeState" } } %> -
-
-
-
- <%= address_form.input :zip, input_html: { data: { target: "address-copy.homeZip" } } %> -
-
- <%= address_form.input :country, priority: ["United States"], input_html: { data: { target: "address-copy.homeCountry" } } %> - <%= address_form.input :address_type_id, as: :hidden, input_html: { value: AddressType.find_by(kind: 'Home').id } %> -
-
- <% end %> -

Academic Information

@@ -117,13 +54,11 @@

Publicity

- -
- <%= f.input :hometown_publication, label: "Name of your hometown newspaper or preferred media outlet:", hint: "For some contests, if your manuscript earns an award, the award’s committee will forward a press release to your local newspaper or media outlet." %> -
+
+ <%= f.input :hometown_publication, label: "Name of your hometown newspaper or preferred media outlet:", hint: "For some contests, if your manuscript earns an award, the award's committee will forward a press release to your local newspaper or media outlet." %> +
-
<% if (content = render_editable_content('profiles', 'information')) %> From b3069aa5e3429169a8a19749c3f0e21d33b3a60e Mon Sep 17 00:00:00 2001 From: rsmokeUM Date: Thu, 5 Jun 2025 17:17:28 -0400 Subject: [PATCH 08/22] Refactor profile summary view to enhance layout and maintainability - Updated the profile summary view by restructuring the layout for better alignment and readability. - Reintroduced the edit profile link in a more accessible position, improving user experience. - Removed deprecated address sections to streamline the profile display, aligning with recent changes in the profile model and form. --- app/views/profiles/_profile_summary.html.erb | 44 +++++++------------- 1 file changed, 16 insertions(+), 28 deletions(-) diff --git a/app/views/profiles/_profile_summary.html.erb b/app/views/profiles/_profile_summary.html.erb index cf628eae..c8764e6b 100644 --- a/app/views/profiles/_profile_summary.html.erb +++ b/app/views/profiles/_profile_summary.html.erb @@ -7,31 +7,10 @@

Welcome
<%= @profile.preferred_first_name %>!

UMID: <%= @profile.umid %>

- -
- <%= link_to edit_profile_path(@profile), class: 'text-white link-underline link-underline-opacity-0' do %> - Edit - <% end %> -
+
- -
-
-

- Hometown Address: - <%= simple_format(@profile.home_address.full_address, class: "text-white fw-light lh-1 pt-1 ms-2 small") if @profile.home_address %> -

-
-
-

- Local(campus) Address: - <%= simple_format(@profile.campus_address.full_address, class: "text-white fw-light lh-1 ms-2 pt-1 small") if @profile.campus_address %> -

-
-
-
@@ -134,10 +113,19 @@
- -
-

- Last updated:
<%= @profile.updated_at.strftime("%B %d, %Y") %>
-

+
+ +
+

+ Last updated:
+ <%= @profile.updated_at.strftime("%B %d, %Y") %>
+

+
+ +
+ <%= link_to edit_profile_path(@profile), class: 'text-white link-underline link-underline-opacity-0' do %> + + <% end %> +
-
\ No newline at end of file + From fc2a5ffd8f190acc345efdcfba07977477e96ec5 Mon Sep 17 00:00:00 2001 From: rsmokeUM Date: Thu, 5 Jun 2025 17:17:35 -0400 Subject: [PATCH 09/22] Refactor profile view to improve layout and clarity - Streamlined the profile view by consolidating address-related sections and enhancing the display of academic information. - Updated the layout for better readability, including consistent use of Bootstrap classes for spacing and alignment. - Renamed the "Publicity" section to "Financial Aid" and adjusted the content accordingly, ensuring accurate representation of profile data. --- app/views/profiles/_profile.html.erb | 84 +++++++++++++++------------- 1 file changed, 46 insertions(+), 38 deletions(-) diff --git a/app/views/profiles/_profile.html.erb b/app/views/profiles/_profile.html.erb index 6630c186..01698a72 100644 --- a/app/views/profiles/_profile.html.erb +++ b/app/views/profiles/_profile.html.erb @@ -16,12 +16,10 @@
-
Local(campus) Address:<%= simple_format(profile.campus_address.full_address, {class:"fw-light"}) if profile.campus_address %>
-
Hometown Address:<%= simple_format(profile.home_address.full_address, {class:"fw-light"}) if profile.home_address %>
+ <% if profile.pen_name.present? %> +

Default pen name: <%= simple_format(profile.pen_name, {class:"fw-light"}) %>

+ <% end %>
- <% if profile.pen_name.present? %> -

Default pen name: <%= simple_format(profile.pen_name, {class:"fw-light"}) %>

- <% end %>
@@ -31,55 +29,65 @@

Academic Information

-
-
-

Class Level:
<%= profile.class_level.name if profile.class_level %>

-

School or College:
<%= profile.school.name if profile.school %>

-

Primary Campus Class Location:
<%= profile.campus.campus_descr if profile.campus %>

- <% if @profile&.major.present? %> -

Major (if undergraduate):
<%= profile.major %>

- <% end %> - <% if @profile&.department.present? %> -

Department (if graduate):
<%= profile.department if profile.department %>

- <% end %> -

Expected Graduation Date:
<%= profile.grad_date.strftime("%B %Y") %>

-

Degree:
<%= profile.degree %>

+
+
+
+

Class Level: <%= simple_format(profile.class_level.name, {class:"fw-light"}) %>

+

School or College: <%= simple_format(profile.school.name, {class:"fw-light"}) %>

+

Primary Campus Class Location: <%= simple_format(profile.campus.campus_descr, {class:"fw-light"}) %>

+ <% if profile.major.present? %> +

Major: <%= simple_format(profile.major, {class:"fw-light"}) %>

+ <% end %> + <% if profile.department.present? %> +

Department: <%= simple_format(profile.department, {class:"fw-light"}) %>

+ <% end %> +

Expected Graduation Date: <%= simple_format(profile.grad_date.strftime("%B %Y"), {class:"fw-light"}) %>

+

Degree: <%= simple_format(profile.degree, {class:"fw-light"}) %>

+
- <% if @profile.receiving_financial_aid && @profile.financial_aid_description.present? %> -
-
-

Financial Aid

-
-
+
+
+

Publicity

+
+
+
-

Financial Aid:
<%= profile.receiving_financial_aid ? 'Yes' : 'No' %>

- <% if profile.receiving_financial_aid %> -

Financial Aid Description:
<%= profile.financial_aid_description %>

- <% end %> + Entrant's name as it will appear in publicity:
+ (This is the name you entered as your preferred name.) + <%= simple_format(profile.display_name, {class:"fw-light"}) %>
+ <% if profile.hometown_publication.present? %> +
+
+ Hometown newspaper or preferred media outlet:
+ <%= simple_format(profile.hometown_publication, {class:"fw-light"}) %> +
+
+ <% end %>
- <% end %> +
-

Publicity

+

Financial Aid

-
-
- Entrant’s name as it will appear in publicity:
- (This is the name you entered as your preferred name.) - <%= simple_format(profile.display_name, {class:"fw-light"}) %> - <% if profile.hometown_publication.present? %> -

Name of your hometown newspaper or preferred media outlet:
<%= profile.hometown_publication %>

- <% end %> +
+
+
+ Receiving financial aid: <%= simple_format(profile.receiving_financial_aid ? "Yes" : "No", {class:"fw-light"}) %> + <% if profile.receiving_financial_aid && profile.financial_aid_description.present? %> +
+ Description: <%= simple_format(profile.financial_aid_description, {class:"fw-light"}) %> + <% end %> +
From bef7085cbda56d587b3f68528826622b9aaafaa5 Mon Sep 17 00:00:00 2001 From: rsmokeUM Date: Thu, 5 Jun 2025 17:18:21 -0400 Subject: [PATCH 10/22] Remove address-related tables and columns from the database schema - Dropped the `addresses` and `address_types` tables to eliminate unused address data structures. - Removed `home_address_id` and `campus_address_id` columns from the `profiles` table, along with their associated foreign keys. - Updated the schema version to reflect these changes, streamlining the database structure and enhancing maintainability. --- ...35_remove_address_columns_from_profiles.rb | 8 +++++ .../20250605210643_drop_address_tables.rb | 36 +++++++++++++++++++ db/schema.rb | 33 +---------------- 3 files changed, 45 insertions(+), 32 deletions(-) create mode 100644 db/migrate/20250605204535_remove_address_columns_from_profiles.rb create mode 100644 db/migrate/20250605210643_drop_address_tables.rb diff --git a/db/migrate/20250605204535_remove_address_columns_from_profiles.rb b/db/migrate/20250605204535_remove_address_columns_from_profiles.rb new file mode 100644 index 00000000..9e7e55d2 --- /dev/null +++ b/db/migrate/20250605204535_remove_address_columns_from_profiles.rb @@ -0,0 +1,8 @@ +class RemoveAddressColumnsFromProfiles < ActiveRecord::Migration[7.1] + def change + remove_foreign_key :profiles, :addresses, column: :home_address_id + remove_foreign_key :profiles, :addresses, column: :campus_address_id + remove_column :profiles, :home_address_id, :bigint + remove_column :profiles, :campus_address_id, :bigint + end +end diff --git a/db/migrate/20250605210643_drop_address_tables.rb b/db/migrate/20250605210643_drop_address_tables.rb new file mode 100644 index 00000000..63e15ffe --- /dev/null +++ b/db/migrate/20250605210643_drop_address_tables.rb @@ -0,0 +1,36 @@ +class DropAddressTables < ActiveRecord::Migration[7.1] + def up + # Drop tables in reverse order of dependencies + drop_table :addresses + drop_table :address_types + end + + def down + # Recreate address_types table + create_table :address_types do |t| + t.string :kind, null: false + t.text :description + + t.timestamps + end + + add_index :address_types, :kind, unique: true + add_index :address_types, :id, unique: true, name: 'id_unq_idx' + + # Recreate addresses table + create_table :addresses do |t| + t.string :address1 + t.string :address2 + t.string :city + t.string :state + t.string :zip + t.string :country + t.references :address_type, null: false, foreign_key: true + + t.timestamps + end + + add_index :addresses, :id, unique: true, name: 'id_unq_idx' + add_index :addresses, :address_type_id, name: 'address_type_id_idx' + end +end diff --git a/db/schema.rb b/db/schema.rb index 64c25b4d..eab24cc8 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.2].define(version: 2025_03_12_173602) do +ActiveRecord::Schema[7.2].define(version: 2025_06_05_210643) do create_table "action_text_rich_texts", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t| t.string "name", null: false t.text "body", size: :long @@ -49,30 +49,6 @@ t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true end - create_table "address_types", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t| - t.string "kind", null: false - t.text "description" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.index ["id"], name: "id_unq_idx", unique: true - t.index ["kind"], name: "index_address_types_on_kind", unique: true - end - - create_table "addresses", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t| - t.string "address1" - t.string "address2" - t.string "city" - t.string "state" - t.string "zip" - t.string "country" - t.bigint "address_type_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.index ["address_type_id"], name: "address_type_id_idx" - t.index ["address_type_id"], name: "index_addresses_on_address_type_id" - t.index ["id"], name: "id_unq_idx", unique: true - end - create_table "affiliations", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t| t.string "name" t.bigint "user_id", null: false @@ -294,17 +270,13 @@ t.string "pen_name" t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.bigint "home_address_id" - t.bigint "campus_address_id" t.boolean "campus_employee", default: false, null: false t.string "department" t.string "umid" - t.index ["campus_address_id"], name: "index_profiles_on_campus_address_id" t.index ["campus_id"], name: "campus_id_idx" t.index ["campus_id"], name: "index_profiles_on_campus_id" t.index ["class_level_id"], name: "class_level_id_idx" t.index ["class_level_id"], name: "index_profiles_on_class_level_id" - t.index ["home_address_id"], name: "index_profiles_on_home_address_id" t.index ["id"], name: "id_unq_idx", unique: true t.index ["school_id"], name: "index_profiles_on_school_id" t.index ["school_id"], name: "school_id_idx" @@ -385,7 +357,6 @@ add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id" add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id" - add_foreign_key "addresses", "address_types" add_foreign_key "affiliations", "users" add_foreign_key "assignments", "containers" add_foreign_key "assignments", "roles" @@ -407,8 +378,6 @@ add_foreign_key "judging_assignments", "contest_instances" add_foreign_key "judging_assignments", "users" add_foreign_key "judging_rounds", "contest_instances" - add_foreign_key "profiles", "addresses", column: "campus_address_id" - add_foreign_key "profiles", "addresses", column: "home_address_id" add_foreign_key "profiles", "campuses" add_foreign_key "profiles", "class_levels" add_foreign_key "profiles", "schools" From 133c85b6acf2e25de2fddcafb656fe6ccab2331b Mon Sep 17 00:00:00 2001 From: rsmokeUM Date: Thu, 5 Jun 2025 17:18:30 -0400 Subject: [PATCH 11/22] Remove address seeding logic from db/seeds.rb - Eliminated the creation of AddressType and Address records from the seed file, reflecting the recent removal of address-related models and data structures. - This change streamlines the seeding process and aligns with the overall cleanup of address-related functionality in the application. --- db/seeds.rb | 36 ------------------------------------ 1 file changed, 36 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index 12fbde51..62ed52f5 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -86,42 +86,6 @@ { name: 'Other' } ]) - AddressType.create([ - { kind: 'Home', description: 'Home address' }, - { kind: 'Campus', description: 'Campus address' } - ]) - - # Create Addresses - Address.create([ - { - address1: Faker::Address.street_address, - address2: Faker::Address.secondary_address, - city: Faker::Address.city, - state: Faker::Address.state_abbr, - zip: Faker::Address.zip_code, - country: Faker::Address.country_code, - address_type: AddressType.find_by(kind: 'Home') - }, - { - address1: Faker::Address.street_address, - address2: Faker::Address.secondary_address, - city: Faker::Address.city, - state: Faker::Address.state_abbr, - zip: Faker::Address.zip_code, - country: Faker::Address.country_code, - address_type: AddressType.find_by(kind: 'Campus') - }, - { - address1: Faker::Address.street_address, - address2: Faker::Address.secondary_address, - city: Faker::Address.city, - state: Faker::Address.state_abbr, - zip: Faker::Address.zip_code, - country: Faker::Address.country_code, - address_type: AddressType.find_by(kind: 'Home') - } - ]) - # Seed data for Campus Campus.create([ { campus_descr: 'Ann Arbor', campus_cd: 100 }, From d59dba83ec46b917b77fa267dc1e395af0ba80da Mon Sep 17 00:00:00 2001 From: rsmokeUM Date: Thu, 5 Jun 2025 17:18:39 -0400 Subject: [PATCH 12/22] Update sample data task to create development data - Refactored the `create_entries` task into a new `create` task for generating sample data in the development environment. - Introduced roles, campuses, schools, and class levels, ensuring they are created if they don't exist. - Added logic to create sample users with profiles, including random attributes and role assignments. - Removed the previous contest entry creation logic, streamlining the task for development purposes. --- lib/tasks/sample_data.rake | 192 ++++++++++++------------------------- 1 file changed, 62 insertions(+), 130 deletions(-) diff --git a/lib/tasks/sample_data.rake b/lib/tasks/sample_data.rake index 5dc06bca..6930d849 100644 --- a/lib/tasks/sample_data.rake +++ b/lib/tasks/sample_data.rake @@ -1,140 +1,72 @@ namespace :sample_data do - desc 'Create sample contest entries for testing' - task create_entries: :environment do - if Rails.env.production? - puts 'This task cannot be run in the production environment.' - exit - end - - # Find or create required records - contest_description = ContestDescription.first || ContestDescription.create!( - name: 'Sample Contest 2024', - created_by: 'system', - container: Container.first || Container.create!( - name: 'Sample Container', - department: Department.first || Department.create!(name: 'Sample Department'), - visibility: Visibility.first || Visibility.create!(kind: 'Public') - ) - ) - - contest_instance = ContestInstance.first || - ContestInstance.create!( - contest_description: contest_description, - description: 'A sample contest for testing', - date_open: Date.today, - date_closed: 1.month.from_now, - require_pen_name: true, - created_by: 'system' - ) - - category = Category.first || Category.create!(kind: 'Poetry', description: 'Poetry submissions') - - # Create required reference data if not exists - class_level = ClassLevel.first || ClassLevel.create!(name: 'Senior', description: 'Fourth year student') - school = School.first || School.create!(name: 'Literature, Science, and the Arts') - campus = Campus.first || Campus.create!(campus_descr: 'Ann Arbor', campus_cd: 1) - - # Create address types if they don't exist - home_type = AddressType.find_or_create_by!(kind: 'Home', description: 'Home address') - campus_type = AddressType.find_or_create_by!(kind: 'Campus', description: 'Campus address') - - # Sample titles for creative writing entries - titles = [ - 'The Last Sunset', - 'Whispers in the Wind', - 'Beyond the Horizon', - 'Echoes of Tomorrow', - 'The Silent Garden', - 'Memories of Rain', - 'The Forgotten Door', - 'Dancing Shadows', - 'The Crystal Key', - "Autumn's Secret", - 'The Time Keeper', - "Midnight's Promise", - 'The Paper Boat', - "Winter's Song" - ] - - # Create entries - titles.each_with_index do |title, index| - # Create addresses - home_address = Address.create!( - address_type: home_type, - address1: "#{1000 + index} Home St", - city: 'Ann Arbor', - state: 'MI', - zip: '48109', - country: 'USA' + desc 'Create sample data for development' + task create: :environment do + # Create roles if they don't exist + axis_mundi_role = Role.find_or_create_by!(kind: 'Axis Mundi', description: 'Administrator role') + collection_admin_role = Role.find_or_create_by!(kind: 'Collection Administrator', description: 'Collection administrator role') + + # Create campuses if they don't exist + ann_arbor_campus = Campus.find_or_create_by!(name: 'Ann Arbor', description: 'Ann Arbor campus') + dearborn_campus = Campus.find_or_create_by!(name: 'Dearborn', description: 'Dearborn campus') + flint_campus = Campus.find_or_create_by!(name: 'Flint', description: 'Flint campus') + + # Create schools if they don't exist + lsa = School.find_or_create_by!(name: 'LSA', description: 'College of Literature, Science, and the Arts') + engineering = School.find_or_create_by!(name: 'Engineering', description: 'College of Engineering') + business = School.find_or_create_by!(name: 'Business', description: 'Ross School of Business') + + # Create class levels if they don't exist + freshman = ClassLevel.find_or_create_by!(name: 'Freshman', description: 'First year student') + sophomore = ClassLevel.find_or_create_by!(name: 'Sophomore', description: 'Second year student') + junior = ClassLevel.find_or_create_by!(name: 'Junior', description: 'Third year student') + senior = ClassLevel.find_or_create_by!(name: 'Senior', description: 'Fourth year student') + + # Create sample users with profiles + 5.times do |index| + # Create user + user = User.create!( + email: "user#{index + 1}@example.com", + first_name: Faker::Name.first_name, + last_name: Faker::Name.last_name, + uniqname: "user#{index + 1}", + uid: "user#{index + 1}", + display_name: "User #{index + 1}", + password: 'passwordpassword', + affiliations_attributes: [ + { name: 'student' }, + { name: 'member' } + ] ) - campus_address = Address.create!( - address_type: campus_type, - address1: "#{2000 + index} Campus Dr", - city: 'Ann Arbor', - state: 'MI', - zip: '48109', - country: 'USA' + # Create profile + p = Profile.create!( + user: user, + preferred_first_name: user.first_name, + preferred_last_name: user.last_name, + umid: format('%08d', rand(10000000..99999999)), + class_level: [freshman, sophomore, junior, senior].sample, + school: [lsa, engineering, business].sample, + campus: [ann_arbor_campus, dearborn_campus, flint_campus].sample, + major: Faker::Educator.subject, + department: Faker::Educator.subject, + grad_date: Date.today + rand(1..4).years, + degree: ['Bachelor\'s', 'Master\'s', 'PhD'].sample, + receiving_financial_aid: [true, false].sample, + accepted_financial_aid_notice: true, + campus_employee: [true, false].sample, + financial_aid_description: Faker::Lorem.paragraph, + hometown_publication: Faker::Address.city, + pen_name: Faker::Book.author ) - # Create a user for each entry - user = User.find_or_create_by!(email: "author#{index + 1}@example.com") do |u| - u.first_name = 'Author' - u.last_name = "#{index + 1}" - u.password = 'ThisIsALongPassword123!@#' - u.password_confirmation = 'ThisIsALongPassword123!@#' - end - - # Create a profile for the user - profile = Profile.find_or_create_by!(user: user) do |p| - p.preferred_first_name = user.first_name - p.preferred_last_name = user.last_name - p.grad_date = Date.new(2024, 5, 1) - p.degree = 'BA' - p.umid = format('%08d', index + 10000000) # 8-digit UMID - p.class_level = class_level - p.campus = campus - p.school = school - p.major = 'Creative Writing' - p.home_address = home_address - p.campus_address = campus_address - end - - Entry.find_or_create_by!(title: title) do |entry| - entry.contest_instance = contest_instance - entry.profile = profile - entry.category = category - entry.pen_name = "Poet#{index + 1}" - entry.created_at = Time.current - rand(1..30).days - - # Create a temporary markdown file - temp_file = Tempfile.new([ 'entry', '.md' ]) - temp_file.write("# #{title}\n\n") - temp_file.write("## By #{entry.pen_name}\n\n") - temp_file.write("This is a sample entry for testing purposes.\n\n") - temp_file.write('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.') - temp_file.rewind - - # Convert to PDF using pandoc - pdf_file = Tempfile.new([ 'entry', '.pdf' ]) - system("pandoc #{temp_file.path} -o #{pdf_file.path}") - - # Attach the PDF file to the entry - entry.entry_file.attach( - io: File.open(pdf_file.path), - filename: "#{title.downcase.gsub(/[^a-z0-9]/, '_')}.pdf", - content_type: 'application/pdf' - ) - - temp_file.close - temp_file.unlink - pdf_file.close - pdf_file.unlink - - puts "Created entry: #{title} by #{profile.preferred_first_name} #{profile.preferred_last_name} (#{entry.pen_name})" + # Assign roles to some users + if index < 2 + UserRole.create!(user: user, role: axis_mundi_role) + elsif index < 4 + UserRole.create!(user: user, role: collection_admin_role) end end - puts "\nCreated #{titles.length} sample entries for contest: #{contest_instance.contest_description.name}" + puts 'Sample data created successfully!' end end From 69b8e645b36942c92c746c86fb59f52573fdf854 Mon Sep 17 00:00:00 2001 From: rsmokeUM Date: Thu, 5 Jun 2025 17:18:58 -0400 Subject: [PATCH 13/22] Remove address-related factories and specs to streamline test suite - Deleted the factories for Address and AddressType, which were no longer needed following the removal of their corresponding models. - Removed associated RSpec tests for Address and AddressType, ensuring the test suite reflects the current application structure and maintains clarity. - This change aligns with the ongoing cleanup of address-related functionality in the codebase. --- spec/factories/address_types.rb | 33 ------- spec/factories/addresses.rb | 37 -------- spec/models/address_spec.rb | 124 --------------------------- spec/models/address_type_spec.rb | 35 -------- spec/policies/address_policy_spec.rb | 103 ---------------------- 5 files changed, 332 deletions(-) delete mode 100644 spec/factories/address_types.rb delete mode 100644 spec/factories/addresses.rb delete mode 100644 spec/models/address_spec.rb delete mode 100644 spec/models/address_type_spec.rb delete mode 100644 spec/policies/address_policy_spec.rb diff --git a/spec/factories/address_types.rb b/spec/factories/address_types.rb deleted file mode 100644 index acf514c6..00000000 --- a/spec/factories/address_types.rb +++ /dev/null @@ -1,33 +0,0 @@ -# == Schema Information -# -# Table name: address_types -# -# id :bigint not null, primary key -# description :text(65535) -# kind :string(255) not null -# created_at :datetime not null -# updated_at :datetime not null -# -# Indexes -# -# id_unq_idx (id) UNIQUE -# index_address_types_on_kind (kind) UNIQUE -# -FactoryBot.define do - factory :address_type do - # kind { 'Home' } - sequence(:kind) { |n| "Kind #{n}" } # Use a unique sequence for kind - description { Faker::Lorem.sentence } - - trait :home do - kind { 'Home' } - end - - trait :campus do - kind { 'Campus' } - end - - factory :home_address_type, traits: [ :home ] - factory :campus_address_type, traits: [ :campus ] - end -end diff --git a/spec/factories/addresses.rb b/spec/factories/addresses.rb deleted file mode 100644 index ef2b6258..00000000 --- a/spec/factories/addresses.rb +++ /dev/null @@ -1,37 +0,0 @@ -# == Schema Information -# -# Table name: addresses -# -# id :bigint not null, primary key -# address1 :string(255) -# address2 :string(255) -# city :string(255) -# country :string(255) -# state :string(255) -# zip :string(255) -# created_at :datetime not null -# updated_at :datetime not null -# address_type_id :bigint -# -# Indexes -# -# address_type_id_idx (address_type_id) -# id_unq_idx (id) UNIQUE -# index_addresses_on_address_type_id (address_type_id) -# -# Foreign Keys -# -# fk_rails_... (address_type_id => address_types.id) -# - -FactoryBot.define do - factory :address do - address1 { Faker::Address.street_address } - address2 { Faker::Address.secondary_address } - city { Faker::Address.city } - state { Faker::Address.state_abbr } - zip { Faker::Address.zip_code } - country { Faker::Address.country_code } - address_type - end -end diff --git a/spec/models/address_spec.rb b/spec/models/address_spec.rb deleted file mode 100644 index c26c00d7..00000000 --- a/spec/models/address_spec.rb +++ /dev/null @@ -1,124 +0,0 @@ -# == Schema Information -# -# Table name: addresses -# -# id :bigint not null, primary key -# address1 :string(255) -# address2 :string(255) -# city :string(255) -# country :string(255) -# state :string(255) -# zip :string(255) -# created_at :datetime not null -# updated_at :datetime not null -# address_type_id :bigint -# -# Indexes -# -# address_type_id_idx (address_type_id) -# id_unq_idx (id) UNIQUE -# index_addresses_on_address_type_id (address_type_id) -# -# Foreign Keys -# -# fk_rails_... (address_type_id => address_types.id) -# - -require 'rails_helper' - -RSpec.describe Address do - before do - @address_type = AddressType.create(kind: 'Home') - end - - it 'is valid with valid attributes' do - address = Address.new( - address1: Faker::Address.street_address, - address2: Faker::Address.secondary_address, - city: Faker::Address.city, - state: Faker::Number.between(from: 1, to: 50), - zip: Faker::Address.zip_code, - country: Faker::Number.between(from: 1, to: 250), - address_type: @address_type - ) - expect(address).to be_valid - end - - it 'is not valid without address1' do - address = Address.new( - address1: nil, - address2: Faker::Address.secondary_address, - city: Faker::Address.city, - state: Faker::Number.between(from: 1, to: 50), - zip: Faker::Address.zip_code, - country: Faker::Number.between(from: 1, to: 250), - address_type: @address_type - ) - expect(address).not_to be_valid - end - - it 'is not valid without city' do - address = Address.new( - address1: Faker::Address.street_address, - address2: Faker::Address.secondary_address, - city: nil, - state: Faker::Number.between(from: 1, to: 50), - zip: Faker::Address.zip_code, - country: Faker::Number.between(from: 1, to: 250), - address_type: @address_type - ) - expect(address).not_to be_valid - end - - it 'is not valid without state' do - address = Address.new( - address1: Faker::Address.street_address, - address2: Faker::Address.secondary_address, - city: Faker::Address.city, - state: nil, - zip: Faker::Address.zip_code, - country: Faker::Number.between(from: 1, to: 250), - address_type: @address_type - ) - expect(address).not_to be_valid - end - - it 'is not valid without zip' do - address = Address.new( - address1: Faker::Address.street_address, - address2: Faker::Address.secondary_address, - city: Faker::Address.city, - state: Faker::Number.between(from: 1, to: 50), - zip: nil, - country: Faker::Number.between(from: 1, to: 250), - address_type: @address_type - ) - expect(address).not_to be_valid - end - - it 'is not valid without country' do - address = Address.new( - address1: Faker::Address.street_address, - address2: Faker::Address.secondary_address, - city: Faker::Address.city, - state: Faker::Number.between(from: 1, to: 50), - zip: Faker::Address.zip_code, - country: nil, - address_type: @address_type - ) - expect(address).not_to be_valid - end - - it 'is not valid without address_type' do - address = Address.new( - address1: Faker::Address.street_address, - address2: Faker::Address.secondary_address, - city: Faker::Address.city, - state: Faker::Number.between(from: 1, to: 50), - zip: Faker::Address.zip_code, - country: Faker::Number.between(from: 1, to: 250), - address_type: nil - ) - expect(address).not_to be_valid - end -end diff --git a/spec/models/address_type_spec.rb b/spec/models/address_type_spec.rb deleted file mode 100644 index 649e751b..00000000 --- a/spec/models/address_type_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -# == Schema Information -# -# Table name: address_types -# -# id :bigint not null, primary key -# description :text(65535) -# kind :string(255) not null -# created_at :datetime not null -# updated_at :datetime not null -# -# Indexes -# -# id_unq_idx (id) UNIQUE -# index_address_types_on_kind (kind) UNIQUE -# -require 'rails_helper' - -RSpec.describe AddressType, type: :model do - before do - described_class.delete_all - end - - it 'is valid with valid attributes' do - expect(build(:address_type)).to be_valid - end - - it 'is not valid without a kind' do - expect(build(:address_type, kind: nil)).not_to be_valid - end - - it 'is not valid with a duplicate kind' do - create(:address_type, kind: 'Home') - expect(build(:address_type, kind: 'Home')).not_to be_valid - end -end diff --git a/spec/policies/address_policy_spec.rb b/spec/policies/address_policy_spec.rb deleted file mode 100644 index 2db4e901..00000000 --- a/spec/policies/address_policy_spec.rb +++ /dev/null @@ -1,103 +0,0 @@ -# spec/policies/address_policy_spec.rb -require 'rails_helper' - -RSpec.describe AddressPolicy do - subject { described_class.new(user, address) } - - let(:owned_address) { create(:address) } - let(:other_address) { create(:address) } - let(:address) { owned_address } # Default address for tests - - let(:address_owner_user) { create(:user) } - let(:axis_mundi_user) { create(:user) } - let(:other_user) { create(:user) } - - let(:axis_mundi_role) { create(:role, kind: 'Axis Mundi') } - - before do - # Assign the Axis Mundi role to the axis_mundi_user - create(:user_role, user: axis_mundi_user, role: axis_mundi_role) - - # Create a profile for the address_owner_user with the owned_address as home_address - create(:profile, user: address_owner_user, home_address: owned_address) - end - - context 'when user is axis mundi' do - let(:user) { axis_mundi_user } - - it { is_expected.to permit_action(:index) } - it { is_expected.to permit_action(:show) } - it { is_expected.to permit_action(:create) } - it { is_expected.to permit_action(:new) } - it { is_expected.to permit_action(:update) } - it { is_expected.to permit_action(:edit) } - it { is_expected.to permit_action(:destroy) } - end - - context 'when user is the owner of the address' do - let(:user) { address_owner_user } - - it { is_expected.not_to permit_action(:index) } - it { is_expected.to permit_action(:show) } - it { is_expected.to permit_action(:create) } - it { is_expected.to permit_action(:new) } - it { is_expected.to permit_action(:update) } - it { is_expected.to permit_action(:edit) } - it { is_expected.not_to permit_action(:destroy) } - end - - context 'when user owns a different address' do - let(:user) { address_owner_user } - let(:address) { other_address } - - it { is_expected.not_to permit_action(:show) } - it { is_expected.not_to permit_action(:update) } - end - - context 'when user is not the owner and not axis mundi' do - let(:user) { other_user } - - it { is_expected.not_to permit_action(:index) } - it { is_expected.not_to permit_action(:show) } - it { is_expected.not_to permit_action(:create) } - it { is_expected.not_to permit_action(:new) } - it { is_expected.not_to permit_action(:update) } - it { is_expected.not_to permit_action(:edit) } - it { is_expected.not_to permit_action(:destroy) } - end - - context 'when user is nil (not logged in)' do - let(:user) { nil } - - it { is_expected.not_to permit_action(:index) } - it { is_expected.not_to permit_action(:show) } - it { is_expected.not_to permit_action(:create) } - it { is_expected.not_to permit_action(:new) } - it { is_expected.not_to permit_action(:update) } - it { is_expected.not_to permit_action(:edit) } - it { is_expected.not_to permit_action(:destroy) } - end - - describe 'Scope' do - subject { Pundit.policy_scope(user, Address) } - - let!(:address1) { create(:address) } - let!(:address2) { create(:address) } - - context 'when user is axis mundi' do - let(:user) { axis_mundi_user } - - it 'includes all addresses' do - expect(subject).to include(address1, address2) - end - end - - context 'when user is not axis mundi' do - let(:user) { other_user } - - it 'returns an empty scope' do - expect(subject).to be_empty - end - end - end -end From d4fa586649281e7d8de8e27cc98029da610c5759 Mon Sep 17 00:00:00 2001 From: rsmokeUM Date: Thu, 5 Jun 2025 17:19:08 -0400 Subject: [PATCH 14/22] Refactor profile factory by removing address associations - Eliminated the `home_address` and `campus_address` associations from the profile factory, reflecting the recent removal of address-related functionality. - Updated the factory definition to streamline test data generation, ensuring it aligns with the current application structure. --- spec/factories/profiles.rb | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/spec/factories/profiles.rb b/spec/factories/profiles.rb index 08a5e4ca..c35111f9 100644 --- a/spec/factories/profiles.rb +++ b/spec/factories/profiles.rb @@ -20,34 +20,28 @@ # umid :string(255) # created_at :datetime not null # updated_at :datetime not null -# campus_address_id :bigint # campus_id :bigint # class_level_id :bigint -# home_address_id :bigint # school_id :bigint # user_id :bigint not null # # Indexes # -# campus_id_idx (campus_id) -# class_level_id_idx (class_level_id) -# id_unq_idx (id) UNIQUE -# index_profiles_on_campus_address_id (campus_address_id) -# index_profiles_on_campus_id (campus_id) -# index_profiles_on_class_level_id (class_level_id) -# index_profiles_on_home_address_id (home_address_id) -# index_profiles_on_school_id (school_id) -# index_profiles_on_umid (umid) UNIQUE -# index_profiles_on_user_id (user_id) -# school_id_idx (school_id) -# user_id_idx (user_id) +# campus_id_idx (campus_id) +# class_level_id_idx (class_level_id) +# id_unq_idx (id) UNIQUE +# index_profiles_on_campus_id (campus_id) +# index_profiles_on_class_level_id (class_level_id) +# index_profiles_on_school_id (school_id) +# index_profiles_on_umid (umid) UNIQUE +# index_profiles_on_user_id (user_id) +# school_id_idx (school_id) +# user_id_idx (user_id) # # Foreign Keys # -# fk_rails_... (campus_address_id => addresses.id) # fk_rails_... (campus_id => campuses.id) # fk_rails_... (class_level_id => class_levels.id) -# fk_rails_... (home_address_id => addresses.id) # fk_rails_... (school_id => schools.id) # fk_rails_... (user_id => users.id) # @@ -71,7 +65,5 @@ financial_aid_description { Faker::Lorem.paragraph } hometown_publication { Faker::Address.city } pen_name { Faker::Book.author } - home_address { association :address } - campus_address { association :address } end end From 2b8d6c4b286ebbdf4bc78a3bffa4445465e3271a Mon Sep 17 00:00:00 2001 From: rsmokeUM Date: Thu, 5 Jun 2025 17:19:15 -0400 Subject: [PATCH 15/22] Refactor profile specs to remove address-related tests - Eliminated tests for `home_address` and `campus_address` associations in the Profile model specs, reflecting the recent removal of address-related functionality. - Updated the associated records setup to streamline test data generation, ensuring alignment with the current application structure. --- spec/models/profile_spec.rb | 55 ++++++++----------------------------- 1 file changed, 12 insertions(+), 43 deletions(-) diff --git a/spec/models/profile_spec.rb b/spec/models/profile_spec.rb index e8fbfe8f..29a88548 100644 --- a/spec/models/profile_spec.rb +++ b/spec/models/profile_spec.rb @@ -20,34 +20,28 @@ # umid :string(255) # created_at :datetime not null # updated_at :datetime not null -# campus_address_id :bigint # campus_id :bigint # class_level_id :bigint -# home_address_id :bigint # school_id :bigint # user_id :bigint not null # # Indexes # -# campus_id_idx (campus_id) -# class_level_id_idx (class_level_id) -# id_unq_idx (id) UNIQUE -# index_profiles_on_campus_address_id (campus_address_id) -# index_profiles_on_campus_id (campus_id) -# index_profiles_on_class_level_id (class_level_id) -# index_profiles_on_home_address_id (home_address_id) -# index_profiles_on_school_id (school_id) -# index_profiles_on_umid (umid) UNIQUE -# index_profiles_on_user_id (user_id) -# school_id_idx (school_id) -# user_id_idx (user_id) +# campus_id_idx (campus_id) +# class_level_id_idx (class_level_id) +# id_unq_idx (id) UNIQUE +# index_profiles_on_campus_id (campus_id) +# index_profiles_on_class_level_id (class_level_id) +# index_profiles_on_school_id (school_id) +# index_profiles_on_umid (umid) UNIQUE +# index_profiles_on_user_id (user_id) +# school_id_idx (school_id) +# user_id_idx (user_id) # # Foreign Keys # -# fk_rails_... (campus_address_id => addresses.id) # fk_rails_... (campus_id => campuses.id) # fk_rails_... (class_level_id => class_levels.id) -# fk_rails_... (home_address_id => addresses.id) # fk_rails_... (school_id => schools.id) # fk_rails_... (user_id => users.id) # @@ -56,14 +50,11 @@ RSpec.describe Profile do let(:user) { create(:user) } - let(:addresses) { create_list(:address, 2) } let(:associated_records) do { class_level: create(:class_level), school: create(:school), - campus: create(:campus), - home_address: addresses.first, - campus_address: addresses.second + campus: create(:campus) } end @@ -159,26 +150,6 @@ it 'belongs to campus' do expect(profile.campus).to eq(associated_records[:campus]) end - - it 'belongs to home_address' do - expect(profile.home_address).to eq(associated_records[:home_address]) - end - - it 'belongs to campus_address' do - expect(profile.campus_address).to eq(associated_records[:campus_address]) - end - - it 'accepts nested attributes for home_address' do - profile_attributes = attributes_for(:profile, home_address_attributes: attributes_for(:address)) - profile = described_class.new(profile_attributes) - expect(profile.home_address).to be_present - end - - it 'accepts nested attributes for campus_address' do - profile_attributes = attributes_for(:profile, campus_address_attributes: attributes_for(:address)) - profile = described_class.new(profile_attributes) - expect(profile.campus_address).to be_present - end end describe 'callbacks' do @@ -202,9 +173,7 @@ { class_level: create(:class_level), school: create(:school), - campus: create(:campus), - home_address: create(:address), - campus_address: create(:address) + campus: create(:campus) } end From 635aea7ae4d45a7418c562aa012157ed16f8f1d2 Mon Sep 17 00:00:00 2001 From: rsmokeUM Date: Thu, 5 Jun 2025 17:19:22 -0400 Subject: [PATCH 16/22] Refactor profile policy specs to remove address-related references - Updated the ProfilePolicy specs to eliminate references to `home_address` and `campus_address`, reflecting the recent removal of address-related functionality. - Streamlined test cases for clarity and alignment with the current application structure, ensuring a focused approach to policy testing. --- spec/policies/profile_policy_spec.rb | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/spec/policies/profile_policy_spec.rb b/spec/policies/profile_policy_spec.rb index ec7714b6..cc254a35 100644 --- a/spec/policies/profile_policy_spec.rb +++ b/spec/policies/profile_policy_spec.rb @@ -7,8 +7,7 @@ create(:profile, accepted_financial_aid_notice: true, preferred_first_name: 'John', preferred_last_name: 'Doe', umid: '12345678', grad_date: Date.today + 1.year, degree: 'Bachelor', class_level_id: create(:class_level).id, campus_id: create(:campus).id, - school_id: create(:school).id, home_address: create(:address), - campus_address: create(:address)) + school_id: create(:school).id) end let(:axis_mundi_role) { create(:role, kind: 'Axis Mundi') } @@ -46,25 +45,25 @@ let(:user) { create(:user) } # The user we're testing let(:another_user) { create(:user) } # A different user let(:profile) { create(:profile, user: another_user) } # Profile belongs to another user - + it 'permits new and create actions' do # Ensure the user does not have a profile expect(user.profile).to be_nil - + # Test new? policy expect(subject).to permit_action(:new) - + # Test create? policy expect(subject).to permit_action(:create) end - + it 'forbids show, update, and destroy actions' do # Test show? policy expect(subject).not_to permit_action(:show) - + # Test update? policy expect(subject).not_to permit_action(:update) - + # Test destroy? policy expect(subject).not_to permit_action(:destroy) end From 8100736db1566bf5cf8c758119b74bb71eaf52b7 Mon Sep 17 00:00:00 2001 From: rsmokeUM Date: Thu, 5 Jun 2025 17:19:32 -0400 Subject: [PATCH 17/22] Refactor user creation helpers to remove address-related attributes - Eliminated `home_address` and `campus_address` attributes from user creation helper methods, reflecting the recent removal of address-related functionality. - Streamlined user creation logic to ensure alignment with the current application structure and maintain clarity in test data generation. --- spec/support/user_creation_helpers.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/spec/support/user_creation_helpers.rb b/spec/support/user_creation_helpers.rb index 3d624f83..ca258034 100644 --- a/spec/support/user_creation_helpers.rb +++ b/spec/support/user_creation_helpers.rb @@ -30,9 +30,7 @@ def create_ugrad_student_with_profile(class_level_name) campus: create(:campus), grad_date: Date.today + 1.year, degree: "Bachelor's", - umid: format('%08d', rand(10000000..99999999)), - home_address: create(:address, address_type: create(:address_type, :home)), - campus_address: create(:address, address_type: create(:address_type, :campus)) + umid: format('%08d', rand(10000000..99999999)) ) user @@ -64,9 +62,7 @@ def create_gradstudent_with_profile(class_level_name) campus: create(:campus), grad_date: Date.today + 1.year, degree: "Master's", - umid: format('%08d', rand(10000000..99999999)), - home_address: create(:address, address_type: create(:address_type, :home)), - campus_address: create(:address, address_type: create(:address_type, :campus)) + umid: format('%08d', rand(10000000..99999999)) ) user From ca9179502b25fe934f112fbd29aaed954a33d090 Mon Sep 17 00:00:00 2001 From: rsmokeUM Date: Mon, 9 Jun 2025 12:39:53 -0400 Subject: [PATCH 18/22] Refactor contest descriptions helper to enhance instance summary display - Updated the summary generation logic to improve clarity by changing the label for active instances to "Active" and the total instances to "Total". - Streamlined the HTML output for better readability and consistency in the user interface. --- app/helpers/contest_descriptions_helper.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/helpers/contest_descriptions_helper.rb b/app/helpers/contest_descriptions_helper.rb index 44b1ee76..55a63fa9 100644 --- a/app/helpers/contest_descriptions_helper.rb +++ b/app/helpers/contest_descriptions_helper.rb @@ -6,12 +6,11 @@ def contest_description_summary(description) if active_instances.any? first_active = active_instances.first entry_count = first_active.entries.where(deleted: false).count - summary += 'Active instance
' - summary += link_to(pluralize(entry_count, 'entry'), - container_contest_description_contest_instance_path(description.container, description, first_active), class: 'btn btn-sm btn-primary') + summary += link_to("Active: #{pluralize(entry_count, 'entry')}", + container_contest_description_contest_instance_path(description.container, description, first_active), class: 'btn btn-sm btn-primary small') summary += '
' end - summary += "#{pluralize(total_instances, 'instance')}" + summary += "Total: #{pluralize(total_instances, 'instance')}" content_tag(:div, summary.html_safe, class: 'text-muted') end From 3e3c1af7d90c2e4e9a258725fb6f408fe104f2ca Mon Sep 17 00:00:00 2001 From: rsmokeUM Date: Mon, 9 Jun 2025 12:40:01 -0400 Subject: [PATCH 19/22] Update contest descriptions table header for clarity - Changed the column header from "Summary" to "Instance Details" in the contest descriptions table to better reflect the content displayed. - This update enhances the user interface by providing clearer context for the information presented. --- app/views/containers/_contest_descriptions_table.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/containers/_contest_descriptions_table.html.erb b/app/views/containers/_contest_descriptions_table.html.erb index 69cb9ca0..3d688076 100644 --- a/app/views/containers/_contest_descriptions_table.html.erb +++ b/app/views/containers/_contest_descriptions_table.html.erb @@ -4,7 +4,7 @@ Name - Summary + Instance Details Short Name Eligibility Rules Notes From 0a6f43a789b1dfa7324e4be7889602a7c2121b78 Mon Sep 17 00:00:00 2001 From: rsmokeUM Date: Mon, 9 Jun 2025 15:48:54 -0400 Subject: [PATCH 20/22] Refactor contest descriptions helper to simplify total instances display - Updated the summary output in the contest descriptions helper by removing the "Total:" label, enhancing clarity and conciseness in the displayed information. - This change improves the user interface by streamlining the presentation of instance counts. --- app/helpers/contest_descriptions_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/contest_descriptions_helper.rb b/app/helpers/contest_descriptions_helper.rb index 55a63fa9..5e53842d 100644 --- a/app/helpers/contest_descriptions_helper.rb +++ b/app/helpers/contest_descriptions_helper.rb @@ -10,7 +10,7 @@ def contest_description_summary(description) container_contest_description_contest_instance_path(description.container, description, first_active), class: 'btn btn-sm btn-primary small') summary += '
' end - summary += "Total: #{pluralize(total_instances, 'instance')}" + summary += "#{pluralize(total_instances, 'instance')}" content_tag(:div, summary.html_safe, class: 'text-muted') end From 011b2aa3e59f527b75cf230813c6a1f7a5df5bc3 Mon Sep 17 00:00:00 2001 From: rsmokeUM Date: Tue, 10 Jun 2025 09:22:21 -0400 Subject: [PATCH 21/22] Update eligibility rules display in containers helper for improved readability - Adjusted the truncation length of eligibility rules from 100 to 60 characters to enhance clarity in the user interface. - Modified the link text to include a space before '...more', improving the visual separation and overall presentation of the content. --- app/helpers/containers_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helpers/containers_helper.rb b/app/helpers/containers_helper.rb index 7fa7bcf9..ed112856 100644 --- a/app/helpers/containers_helper.rb +++ b/app/helpers/containers_helper.rb @@ -18,8 +18,8 @@ def render_eligibility_rules(description) eligibility_plain = description.eligibility_rules.to_plain_text if eligibility_plain.length > 100 content_tag(:div) do - truncate(eligibility_plain, length: 100, omission: '') + - link_to('...more', '#', + truncate(eligibility_plain, length: 60, omission: '') + + link_to(' ...more', '#', data: { action: 'click->modal#open', url: eligibility_rules_container_contest_description_path(description.container, description), From 489e7a564201a70b08e216bd61b672b2f7aa64ed Mon Sep 17 00:00:00 2001 From: rsmokeUM Date: Tue, 10 Jun 2025 09:23:03 -0400 Subject: [PATCH 22/22] Enhance contest descriptions table for improved readability - Updated the contest descriptions table to include clearer column headers and improved layout, enhancing the user interface. - Adjusted the display of names and statuses for better visibility, including truncation for long text. - Refined action links and button styles for a more consistent and user-friendly experience. --- .../_contest_descriptions_table.html.erb | 55 ++++++++++++------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/app/views/containers/_contest_descriptions_table.html.erb b/app/views/containers/_contest_descriptions_table.html.erb index 3d688076..2c8a6d84 100644 --- a/app/views/containers/_contest_descriptions_table.html.erb +++ b/app/views/containers/_contest_descriptions_table.html.erb @@ -1,41 +1,56 @@ <%# app/views/containers/_contest_descriptions_table.html.erb %>
- +
- - - - - - - + + + + + + + <% descriptions.each do |description| %> - - - - + - + - - +
NameInstance DetailsShort NameEligibility RulesNotesActiveActionsNameStatusShort NameEligibilityNotesActiveActions
<%= description.name %><%= contest_description_summary(description) %><%= description.short_name %> - <%= render_eligibility_rules(description) %> + + + <%= description.name %> + + + <%= contest_description_summary(description) %> + + + <%= description.short_name %> + + + + <%# <% if description.notes.present? %> - <%= link_to "view", container_contest_description_contest_instances_path(container, description) %> + <%= link_to "view", container_contest_description_contest_instances_path(container, description), class: "btn btn-link btn-sm p-0", title: "View notes", aria: { label: "View notes for #{description.name}" } %> <% end %> <%= boolean_to_yes_no(description.active) %> -
+
+ <%= boolean_to_yes_no(description.active) %> + +
<% contest_description_action_links(container, description).each do |action, config| %> <%= link_to config[:path], - class: 'd-block', + class: 'btn btn-link btn-sm p-0', data: config[:data]&.merge('bs-toggle': 'tooltip'), title: config[:title], aria: { label: config[:title] } do %> - + <%= config[:title] %> <% end %> <% end %>