Skip to content

Commit

Permalink
Merge branch 'BIB-49-rails-7-production' into BIB-46-dual-boot-with-r…
Browse files Browse the repository at this point in the history
…ails-7-1
  • Loading branch information
torresga authored Sep 26, 2024
2 parents f9b5d0a + 764b5ff commit 1a5ba72
Show file tree
Hide file tree
Showing 20 changed files with 126 additions and 63 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ group :development, :test do
# the gem version hasn't been updated in a long time github.com/pry/pry-coolline/issues/22
# https://github.com/pry/pry-coolline/commit/f3a130c9829969732977015a04e90b9fb5d281b2
# gem "jazz_fingers"
gem "parallel_tests"
gem "parallel_tests", "~> 3.5.2"
gem "pry-byebug"
gem "pry-rails"
gem "rb-fsevent", "~> 0.10.3"
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@ DEPENDENCIES
omniauth-globalid
omniauth-strava
omniauth-twitter
parallel_tests
parallel_tests (~> 3.5.2)
paranoia
pg (~> 1.0)
pg_search
Expand Down
1 change: 1 addition & 0 deletions Gemfile.next.lock
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ GEM
i18n (>= 1.6, < 2)
minitest (>= 5.1)
mutex_m

tzinfo (~> 2.0)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
Expand Down
8 changes: 4 additions & 4 deletions app/models/cycle_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ class CycleType
cargo: "Cargo Bike (front storage)",
"tall-bike": "Tall Bike",
"penny-farthing": "Penny Farthing",
"cargo-rear": "Cargo Bike (rear storage)",
"cargo-rear": "Cargo Bike Rear (e.g. longtail)",
"cargo-trike": "Cargo Tricycle (front storage)",
"cargo-trike-rear": "Cargo Tricycle (rear storage)",
"trail-behind": "Trail behind (half bike)",
"pedi-cab": "Pedi Cab (rickshaw)",
"e-scooter": "e-Scooter",
"personal-mobility": "e-Skateboard (e-Unicycle, Personal mobility device, etc)",
"non-e-scooter": "Scooter (Not electric)",
"non-e-skateboard": "Skateboard (Not electric)",
"e-motorcycle": "e-Motorcycle (or e-Dirtbike)"
"non-e-scooter": "Scooter (not electric)",
"non-e-skateboard": "Skateboard (not electric)",
"e-motorcycle": "e-Motorcycle/e-Dirtbike (no pedals)"
}.freeze

MODEST_PRIORITY = %i[personal-mobility recumbent tandem tricycle].freeze
Expand Down
30 changes: 15 additions & 15 deletions app/views/bikes/new.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -53,29 +53,29 @@
= t(".missing_serial")

.related-fields
.form-group.row.unnested-field
.form-group.row
= f.label :cycle_type, t(".this_is_a"), class: 'form-well-label'
.form-well-input
- if @bike.cycle_type == "bike"
%label.collapse.in.pt-1.pl-1.cursor-pointer
= check_box_tag :traditional_bike_checkbox, true, true
= t(".traditional_bike")
%span.below-input-help{style: "font-size: 100%; padding: 0 0 0 1.1em"}
%em= t(".traditional_bike_definition")
%em= t(".traditional_bike_definition")

.cycle-type-select.fancy-select.unfancy{class: @bike.cycle_type == "bike" ? "collapse" : ""}
= select(:bike, :cycle_type, CycleType.select_options, {prompt: false}, {required: true, class: 'form-control'})
%label#motorizedWrapper.cursor-pointer.mt-1.mb-0.pl-1
= check_box_tag :propulsion_type_motorized, true
%strong ⚡️
= t(".electric")
(motorized)
#propulsionTypeFields.collapse.pl-1
%label.checkbox-inline.mr-2
= check_box_tag :propulsion_type_throttle, true, @bike.propulsion_type_throttle?
Throttle
%label.checkbox-inline
= check_box_tag :propulsion_type_pedal_assist, true, @bike.propulsion_type_pedal_assist?
Pedal assist
%label#motorizedWrapper.cursor-pointer.mt-1.mb-0.pl-1
= check_box_tag :propulsion_type_motorized, true
%strong ⚡️
= t(".electric")
(motorized)
#propulsionTypeFields.collapse.pl-1
%label.checkbox-inline.mr-2
= check_box_tag :propulsion_type_throttle, true, @bike.propulsion_type_throttle?
Throttle
%label.checkbox-inline
= check_box_tag :propulsion_type_pedal_assist, true, @bike.propulsion_type_pedal_assist?
Pedal assist

