Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

422 deactivate services when parent resource is deactivated #431

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

jjfreund
Copy link
Contributor

No description provided.

Copy link
Contributor

@cliffcrosland cliffcrosland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some small comments, but otherwise LGTM


module Services
module Resources
include Errors
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rails might auto-load this module, so I think it might be possible to delete this include Errors line here. In development mode, Rails lazily loads modules, so when it encounters raise Errors::PreconditionFailed, it will go look for the appropriate file and load it into scope.

remove_from_algolia(service)
end

def self.remove_from_algolia(service)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this can be factored out as a common utility since it is used in both services? Might be able to put it in app/services/utils.rb? Perhaps the error log message can be generalized as follows:

def self.remove_from_algolia(record)
  record.remove_from_index!
rescue StandardError
  puts "failed to remove #{record.class} #{record.id} from algolia index"
end

# frozen_string_literal: true

module Services
module Resources
Copy link
Contributor

@cliffcrosland cliffcrosland Jun 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be cool to add some rspec tests for these services, but if their functionality is already covered by the Postman tests, there is probably no need.

@cliffcrosland
Copy link
Contributor

Haha, looks like Rubocop wants you to add empty newlines after the Errors::PreconditionFailed guard clauses

@Maxastuart Maxastuart added this to the v1.20 milestone Jul 1, 2019
@jjfreund jjfreund modified the milestones: v1.20, v1.22 Sep 22, 2019
@Maxastuart Maxastuart modified the milestones: v1.22, v1.23 Sep 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants