Skip to content

Commit

Permalink
Make api_error booleans consistent in interactors
Browse files Browse the repository at this point in the history
We had a mix of some places using api_error and some using api_errored.
I had initially planned to use api_errored, which was to remove ambiguity
of whether this was a boolean or a message (as is the case of
api_error), however this isn't a very natural thing to type and is
dubious English.

For consistency I've updated all the places where we were using the term
errored to just be error.
  • Loading branch information
kevindew committed Apr 29, 2019
1 parent 9cc5c06 commit f5ea158
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/controllers/documents_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def confirm_delete_draft

def destroy
result = Documents::DestroyInteractor.call(params: params, user: current_user)
if result.api_errored
if result.api_error
redirect_to document_path(params[:document]),
alert_with_description: t("documents.show.flashes.delete_draft_error")
else
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/review_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
class ReviewController < ApplicationController
def submit_for_2i
result = Review::SubmitFor2iInteractor.call(params: params, user: current_user)
issues, api_errored = result.to_h.values_at(:issues, :api_errored)
issues, api_error = result.to_h.values_at(:issues, :api_error)

if api_errored
if api_error
redirect_to document_path(params[:document]),
alert_with_description: t("documents.show.flashes.2i_error")
elsif issues
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/topics_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ def edit

def update
result = Topics::UpdateInteractor.call(params: params, user: current_user)
api_conflict, api_errored = result.to_h.values_at(:api_conflict, :api_errored)
api_conflict, api_error = result.to_h.values_at(:api_conflict, :api_error)

if api_conflict
redirect_to topics_path(params[:document]),
alert_with_description: t("topics.edit.flashes.topic_update_conflict")
elsif api_errored
elsif api_error
redirect_to document_path(params[:document]),
alert_with_description: t("documents.show.flashes.topic_update_error")
else
Expand Down
4 changes: 2 additions & 2 deletions app/interactors/documents/destroy_interactor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Documents::DestroyInteractor
delegate :params,
:user,
:edition,
:api_errored,
:api_error,
to: :context

def call
Expand All @@ -26,7 +26,7 @@ def discard_draft
DeleteDraftService.new(edition.document, user).delete
rescue GdsApi::BaseError => e
GovukError.notify(e)
context.fail!(api_errored: true)
context.fail!(api_error: true)
end

def create_timeline_entry
Expand Down
4 changes: 2 additions & 2 deletions app/interactors/review/submit_for2i_interactor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Review::SubmitFor2iInteractor
:user,
:edition,
:issues,
:api_errored,
:api_error,
to: :context

def call
Expand All @@ -32,7 +32,7 @@ def check_for_issues
context.fail!(issues: issues) if issues.any?
rescue GdsApi::BaseError => e
GovukError.notify(e)
context.fail!(api_errored: true)
context.fail!(api_error: true)
end

def update_status
Expand Down
4 changes: 2 additions & 2 deletions app/interactors/topics/update_interactor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Topics::UpdateInteractor
:user,
:document,
:api_conflict,
:api_errored,
:api_error,
to: :context

def call
Expand All @@ -28,6 +28,6 @@ def update_topics
context.fail!(api_conflict: true)
rescue GdsApi::BaseError => e
GovukError.notify(e)
context.fail!(api_errored: true)
context.fail!(api_error: true)
end
end

0 comments on commit f5ea158

Please sign in to comment.