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

Deprecation cleanup #1466

Merged
merged 5 commits into from
Aug 22, 2016
Merged

Deprecation cleanup #1466

merged 5 commits into from
Aug 22, 2016

Conversation

atz
Copy link
Member

@atz atz commented Aug 20, 2016

Fixes #1464
Fixes #1465
Fixes #1463

Cleans up catalog_controller_spec considerably.

def additional_response_formats format
blacklight_config.index.respond_to.each do |key, config|
format.send key do
case config
when false
raise ActionController::RoutingError, 'Not Found'
when Hash
render config
if config[:nothing] # nothing param deprecated in rails, but still in configs
head :ok, config.reject { |k, v| k == :nothing }

Choose a reason for hiding this comment

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

Unused block argument - v. If it's necessary, use _ or _v as an argument name to indicate that it won't be used.

Copy link
Member

Choose a reason for hiding this comment

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

config.except(:nothing) ought to work here, yeah?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, that's fine

@coveralls
Copy link

coveralls commented Aug 20, 2016

Coverage Status

Coverage decreased (-0.006%) to 77.058% when pulling f9d894c on sul-dlss:deprecation_cleanup into f3b2b5f on projectblacklight:master.

def additional_response_formats format
blacklight_config.index.respond_to.each do |key, config|
format.send key do
case config
when false
raise ActionController::RoutingError, 'Not Found'
when Hash
render config
if config[:nothing] # nothing param deprecated in rails, but still in configs
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to handle this case? Wouldn't it be better to get downstream applications to update their config? At the very least, we should issue our own deprecation warning so they do.

Copy link
Member Author

Choose a reason for hiding this comment

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

Data migration of existing production configs is outside my intended scope for this PR, but I otherwise agree with you. I needed to catch it to resolve the last outstanding deprecation warnings. Not sure what to advise the migrate to. Since previous configs were passed to render, that was easy, but the deprecation we are trying to avoid is precisely that we can't do render nothing: true anymore. Seems like we will need a conditional regardless.

Copy link
Member

Choose a reason for hiding this comment

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

My point is, this isn't blacklight's deprecation to clean up. We're just an intermediate party, and downstream applications will need to get updated. I'm +0, though, on capturing their deprecation warning and giving them an equivalent but more accurate deprecation warning.

Copy link
Member Author

Choose a reason for hiding this comment

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

Blacklight set the config syntax and behavior. To say it is the downstream app's problem means breaking those apps on rails 5.1 for the same configs blacklight currently uses (and maybe even generates).

Copy link
Member

Choose a reason for hiding this comment

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

The parameters to respond_to are intended and expected to mirror the Rails parameters, we're not trying to invent our own render API. If downstream applications ignore the deprecation warning and upgrade to Rails 5.1 without heeding those warnings, that's on them.

Copy link
Member Author

Choose a reason for hiding this comment

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

How do you expect them to handle the case currently borne by render :nothing? If we don't expose head, there is no option they can pass via this switch to render that 5.1 will support. That's not their failure to resolve deprecations, if we're the ones forcing them to pass options to render in the first place.

Copy link
Member

Choose a reason for hiding this comment

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

This seems acceptable:

config.index.respond_to.txt = Proc.new { head :ok }

Also acceptable might be config.index.respond_to.txt = { body: "" }, or similar variations.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, I see what you mean. You want me to back this change out?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, please.

@coveralls
Copy link

coveralls commented Aug 20, 2016

Coverage Status

Coverage decreased (-0.006%) to 77.058% when pulling 503fcfb on sul-dlss:deprecation_cleanup into f3b2b5f on projectblacklight:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+17.5%) to 94.566% when pulling fe0487e on sul-dlss:deprecation_cleanup into f3b2b5f on projectblacklight:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage increased (+17.5%) to 94.566% when pulling fe0487e on sul-dlss:deprecation_cleanup into f3b2b5f on projectblacklight:master.

@coveralls
Copy link

coveralls commented Aug 20, 2016

Coverage Status

Coverage decreased (-0.006%) to 77.058% when pulling fe0487e on sul-dlss:deprecation_cleanup into f3b2b5f on projectblacklight:master.

@coveralls
Copy link

coveralls commented Aug 20, 2016

Coverage Status