.related-fields
.form-group.row
Expand Down
10 changes: 5 additions & 5 deletions app/views/registrations/embed.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
- email_placeholder ||= t(".owner_email", owner: current_organization&.school? ? current_organization.short_name : t(".your"))
= f.email_field :owner_email, required: true, value: @owner_email, placeholder: email_placeholder, class: "form-control"

- if @vehicle_select
.form-group.fancy-select.unfancy.short-fancy-select
- @b_param.cycle_type ||= 'bike'
= f.select(:cycle_type, CycleType.select_options(traditional_bike: true), {prompt: false}, {required: true, class: 'form-control'})

.form-group
- initial_mnfg = @b_param.manufacturer && { id: @b_param.manufacturer.id, text: @b_param.manufacturer.name }.to_json
= f.text_field :manufacturer_id, value: @b_param.manufacturer&.name, class: "form-control unfancy",
Expand All @@ -12,11 +17,6 @@
%span.below-input-help
= t(".select_other_if_manufacturer_doesnt_show")

- if @vehicle_select
.form-group.fancy-select.unfancy.short-fancy-select
- @b_param.cycle_type ||= 'bike'
= f.select(:cycle_type, CycleType.select_options(traditional_bike: true), {prompt: false}, {required: true, class: 'form-control'})

.form-group.fancy-select.unfancy.short-fancy-select
= f.select(:primary_frame_color_id, Color.select_options, required: true, prompt: t(".primary_frame_color"), class: "form-control")

