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

Add required content elements #37

Merged
merged 3 commits into from
Sep 30, 2016
Merged

Add required content elements #37

merged 3 commits into from
Sep 30, 2016

Conversation

gomayonqui
Copy link
Collaborator

No description provided.

@@ -10,10 +10,15 @@ def edit
end

def update
processing_version = Pulitzer::UpdateVersionStatus.new(@version,@status).call

if @status == "active" && @version.empty_required_content_elements?
Copy link
Owner

@edraut edraut Sep 28, 2016

Choose a reason for hiding this comment

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

@gomayonqui this logic is right.

However, I think it might be cleaner if you put it inside Pulitzer::UpdateVersionStatus though.

You could have the initialize method do this logic and write an error to the interaction

if @status == "active" && @version.empty_required_content_elements?
  @errors = ["It's not possible to activate a version without filling required content elements"]
end

Then you could add an errors accessor to the initializer:

attr_accessor :errors

Then the controller could just check for errors

status_updater = Pulitzer::UpdateVersionStatus.new(@version,@status)
if status_updater.errors.empty?
... do success logic...
else
... do error logic...
end

what do you think? it would clean up the controller and allow the interaction to handle the whole flow.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Great idea, will go for it

@edraut
Copy link
Owner

edraut commented Sep 30, 2016

looks great @gomayonqui ! ship it

@gomayonqui gomayonqui merged commit c49fcc6 into master Sep 30, 2016
@gomayonqui gomayonqui deleted the add-required branch September 30, 2016 19:01
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.

2 participants