Coverage decreased (-0.006%) to 77.058% when pulling 4c16385 on sul-dlss:deprecation_cleanup into f3b2b5f on projectblacklight:master.

- Use `let` statements, remove class instance vars
- Use common before blocks
- Correct indent formatting
- Remove redundant mocks!
- Removes rails deprecations around render calls
- Remove rails 3 cruft
@coveralls
Copy link

coveralls commented Aug 20, 2016

Coverage Status

Coverage decreased (-0.006%) to 77.058% when pulling a83d1e9 on sul-dlss:deprecation_cleanup into f3b2b5f on projectblacklight:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+17.5%) to 94.566% when pulling a83d1e9 on sul-dlss:deprecation_cleanup into f3b2b5f on projectblacklight:master.

it "does not call the supplied method" do
expect(controller).to receive(:validate_like_params).and_return(false)
expect(controller).not_to receive(:perform_like)
expect { post :like }.not_to raise_error
Copy link
Member Author

Choose a reason for hiding this comment

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

This is now the sole failing test on Rails 4.

Note: the old version of the test was bogus. The post was already made at 683 before validate_like_params was re-stubbed false.

Copy link
Member

Choose a reason for hiding this comment

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

Worse than that -- I'm not sure the post was even triggered. It seems like we're not effectively handling invalid input (in actual use, it'll fail over to the original template.. but still)

Copy link
Member

@cbeer cbeer Aug 22, 2016

Choose a reason for hiding this comment

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

For now, I'd suggest marking it as pending, filing a ticket, and moving on.

@coveralls
Copy link

coveralls commented Aug 22, 2016

Coverage Status

Coverage increased (+17.5%) to 94.569% when pulling f5bce77 on sul-dlss:deprecation_cleanup into f3b2b5f on projectblacklight:master.

@coveralls
Copy link

coveralls commented Aug 22, 2016

Coverage Status

Coverage decreased (-0.002%) to 94.569% when pulling 037b128 on sul-dlss:deprecation_cleanup into 32e5715 on projectblacklight:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.002%) to 94.569% when pulling 037b128 on sul-dlss:deprecation_cleanup into 32e5715 on projectblacklight:master.

@coveralls
Copy link

coveralls commented Aug 22, 2016

Coverage Status

Coverage decreased (-0.002%) to 94.569% when pulling 3f2c495 on sul-dlss:deprecation_cleanup into 32e5715 on projectblacklight:master.

@coveralls
Copy link

coveralls commented Aug 22, 2016

Coverage Status

Coverage increased (+0.03%) to 94.596% when pulling 4cfa7f6 on sul-dlss:deprecation_cleanup into 32e5715 on projectblacklight:master.

# Collects formats that this doc can export as.
# Returns a hash, keys are format short-names that can
# be exported. Hash includes:
# :content-type => mime-content-type
# :content-type => { content_type: content_type }
Copy link
Member

Choose a reason for hiding this comment

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

I think this was intended to be a placeholder for a string, so something like this would be more correct:

:content_type => 'sample/content-type'

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, it seems like a bad comment. The method returns a hash, with values that are themselves hashes. The example here was presumably demonstrating the contents of a value, not the entire hash. Maybe we can rework the comment to be better?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, it was clearly half-baked previously. I was just trying to capture that there was internal structure (values are hashes). I'll touch it up and merge.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 94.596% when pulling 66d9e71 on sul-dlss:deprecation_cleanup into 32e5715 on projectblacklight:master.

1 similar comment
@coveralls
Copy link

coveralls commented Aug 22, 2016

Coverage Status

Coverage increased (+0.03%) to 94.596% when pulling 66d9e71 on sul-dlss:deprecation_cleanup into 32e5715 on projectblacklight:master.

This updated version is from Curation Concerns.
It never actually posted to the controller.  With a post it fails on
Rails 4 but passes on Rails 5.  Needs clarification.
@coveralls
Copy link

coveralls commented Aug 22, 2016

Coverage Status

Coverage increased (+0.03%) to 94.596% when pulling 920882c on sul-dlss:deprecation_cleanup into 32e5715 on projectblacklight:master.

@cbeer cbeer merged commit 8f399ac into projectblacklight:master Aug 22, 2016
@cbeer cbeer deleted the deprecation_cleanup branch August 22, 2016 23:52
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.

None yet

5 participants