diff options
author | Guillermo Iguaran <guilleiguaran@gmail.com> | 2019-07-19 15:36:58 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-19 15:36:58 -0500 |
commit | ea91f9bc1c6172b9dd2490f6d67140f930f62f13 (patch) | |
tree | 61ef0bd35225c67ce69ea04c71c418b9e22dc05a /actionview/test | |
parent | 611339015fcc6056215edc6a95c20673a6245f7f (diff) | |
parent | d2d15ad8a540e2f519de2ea905aff2305b038450 (diff) | |
download | rails-ea91f9bc1c6172b9dd2490f6d67140f930f62f13.tar.gz rails-ea91f9bc1c6172b9dd2490f6d67140f930f62f13.tar.bz2 rails-ea91f9bc1c6172b9dd2490f6d67140f930f62f13.zip |
Merge pull request #36511 from aantix/sms_link_helper
Helper method to create an sms link
Diffstat (limited to 'actionview/test')
-rw-r--r-- | actionview/test/template/url_helper_test.rb | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/actionview/test/template/url_helper_test.rb b/actionview/test/template/url_helper_test.rb index 632b32f09f..bce6e7f370 100644 --- a/actionview/test/template/url_helper_test.rb +++ b/actionview/test/template/url_helper_test.rb @@ -708,6 +708,68 @@ class UrlHelperTest < ActiveSupport::TestCase assert_equal({ class: "special" }, options) end + def test_sms_to + assert_dom_equal %{<a href="sms:15155555785;">15155555785</a>}, sms_to("15155555785") + assert_dom_equal %{<a href="sms:15155555785;">Jim Jones</a>}, sms_to("15155555785", "Jim Jones") + assert_dom_equal( + %{<a class="admin" href="sms:15155555785;">Jim Jones</a>}, + sms_to("15155555785", "Jim Jones", "class" => "admin") + ) + assert_equal sms_to("15155555785", "Jim Jones", "class" => "admin"), + sms_to("15155555785", "Jim Jones", class: "admin") + end + + def test_sms_to_with_options + assert_dom_equal( + %{<a class="simple-class" href="sms:15155555785;?&body=Hello%20from%20Jim">Text me</a>}, + sms_to("15155555785", "Text me", class: "simple-class", body: "Hello from Jim") + ) + + assert_dom_equal( + %{<a href="sms:15155555785;?&body=This%20is%20the%20body%20of%20the%20message.">Text me</a>}, + sms_to("15155555785", "Text me", body: "This is the body of the message.") + ) + end + + def test_sms_with_img + assert_dom_equal %{<a href="sms:15155555785;"><img src="/feedback.png" /></a>}, + sms_to("15155555785", raw('<img src="/feedback.png" />')) + end + + def test_sms_with_html_safe_string + assert_dom_equal( + %{<a href="sms:1%2B5155555785;">1+5155555785</a>}, + sms_to(raw("1+5155555785")) + ) + end + + def test_sms_with_nil + assert_dom_equal( + %{<a href="sms:;"></a>}, + sms_to(nil) + ) + end + + def test_sms_returns_html_safe_string + assert_predicate sms_to("15155555785"), :html_safe? + end + + def test_sms_with_block + assert_dom_equal %{<a href="sms:15155555785;"><span>Text me</span></a>}, + sms_to("15155555785") { content_tag(:span, "Text me") } + end + + def test_sms_with_block_and_options + assert_dom_equal %{<a class="special" href="sms:15155555785;?&body=Hello%20from%20Jim"><span>Text me</span></a>}, + sms_to("15155555785", body: "Hello from Jim", class: "special") { content_tag(:span, "Text me") } + end + + def test_sms_does_not_modify_html_options_hash + options = { class: "special" } + sms_to "15155555785", "ME!", options + assert_equal({ class: "special" }, options) + end + def protect_against_forgery? request_forgery end |