File tree 4 files changed +33
-1
lines changed
lib/grape_entity/exposure/nesting_exposure
spec/grape_entity/exposure/nesting_exposure 4 files changed +33
-1
lines changed Original file line number Diff line number Diff line change 3
3
4
4
* Your contribution here.
5
5
* [ #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 ) .
6
7
7
8
0.5.0 (2015-12-07)
8
9
==================
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)
21
21
def delete_by ( *attributes )
22
22
reset_memoization!
23
23
@exposures . reject! { |e | attributes . include? e . attribute }
24
+ @exposures
24
25
end
25
26
26
27
def clear
Original file line number Diff line number Diff line change 1
1
require 'spec_helper'
2
2
3
3
describe Grape ::Entity ::Exposure ::NestingExposure ::NestedExposures do
4
- subject { described_class . new ( [ ] ) }
4
+ subject ( :nested_exposures ) { described_class . new ( [ ] ) }
5
5
6
6
describe '#deep_complex_nesting?' do
7
7
it 'is reset when additional exposure is added' do
31
31
expect ( subject . instance_variable_get ( :@deep_complex_nesting ) ) . to be_nil
32
32
end
33
33
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
34
56
end
You can’t perform that action at this time.
0 commit comments