diff --git a/spec/datagrid/core_spec.rb b/spec/datagrid/core_spec.rb index 4c61685..d943b16 100644 --- a/spec/datagrid/core_spec.rb +++ b/spec/datagrid/core_spec.rb @@ -140,10 +140,10 @@ class EqualTest grid = test_report do scope {Entry} column(:id) - dynamic { + dynamic do column(:name) column(:category) - } + end end expect(grid.columns.map(&:name)).to eq([:id, :name, :category]) @@ -157,10 +157,10 @@ class EqualTest grid = test_report(:attribute_name => 'value') do scope {Entry} datagrid_attribute :attribute_name - dynamic { + dynamic do value = attribute_name column(:name) { value } - } + end end expect(grid.data_value(:name, Entry.create!)).to eq('value') @@ -182,6 +182,22 @@ class EqualTest expect(grid.assets.limit_value).to eq(2) end + + it "has access to grid attributes within scope" do + grid = test_report(name: 'one') do + scope {Entry} + dynamic do + scope do |s| + s.where(name: name) + end + end + filter(:name, dummy: true) + end + one = Entry.create!(name: 'one') + two = Entry.create!(name: 'two') + expect(grid.assets).to include(one) + expect(grid.assets).to_not include(two) + end end describe "ActionController::Parameters" do