diff options
| author | Teddy Wing | 2017-09-01 14:47:29 +0200 |
|---|---|---|
| committer | Teddy Wing | 2017-09-01 14:47:29 +0200 |
| commit | 9574d8b8351fd59eeada05a1ba71893a82b86989 (patch) | |
| tree | 96fc2696e09c85063741ce3a71f44f800d11f127 /spec/helpers | |
| parent | d127ed12158550f84ef1fb9c21d6360c86ac3642 (diff) | |
| download | chouette-core-9574d8b8351fd59eeada05a1ba71893a82b86989.tar.bz2 | |
TableBuilderHelper::Column: Add `link_to` argument
This parameter will be used as the `href` to link the column value
somewhere.
We give it a lambda because this makes it easier to call any method on
the row object.
This means the accessor needs to take the object as an argument, like in
the `#value` method, because we don't have a better way to handle that
(it can't be done at initialisation time because at that point we don't
have row objects, we have a collection).
Diffstat (limited to 'spec/helpers')
| -rw-r--r-- | spec/helpers/table_builder_helper/column_spec.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/spec/helpers/table_builder_helper/column_spec.rb b/spec/helpers/table_builder_helper/column_spec.rb index 0f27703b2..0c5c89e8a 100644 --- a/spec/helpers/table_builder_helper/column_spec.rb +++ b/spec/helpers/table_builder_helper/column_spec.rb @@ -20,4 +20,20 @@ describe TableBuilderHelper::Column do ).to eq('Numéro de téléphone') end end + + describe "#link_to" do + it "calls the block passed in and returns the result" do + train = double('train', kind: 'TGV') + + expect( + TableBuilderHelper::Column.new( + name: 'unused', + attribute: nil, + link_to: lambda do |train| + train.kind + end + ).link_to(train) + ).to eq('TGV') + end + end end |
