| @@ -133,28 +133,6 @@ class InternalUrlsFilterTest < MiniTest::Spec · 132 unmodified lines |
| 133 | 133 | assert_includes internal_urls, 'http://example.com/' |
| 134 | 134 | end |
| 135 | 135 | end |
| 136 | | − |
| 137 | | − context "when context[:follow_links] is a block" do |
| 138 | | − before do |
| 139 | | − @body = link_to context[:url] |
| 140 | | − end |
| 141 | | − |
| 142 | | − it "calls the block with the filter instance" do |
| 143 | | − context[:follow_links] = ->(arg) { @arg = arg; nil } |
| 144 | | − filter.call |
| 145 | | − assert_equal filter, @arg |
| 146 | | − end |
| 147 | | − |
| 148 | | − it "is empty when the block returns false" do |
| 149 | | − context[:follow_links] = ->(_) { false } |
| 150 | | − assert_empty internal_urls |
| 151 | | − end |
| 152 | | − |
| 153 | | − it "is the default when the block returns true" do |
| 154 | | − context[:follow_links] = ->(_) { true } |
| 155 | | − refute_empty internal_urls |
| 156 | | − end |
| 157 | | − end |
| 158 | 136 | end |
| 159 | 137 | |
| 160 | 138 | context "when the base url is 'example.com'" do |
| @@ -325,7 +303,7 @@ class InternalUrlsFilterTest < MiniTest::Spec · 164 unmodified lines |
| 325 | 303 | context[:skip_links] = ->(_) { false } |
| 326 | 304 | end |
| 327 | 305 | |
| 328 | | − it "set :internal_urls" do |
| 306 | + it "sets :internal_urls" do |
| 329 | 307 | assert internal_urls |
| 330 | 308 | end |
| 331 | 309 | |
| @@ -335,4 +313,40 @@ class InternalUrlsFilterTest < MiniTest::Spec · 3 unmodified lines |
| 335 | 313 | end |
| 336 | 314 | end |
| 337 | 315 | end |
| 316 | + |
| 317 | + context "context[:follow_links] is a block" do |
| 318 | + before do |
| 319 | + @body = link_to context[:url] |
| 320 | + end |
| 321 | + |
| 322 | + it "calls the block with the filter instance" do |
| 323 | + context[:follow_links] = ->(arg) { @arg = arg; nil } |
| 324 | + filter.call |
| 325 | + assert_equal filter, @arg |
| 326 | + end |
| 327 | + |
| 328 | + context "and the block returns false" do |
| 329 | + before do |
| 330 | + context[:follow_links] = ->(_) { false } |
| 331 | + end |
| 332 | + |
| 333 | + it "doesn't set :internal_urls" do |
| 334 | + refute internal_urls |
| 335 | + end |
| 336 | + |
| 337 | + it "replaces urls" do |
| 338 | + refute_equal @body, filter_output_string |
| 339 | + end |
| 340 | + end |
| 341 | + |
| 342 | + context "and the block returns true" do |
| 343 | + before do |
| 344 | + context[:follow_links] = ->(_) { true } |
| 345 | + end |
| 346 | + |
| 347 | + it "sets :internal_urls" do |
| 348 | + assert internal_urls |
| 349 | + end |
| 350 | + end |
| 351 | + end |
| 338 | 352 | end |