-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* MAP-1038 rename FlightDetails -> ExtradtionFlight * MAP-1038 Fix db migration * Update spec/requests/api/extradition_flight_controller_update_spec.rb Co-authored-by: Adam Sharp <adam.sharp@digital.justice.gov.uk> * Update app/controllers/api/extradition_flight_controller.rb Co-authored-by: Adam Sharp <adam.sharp@digital.justice.gov.uk> * MAP-1038 Fix missed renames * MAP-1038 Linting * MAP-1038 Typos * MAP-1038 revert create! -> new and save * MAP-1038 datetime -> string column type * MAP-1038 Fix table name in spec * MAP-1038 Simplify extraditionFlight create --------- Co-authored-by: Adam Sharp <adam.sharp@digital.justice.gov.uk>
- Loading branch information
1 parent
af38eed
commit 92db67c
Showing
22 changed files
with
128 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
module Api | ||
class ExtraditionFlightController < ApiController | ||
before_action :set_extradition_flight, only: %i[index update] | ||
|
||
PERMITTED_NEW_PARAMS = [ | ||
:type, | ||
{ | ||
attributes: %i[flight_number flight_time], | ||
relationships: [{ move: {} }], | ||
}, | ||
].freeze | ||
|
||
PERMITTED_UPDATE_PARAMS = [:type, { attributes: %i[flight_number flight_time] }].freeze | ||
|
||
def index | ||
render_extradition_flight(@extradition_flight, :ok) | ||
end | ||
|
||
def create | ||
@extradition_flight = ExtraditionFlight.create!(new_extradition_flight_attributes) | ||
render_extradition_flight(@extradition_flight, :created) | ||
end | ||
|
||
def update | ||
@extradition_flight.update!(update_extradition_flight_attributes) | ||
|
||
render_extradition_flight(@extradition_flight, :ok) | ||
end | ||
|
||
private | ||
|
||
def set_extradition_flight | ||
@extradition_flight = ExtraditionFlight.find_by!(move:) | ||
end | ||
|
||
def new_extradition_flight_params | ||
params.require(:data).permit(PERMITTED_NEW_PARAMS) | ||
end | ||
|
||
def new_extradition_flight_attributes | ||
@new_extradition_flight_attributes ||= new_extradition_flight_params.to_h[:attributes].merge!(move:) | ||
end | ||
|
||
def update_extradition_flight_params | ||
params.require(:data).permit(PERMITTED_UPDATE_PARAMS) | ||
end | ||
|
||
def update_extradition_flight_attributes | ||
@update_extradition_flight_attributes ||= update_extradition_flight_params.to_h[:attributes] | ||
end | ||
|
||
def move | ||
@move ||= Move.accessible_by(current_ability).find(params.require(:move_id)) | ||
end | ||
|
||
def render_extradition_flight(extradition_flight, status) | ||
render_json extradition_flight, serializer: ExtraditionFlightSerializer, include: included_relationships, status: | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
app/models/flight_details.rb → app/models/extradition_flight.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
app/serializers/flight_details_serializer.rb → ...ializers/extradition_flight_serializer.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...e/20240502112955_create_flight_details.rb → ...40502112955_create_extradition_flights.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
spec/factories/flight_details.rb → spec/factories/extradition_flight.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.