File tree Expand file tree Collapse file tree
lib/grape_entity/exposure/nesting_exposure
spec/grape_entity/exposure/nesting_exposure Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33
44* Your contribution here.
55* [ #202 ] ( https://github.com/ruby-grape/grape-entity/pull/202 ) : Fix: Reset ` @using_class ` memoization on ` .setup ` - [ @rngtng ] ( https://github.com/rngtng ) .
6+ * [ #203 ] ( https://github.com/ruby-grape/grape-entity/pull/203 ) : Grape::Entity::Exposure::NestingExposure::NestedExposures.delete_if always returns exposures. - [ @rngtng ] ( https://github.com/rngtng ) .
67
780.5.0 (2015-12-07)
89==================
Original file line number Diff line number Diff line change 1+ Upgrading Grape Entity
2+ ===============
3+
4+ ### Upgrading to >= 0.5.1
5+
6+ * ` Grape::Entity::Exposure::NestingExposure::NestedExposures.delete_if ` always
7+ returns exposures, regardless of delete result (used to be
8+ ` nil ` in negative case), see [ #203 ] ( https://github.com/ruby-grape/grape-entity/pull/203 ) .
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ def <<(exposure)
2121 def delete_by ( *attributes )
2222 reset_memoization!
2323 @exposures . reject! { |e | attributes . include? e . attribute }
24+ @exposures
2425 end
2526
2627 def clear
Original file line number Diff line number Diff line change 11require 'spec_helper'
22
33describe Grape ::Entity ::Exposure ::NestingExposure ::NestedExposures do
4- subject { described_class . new ( [ ] ) }
4+ subject ( :nested_exposures ) { described_class . new ( [ ] ) }
55
66 describe '#deep_complex_nesting?' do
77 it 'is reset when additional exposure is added' do
3131 expect ( subject . instance_variable_get ( :@deep_complex_nesting ) ) . to be_nil
3232 end
3333 end
34+
35+ describe '.delete_by' do
36+ subject { nested_exposures . delete_by ( *attributes ) }
37+
38+ let ( :attributes ) { [ :id ] }
39+
40+ before do
41+ nested_exposures << Grape ::Entity ::Exposure . new ( :id , { } )
42+ end
43+
44+ it 'deletes matching exposure' do
45+ is_expected . to eq [ ]
46+ end
47+
48+ context "when given attribute doesn't exists" do
49+ let ( :attributes ) { [ :foo ] }
50+
51+ it 'deletes matching exposure' do
52+ is_expected . to eq ( nested_exposures )
53+ end
54+ end
55+ end
3456end
You can’t perform that action at this time.
0 commit comments