Expand Down
2 changes: 1 addition & 1 deletion config/locales/.translation_io
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
timestamp: 1724860094
timestamp: 1725899256
17 changes: 8 additions & 9 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -691,22 +691,21 @@ en:
cycle_type:
bike: Bike
cargo: Cargo Bike (front storage)
cargo_rear: Cargo Bike (rear storage)
cargo_rear: Cargo Bike Rear (e.g. longtail)
cargo_trike: Cargo Tricycle (front storage)
cargo_trike_rear: Cargo Tricycle (rear storage)
e_motorcycle: e-Motorcycle (or e-Dirtbike)
e_motorcycle: e-Motorcycle/e-Dirtbike (no pedals)
e_scooter: e-Scooter
e_skateboard: e-Skateboard
non_e_scooter: Scooter (not electric)
non_e_skateboard: Skateboard (Not electric)
non_e_skateboard: Skateboard (not electric)
pedi_cab: Pedi Cab (rickshaw)
penny_farthing: Penny Farthing
personal_mobility: e-Skateboard (e-Unicycle, Personal mobility device, etc)
recumbent: Recumbent
stroller: Stroller
tall_bike: Tall Bike
tandem: Tandem
traditional_bike: Traditional Bike (2 wheels, 1 seat, no motor)
traditional_bike: Traditional Bike (2 wheels, 1 seat, pedals)
trail_behind: Trail behind (half bike)
trailer: Bike Trailer
tricycle: Tricycle
Expand All @@ -728,11 +727,11 @@ en:
rearward: Rear facing
propulsion_type:
foot_pedal: Foot Pedal
hand_pedal: Hand Pedal
hand_pedal: Hand Cycle (hand pedal)
human_not_pedal: Human powered (not by pedals)
pedal_assist: Pedal Assist
pedal_assist_and_throttle: Pedal Assist and Throttle
throttle: Throttle
throttle: Electric Throttle
errors:
messages:
access_denied: The resource owner or authorization server denied the request.
Expand Down Expand Up @@ -1112,7 +1111,7 @@ en:
student_id: Student ID
this_is_a: This is a
traditional_bike: Traditional bicycle
traditional_bike_definition: Two wheels, one seat, no motor
traditional_bike_definition: 2 wheels, 1 seat, pedals
unknown_year: Unknown year
unsure_or_unknown: Unsure or unknown
very_few_vehicles_html: Very few %{type_html} are made without serials.
Expand Down Expand Up @@ -1453,7 +1452,7 @@ en:
select_cog_count: Select cog count
submit_correction: Submit correction
submit_update: Submit update
traditional_bike_definition: Two wheels, one seat, no motor
traditional_bike_definition: 2 wheels, 1 seat, pedals
update_propulsion: Update propulsion
update_vehicle_type: Update vehicle type
vehicle_type: Vehicle type
Expand Down
1 change: 0 additions & 1 deletion config/locales/translation.es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,6 @@ es:
cargo_trike:
cargo_trike_rear:
e_scooter:
e_skateboard:
non_e_scooter:
non_e_skateboard:
pedi_cab:
Expand Down
7 changes: 3 additions & 4 deletions config/locales/translation.nb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,6 @@ nb:
cargo_trike: Cargo trehjulssykkel (oppbevaring foran)
cargo_trike_rear: Laste trehjulssykkel (oppbevaring bak)
e_scooter: E-scooter
e_skateboard: E-skateboard
non_e_scooter: Scooter (ikke elektrisk)
non_e_skateboard: Skateboard (ikke elektrisk)
pedi_cab: Pedi Cab (rickshaw)
Expand All @@ -860,7 +859,7 @@ nb:
unicycle: Enhjuling
wheelchair: Rullestol
e_motorcycle: e-motorsykkel (eller e-Dirtbike)
traditional_bike: Tradisjonell sykkel (to hjul, ett sete, ingen motor)
traditional_bike: Tradisjonell sykkel (2 hjul, 1 sete, pedal)
frame_material:
aluminum: Aluminium
composite: Karbon eller kompositt
Expand Down Expand Up @@ -1855,7 +1854,7 @@ nb:
student_id: Student ID
this_is_a: Dette er en
traditional_bike: Tradisjonell sykkel
traditional_bike_definition: To hjul, ett sete, ingen motor
traditional_bike_definition: 2 hjul, 1 sete, pedal
unknown_year: Ukjent årstall
unsure_or_unknown: Usikker eller ukjent
was_made_before_1970: Ble laget før 1970
Expand Down Expand Up @@ -2184,7 +2183,7 @@ nb:
propulsion_type: Fremdrift
submit_correction: Send inn rettelse
submit_update: Send inn oppdatering
traditional_bike_definition: To hjul, ett sete, ingen motor
traditional_bike_definition: 2 hjul, 1 sete, pedal
update_propulsion: Oppdater fremdrift
update_vehicle_type: Oppdater kjøretøytype
vehicle_type: Bil type
Expand Down
7 changes: 3 additions & 4 deletions config/locales/translation.nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -855,11 +855,10 @@ nl:
personal_mobility: Persoonlijk mobiliteitshulpmiddel (elektrische scooter,
skateboard, eenwieler, enz.)
e_scooter: E-scooter
e_skateboard: E-skateboard
non_e_scooter: Scooter (niet elektrisch)
non_e_skateboard: Skateboard (niet elektrisch)
e_motorcycle: e-motorfiets (of e-dirtbike)
traditional_bike: Traditionele fiets (twee wielen, één zadel, geen motor)
traditional_bike: Traditionele fiets (2 wielen, 1 zadel, pedaal)
frame_material:
aluminum: Aluminium
composite: Koolstof of composiet
Expand Down Expand Up @@ -1833,7 +1832,7 @@ nl:
electric: Elektrisch
required: vereist - of markering ontbreekt
traditional_bike: Traditionele fiets
traditional_bike_definition: Twee wielen, één stoel, geen motor
traditional_bike_definition: 2 wielen, 1 zadel, pedaal
enter_bike_type_details_html: Voer %{type_html}-gegevens in
enter_found_bike_type_details_html: Voer de gevonden %{type_html}-gegevens in
enter_stolen_bike_type_details_html: Voer gegevens over gestolen %{type_html}
Expand Down Expand Up @@ -5829,7 +5828,7 @@ nl:
propulsion_type: Voortstuwing
submit_correction: Correctie indienen
submit_update: Update verzenden
traditional_bike_definition: Twee wielen, één stoel, geen motor
traditional_bike_definition: 2 wielen, 1 zadel, pedaal
update_propulsion: Aandrijving bijwerken
update_vehicle_type: Voertuigtype bijwerken
vehicle_type: 'Voertuigtype:'
Expand Down
18 changes: 18 additions & 0 deletions db/migrate/20240908151325_change_flipper_gates_value_to_text.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

class ChangeFlipperGatesValueToText < ActiveRecord::Migration[6.1]
def up
# Ensure this incremental update migration is idempotent
return unless connection.column_exists? :flipper_gates, :value, :string

