Skip to content

Commit

Permalink
Add tests on accessing grid attributes from dynamic scope
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdan committed Jan 12, 2024
1 parent 79a12db commit 2c7a2b0
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions spec/datagrid/core_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand All @@ -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')
Expand All @@ -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
Expand Down

0 comments on commit 2c7a2b0

Please # to comment.