-
Notifications
You must be signed in to change notification settings - Fork 154
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
Some subtle improvements #134
Conversation
expect(child_class.exposures).to eq(name: {}) | ||
end | ||
|
||
it 'remove from parent and do not remove from child classes that have locked down their attributes with an .exposures call' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain why the other test is no longer necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because there is no more "confusing" behaviour. unexpose
no longer affects child classes regardless of was .exposures
method called in them or not.
It's kinda breaking change, but I hope nobody relied on such behaviour.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am confused, does this spec break now? I mean when you unexpose :email from the parent class, the child no longer has it?
In which case this at least needs an UPGRADING entry, although I think you want to track down the PR in which this was added and figure out why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from now, if you unexpose from parent class, child doesn't affect.
master:
[3] pry(main)> parent = Class.new(Grape::Entity)
=> #<Class:0x0000010250cf00>
[4] pry(main)> parent.expose :name, :email
=> [:name, :email]
[5] pry(main)> child = Class.new(parent)
=> #<Class:0x00000102a25938>
[6] pry(main)> child.exposures
=> {:name=>{}, :email=>{}}
[7] pry(main)> child_leaking = Class.new(parent)
=> #<Class:0x0000010292fab0>
[8] pry(main)> # not called .exposures
[9] pry(main)> parent.unexpose :email
=> {}
[10] pry(main)> child.exposures
=> {:name=>{}, :email=>{}}
[11] pry(main)> child_leaking.exposures
=> {:name=>{}}
my-branch:
[3] pry(main)> parent = Class.new(Grape::Entity)
=> #<Class:0x000001031fb108>
[4] pry(main)> parent.expose :name, :email
=> [:name, :email]
[5] pry(main)> child = Class.new(parent)
=> #<Class:0x000001032a0888>
[6] pry(main)> child.exposures
=> {:name=>{}, :email=>{}}
[7] pry(main)> child_leaking = Class.new(parent)
=> #<Class:0x0000010319f588>
[8] pry(main)> # not called .exposures
[9] pry(main)> parent.unexpose :email
=> {}
[10] pry(main)> child.exposures
=> {:name=>{}, :email=>{}}
[11] pry(main)> child_leaking.exposures
=> {:name=>{}, :email=>{}}
It was introduces in f089f16 and I think comment
# the following 2 behaviors are testing because it is not most intuitive and could be confusing
explains why. Because exposures merge happened in children classes only when it was called.
I'll add entry to UPGRADING
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't find UPGRADING
, so added note to CHANGELOG
Get rid of confusing behaviour when `unexpose` could leak to subclasses which have not locked down their attributes with `.exposures` call yet.
Ok, I am good with this, merging. Thank you very much. |
Check out https://github.com/intridea/grape-entity/pulls too, there're a few bugs that were raised that sound vaguely familiar, maybe this fixes anything. |
This fixes a regression introduced after merging a ruby-grape#134. It's something undocumented before but it worked before and I don't see anything harmful in the presence of this feature.
This fixes a regression introduced after merging a ruby-grape#134. It's something undocumented before but it worked before and I don't see anything harmful in the presence of this feature. Fixes ruby-grape#166.
This fixes a regression introduced after merging a ruby-grape#134. It's something undocumented before but it worked before and I don't see anything harmful in the presence of this feature. Fixes ruby-grape#166.
This fixes a regression introduced after merging a ruby-grape#134. It's something undocumented before but it worked before and I don't see anything harmful in the presence of this feature. Fixes ruby-grape#166.
This fixes a regression introduced after merging a ruby-grape#134. It's something undocumented before but it worked before and I don't see anything harmful in the presence of this feature. Fixes ruby-grape#166.
This fixes a regression introduced after merging a ruby-grape#134. It's something undocumented before but it worked before and I don't see anything harmful in the presence of this feature. Fixes ruby-grape#166.
This fixes a regression introduced after merging a ruby-grape#134. It's something undocumented before but it worked before and I don't see anything harmful in the presence of this feature. Fixes ruby-grape#166. Conflicts: .rubocop_todo.yml CHANGELOG.md lib/grape_entity/entity.rb lib/grape_entity/version.rb spec/grape_entity/entity_spec.rb
This fixes a regression introduced after merging a ruby-grape#134. It's something undocumented before but it worked before and I don't see anything harmful in the presence of this feature. Fixes ruby-grape#166. Conflicts: .rubocop_todo.yml CHANGELOG.md lib/grape_entity/entity.rb lib/grape_entity/version.rb spec/grape_entity/entity_spec.rb
This fixes a regression introduced after merging a ruby-grape#134. It's something undocumented before but it worked before and I don't see anything harmful in the presence of this feature. Fixes ruby-grape#166.
Because less code is better than more.