From 7f85e8bbb15ec4063dad8b080e61d690b77dead7 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Fri, 1 Sep 2017 14:51:07 +0200 Subject: TableBuilderHelper::Column: Add `#linkable?` method This tells the markup assembler whether or not this column should be wrapped in a link (``). It intends to serve the same purpose as `TableBuilderHelper#column_is_linkable`, but at the column level. The idea is to remove that method when these links only operate by column and not by pre-defined values like before/now. --- spec/helpers/table_builder_helper/column_spec.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'spec/helpers') diff --git a/spec/helpers/table_builder_helper/column_spec.rb b/spec/helpers/table_builder_helper/column_spec.rb index 0c5c89e8a..e0bfd8a6a 100644 --- a/spec/helpers/table_builder_helper/column_spec.rb +++ b/spec/helpers/table_builder_helper/column_spec.rb @@ -21,6 +21,29 @@ describe TableBuilderHelper::Column do end end + describe "#linkable?" do + it "returns true if :link_to is not nil" do + expect( + TableBuilderHelper::Column.new( + name: 'unused', + attribute: nil, + link_to: lambda do + train.kind + end + ).linkable? + ).to be true + end + + it "returns false if :link_to is nil" do + expect( + TableBuilderHelper::Column.new( + name: 'unused', + attribute: nil + ).linkable? + ).to be false + end + end + describe "#link_to" do it "calls the block passed in and returns the result" do train = double('train', kind: 'TGV') -- cgit v1.2.3