Skip to content

Commit

Permalink
IIR-287 Yellow Ribbon Serializer Update (#1024)
Browse files Browse the repository at this point in the history
* Add zip to YellowRibbonProgramSerializer

* Added additional fields to YellowRibbonSerializer, updated tests

* Updated schema used by tests

* Cleaned up delegate statements

* Removed unneeded fields

* Added version constraint for jquery-ui-rails to gemfile

* Revert "Added version constraint for jquery-ui-rails to gemfile"

This reverts commit 302a1b6.

* Attempting to install jquery-ui-rails from source

* URL correction

---------

Co-authored-by: Kyle Henson <[email protected]>
  • Loading branch information
stevelong00 and khenson-oddball authored Feb 14, 2024
1 parent 1b6040d commit 6b7e46a
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ gem 'faraday_middleware'
gem 'figaro'
gem 'font-awesome-rails', '4.7.0.6'
gem 'jquery-rails'
gem 'jquery-ui-rails'
gem 'jquery-ui-rails', git: 'https://github.com/jquery-ui-rails/jquery-ui-rails', branch: 'master'
gem 'newrelic_rpm'
gem 'oj' # Amazon Linux `json` gem causes conflicts, but `multi_json` will prefer `oj` if installed

Expand Down
11 changes: 10 additions & 1 deletion app/models/yellow_ribbon_program.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,17 @@
class YellowRibbonProgram < ApplicationRecord
belongs_to :institution

delegate :country, :insturl, to: :institution
delegate :institution, to: :institution, prefix: :name_of
delegate :correspondence,
:country,
:distance_learning,
:insturl,
:latitude,
:longitude,
:online_only,
:student_veteran,
:student_veteran_link,
:ungeocodable, to: :institution

validates :contribution_amount, numericality: true
validates :degree_level, presence: true
Expand Down
12 changes: 11 additions & 1 deletion app/serializers/yellow_ribbon_program_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,24 @@
class YellowRibbonProgramSerializer < ActiveModel::Serializer
attributes :city,
:contribution_amount,
:correspondence,
:country,
:degree_level,
:distance_learning,
:division_professional_school,
:facility_code,
:institution_id,
:insturl,
:latitude,
:longitude,
:number_of_students,
:name_of_institution,
:online_only,
:state,
:street_address
:street_address,
:student_veteran,
:student_veteran_link,
:ungeocodable,
:year_of_yr_participation,
:zip
end
40 changes: 40 additions & 0 deletions spec/serializers/yellow_ribbon_program_serializer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,18 @@
expect(attributes['country']).to eq(yellow_ribbon_program.country)
end

it 'correspondence' do
expect(attributes['correspondence']).to eq(yellow_ribbon_program.correspondence)
end

it 'degree_level' do
expect(attributes['degree_level']).to eq(yellow_ribbon_program.degree_level)
end

it 'distance_learning' do
expect(attributes['distance_learning']).to eq(yellow_ribbon_program.distance_learning)
end

it 'division_professional_school' do
expect(attributes['division_professional_school']).to eq(yellow_ribbon_program.division_professional_school)
end
Expand All @@ -41,6 +49,14 @@
expect(attributes['insturl']).to eq(yellow_ribbon_program.insturl)
end

it 'latitude' do
expect(attributes['latitude']).to eq(yellow_ribbon_program.latitude)
end

it 'longitude' do
expect(attributes['longitude']).to eq(yellow_ribbon_program.longitude)
end

it 'number_of_students' do
expect(attributes['number_of_students']).to eq(yellow_ribbon_program.number_of_students)
end
Expand All @@ -49,11 +65,35 @@
expect(attributes['name_of_institution']).to eq(yellow_ribbon_program.name_of_institution)
end

it 'online_only' do
expect(attributes['online_only']).to eq(yellow_ribbon_program.online_only)
end

it 'state' do
expect(attributes['state']).to eq(yellow_ribbon_program.state)
end

it 'street_address' do
expect(attributes['street_address']).to eq(yellow_ribbon_program.street_address)
end

it 'student_veteran' do
expect(attributes['student_veteran']).to eq(yellow_ribbon_program.student_veteran)
end

it 'student_veteran_link' do
expect(attributes['student_veteran_link']).to eq(yellow_ribbon_program.student_veteran_link)
end

it 'ungeocodable' do
expect(attributes['ungeocodable']).to eq(yellow_ribbon_program.ungeocodable)
end

it 'year_of_yr_participation' do
expect(attributes['year_of_yr_participation']).to eq(yellow_ribbon_program.year_of_yr_participation)
end

it 'zip' do
expect(attributes['zip']).to eq(yellow_ribbon_program.zip)
end
end
12 changes: 11 additions & 1 deletion spec/support/api/schemas/yellow_ribbon_program.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,26 @@
"properties": {
"city": { "type": ["null", "string"] },
"contribution_amount": { "type": ["null", "string"] },
"correspondence": { "type": ["null", "boolean"] },
"country": { "type": ["null", "string"] },
"degree_level": { "type": ["null", "string"] },
"distance_learning": { "type": ["null", "boolean"] },
"division_professional_school": { "type": ["null", "string"] },
"facility_code": { "type": ["null", "string"] },
"institution_id": { "type": ["null", "integer"] },
"insturl": { "type": ["null", "string"] },
"latitude": { "type": ["null", "number"] },
"longitude": { "type": ["null", "number"] },
"name_of_institution": { "type": ["null", "string"] },
"number_of_students": { "type": ["null", "integer"] },
"online_only": { "type": ["null", "boolean"] },
"state": { "type": ["null", "string"] },
"street_address": { "type": ["null", "string"] }
"street_address": { "type": ["null", "string"] },
"student_veteran": { "type": ["null", "boolean"] },
"student_veteran_link": { "type": ["null", "string"] },
"ungeocodable": { "type": ["null", "boolean"] },
"year_of_yr_participation": { "type": ["null", "string"] },
"zip": { "type": ["null", "string"] }
}
}
},
Expand Down

0 comments on commit 6b7e46a

Please sign in to comment.