if index_exists? :flipper_gates, [:feature_key, :key, :value]
remove_index :flipper_gates, [:feature_key, :key, :value]
end
change_column :flipper_gates, :value, :text
add_index :flipper_gates, [:feature_key, :key, :value], unique: true, length: { value: 255 }
end

def down
change_column :flipper_gates, :value, :string
end
end
5 changes: 3 additions & 2 deletions db/primary_replica_structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,7 @@ CREATE TABLE public.flipper_gates (
id integer NOT NULL,
feature_key character varying NOT NULL,
key character varying NOT NULL,
value character varying,
value text,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL
);
Expand Down Expand Up @@ -6652,6 +6652,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20231212023722'),
('20231212025929'),
('20240517161713'),
('20240712181117');
('20240712181117'),
('20240908151325');


5 changes: 3 additions & 2 deletions db/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,7 @@ CREATE TABLE public.flipper_gates (
id integer NOT NULL,
feature_key character varying NOT NULL,
key character varying NOT NULL,
value character varying,
value text,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL
);
Expand Down Expand Up @@ -6652,6 +6652,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20231212023722'),
('20231212025929'),
('20240517161713'),
('20240712181117');
('20240712181117'),
('20240908151325');


16 changes: 14 additions & 2 deletions spec/models/cycle_type_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
end

describe "select_options" do
let(:trad_bike) { ["Traditional Bike (2 wheels, 1 seat, no motor)", "bike"] }
let(:trad_bike) { ["Traditional Bike (2 wheels, 1 seat, pedals)", "bike"] }
it "has the values" do
expect(CycleType.select_options).to include(["Bike", "bike"])
expect(CycleType.select_options(traditional_bike: true)).to include(trad_bike)
Expand Down Expand Up @@ -69,6 +69,18 @@
end
end

describe "names and translations" do
let(:en_yaml) { YAML.load(File.read(Rails.root.join("config", "locales", "en.yml"))) }
let(:cycle_type_translations) do
# For dumb historical reasons, slugs have dashes rather than underscores
en_yaml.dig("en", "activerecord", "enums", "cycle_type")
.map { |k, v| [k.gsub("_", "-"), v] }.to_h
end
it "has the same names as english translations" do
expect(cycle_type_translations.except("traditional-bike")).to match_hash_indifferently CycleType::NAMES
end
end

describe "not_cycle_drivetrain?" do
it "is falsey" do
expect(CycleType.not_cycle_drivetrain?(:bike)).to be_falsey
Expand Down Expand Up @@ -171,7 +183,7 @@
end
let(:cycle_type) { CycleType.find(0) }
it "is target" do
expect_hashes_to_match(cycle_type.autocomplete_hash, target)
expect(cycle_type.autocomplete_hash).to match_hash_indifferently target
target_result_hash = target.except(:data).merge(target[:data])
expect(cycle_type.autocomplete_result_hash).to eq target_result_hash.as_json
end
Expand Down
10 changes: 10 additions & 0 deletions spec/models/frame_material_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,14 @@
end
end
end

describe "names and translations" do
let(:en_yaml) { YAML.load(File.read(Rails.root.join("config", "locales", "en.yml"))) }
let(:enum_translations) do
en_yaml.dig("en", "activerecord", "enums", "frame_material")
end
it "has the same names as english translations" do
expect(enum_translations).to match_hash_indifferently FrameMaterial::NAMES
end
end
end
10 changes: 10 additions & 0 deletions spec/models/handlebar_type_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,14 @@
end
end
end

describe "names and translations" do
let(:en_yaml) { YAML.load(File.read(Rails.root.join("config", "locales", "en.yml"))) }
let(:enum_translations) do
en_yaml.dig("en", "activerecord", "enums", "handlebar_type")
end
it "has the same names as english translations" do
expect(enum_translations).to match_hash_indifferently HandlebarType::NAMES
end
end
end
12 changes: 12 additions & 0 deletions spec/models/propulsion_type_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,16 @@
end
end
end

describe "names and translations" do
let(:en_yaml) { YAML.load(File.read(Rails.root.join("config", "locales", "en.yml"))) }
let(:enum_translations) do
# For dumb historical reasons, slugs have dashes rather than underscores
en_yaml.dig("en", "activerecord", "enums", "propulsion_type")
.map { |k, v| [k.gsub("_", "-"), v] }.to_h
end
it "has the same names as english translations" do
expect(enum_translations).to match_hash_indifferently PropulsionType::NAMES
end
end
end
Loading

0 comments on commit 1a5ba72

Please sign in to comment.