class TestActComment

Public Instance Methods

test_comment() click to toggle source
# File vendor/qwik/lib/qwik/act-comment.rb, line 341
def test_comment
  t_add_user

  page = @site.create_new
  page.store '{{comment}}'

  res = session('/test/1.html')
  ok_xp([:textarea, {:cols=>'40', :rows=>'7', :name=>'msg'}, ''],
        '//textarea')

  # The 1st comment.
  res = session('/test/1.comment?msg=Hi')
  ok_title('Message has been added.')

  res = session('/test/1.html')
  ok_xp([:dl, [:dt, 'user@e... (1970-01-01 09:00:00)'], [:dd, [:br], 'Hi']],
        "//div[@class='section']/dl[2]")

  page = @site['_SiteChanged']
  assert_match(/^,[.0-9]+,user@e.com,comment,1$/, page.load)

  # The 2nd comment.
  res = session('/test/1.comment?msg=hello%0aworld')
  ok_title('Message has been added.')

  res = session('/test/1.html')
  ok_xp([:dl,
          [:dt, 'user@e... (1970-01-01 09:00:00)'],
          [:dd, [:br], 'Hi'],
          [:dt, 'user@e... (1970-01-01 09:00:00)'],
          [:dd, [:br], 'hello', [:br], 'world']],
        '//div[@class="section"]/dl[2]')

  page = @site['_SiteChanged']
  assert_match(/^,[.0-9]+,user@e.com,comment,1$/, page.load)
end
test_ext_hcomment() click to toggle source
# File vendor/qwik/lib/qwik/act-comment.rb, line 389
def test_ext_hcomment
  t_add_user

  page = @site.create_new
  page.store("{{hcomment}}\n")
  res = session('POST /test/1.hcomment?name=n&msg=m&comment_no=1&style=0')
  ok_eq("- 1970-01-01 09:00:00 '''n''' : m\n{{hcomment}}\n",
        page.load)

  page.store("{{hcomment(1)}}\n")
  res = session('POST /test/1.hcomment?name=n&msg=m&comment_no=1&style=1')
  ok_eq("{{hcomment(1)}}\n- 1970-01-01 09:00:00 '''n''' : m\n",
        page.load)
end
test_ext_mcomment() click to toggle source
# File vendor/qwik/lib/qwik/act-comment.rb, line 455
    def test_ext_mcomment
      t_add_user

      page = @site.create_new
      page.store("{{mcomment}}\n")
      res = session('POST /test/1.html')
      ok_xp([:div, {:class=>'mcomment'},
              [:form, {:method=>'POST', :action=>'1.1.0.mcomment'},
                [:table,
                  [:tr, [:th, 'Name'],
                    [:td, [:input, {:size=>'30', :name=>'u'}]]],
                  [:tr, [:th, 'Comment'],
                    [:td, [:textarea,
                        {:cols=>'50', :rows=>'4', :name=>'m'}, '']]],
                  [:tr, [:th, ''],
                    [:td, [:input, {:value=>'Submit', :type=>'submit'}]]]]]],
            "//div[@class='mcomment']")

      res = session("POST /test/1.1.0.mcomment?u=u&m=m")
      eq "{{mcomment
|0|u|m
}}
", page.load

      res = session("POST /test/1.1.0.mcomment?u=u2&m=m2")
      eq "{{mcomment
|0|u|m
|0|u2|m2
}}
", page.load

      page.store("{{mcomment(1)}}
")
      res = session("POST /test/1.1.1.mcomment?u=u&m=m")
      eq "{{mcomment(1)
|0|u|m
}}
", page.load

      res = session("POST /test/1.1.1.mcomment?u=u2&m=m2")
      eq "{{mcomment(1)
|0|u2|m2
|0|u|m
}}
", page.load

      page.store("{{mcomment}}
{{mcomment}}
")
      res = session("POST /test/1.1.0.mcomment?u=u&m=m")
      eq "{{mcomment
|0|u|m
}}
{{mcomment}}
", page.load

      res = session("POST /test/1.2.0.mcomment?u=u2&m=m2")
      eq "{{mcomment
|0|u|m
}}
{{mcomment
|0|u2|m2
}}
", page.load
    end
test_ext_mcomment2() click to toggle source
# File vendor/qwik/lib/qwik/act-comment.rb, line 521
    def test_ext_mcomment2
      t_add_user

      page = @site.create_new
      page.store("{{mcomment}}\n")
      res = session("POST /test/1.1.0.mcomment?u=u&m=m\n")
      eq '{{mcomment
|0|u|m\n
}}
', page.load

      page.store("{{mcomment}}\n")
      res = session("POST /test/1.1.0.mcomment?u=u&m=m\r\n")
      eq '{{mcomment
|0|u|m\n
}}
', page.load

      page.store("{{mcomment}}\n")
      res = session("POST /test/1.1.0.mcomment?u=u&m=m\r")
      eq '{{mcomment
|0|u|m\n
}}
', page.load

      page.store("{{mcomment}}\n")
      res = session("POST /test/1.1.0.mcomment?u=u&m=m\n\r")
      eq '{{mcomment
|0|u|m\n\n
}}
', page.load
    end
test_plg_comment() click to toggle source
# File vendor/qwik/lib/qwik/act-comment.rb, line 327
def test_plg_comment
  t_add_user
  ok_wi([:div, {:class=>'comment'},
          [:form, {:action=>'1.comment'},
            [:dl,
              [:dt, 'User'],
              [:dd, [:em, 'user@e.com']],
              [:dt, 'Message'],
              [:dd, [:textarea,
                  {:rows=>'7', :name=>'msg', :cols=>'40'}, '']],
              [:dd, [:input, {:value=>'POST', :type=>'submit'}]]]]],
        '{{comment}}')
end
test_plg_hcomment() click to toggle source
# File vendor/qwik/lib/qwik/act-comment.rb, line 378
def test_plg_hcomment
  ok_wi([:div, {:class=>'hcomment'},
          [:form, {:action=>'1.hcomment', :method=>'POST'},
            'Name', ': ', [:input, {:size=>10, :name=>'name'}], ' ',
            'Comment', ': ', [:input, {:size=>50, :name=>'msg'}], ' ',
            [:input, {:value=>'Submit', :type=>'submit', :name=>'comment'}],
            [:input, {:value=>1, :type=>'hidden', :name=>'comment_no'}],
            [:input, {:value=>0, :type=>'hidden', :name=>'style'}]]],
        '{{hcomment}}')
end
test_plg_mcomment() click to toggle source
# File vendor/qwik/lib/qwik/act-comment.rb, line 404
    def test_plg_mcomment
      ok_wi([:div, {:class=>'mcomment'},
              [:form, {:method=>'POST', :action=>'1.1.0.mcomment'},
                [:table,
                  [:tr, [:th, 'Name'],
                    [:td, [:input, {:size=>'30', :name=>'u'}]]],
                  [:tr,
                    [:th, 'Comment'],
                    [:td, [:textarea,
                        {:cols=>'50', :rows=>'4', :name=>'m'}, '']]],
                  [:tr, [:th, ''],
                    [:td, [:input, {:value=>'Submit', :type=>'submit'}]]]]]],
            "{{mcomment}}")
      ok_wi([:div, {:class=>'mcomment'},
              [:div, {:class=>'msg'},
                [:dl, [:dt,
                    [:span, {:class=>'date'}, '1970-01-01'],
                    [:span, {:class=>'user'}, 'u']],
                  [:dd, 'm', [:br]]]],
              [:form, {:method=>'POST', :action=>'1.1.0.mcomment'},
                [:table,
                  [:tr, [:th, 'Name'],
                    [:td, [:input, {:size=>'30', :name=>'u'}]]],
                  [:tr,[:th, 'Comment'],
                    [:td, [:textarea,
                        {:cols=>'50', :rows=>'4', :name=>'m'}, '']]],
                  [:tr, [:th, ''],
                    [:td, [:input, {:value=>'Submit', :type=>'submit'}]]]]]],
            "{{mcomment
|0|u|m
}}")
      ok_wi([:div, {:class=>'mcomment'},
              [:form, {:method=>'POST', :action=>'1.1.1.mcomment'},
                [:table,
                  [:tr, [:th, 'Name'],
                    [:td, [:input, {:size=>'30', :name=>'u'}]]],
                  [:tr, [:th, 'Comment'],
                    [:td, [:textarea,
                        {:cols=>'50', :rows=>'4', :name=>'m'}, '']]],
                  [:tr, [:th, ''],
                    [:td, [:input, {:value=>'Submit', :type=>'submit'}]]]]],
              [:div, {:class=>'msg'},
                [:dl, [:dt,
                    [:span, {:class=>'date'}, '1970-01-01'],
                    [:span, {:class=>'user'}, 'u']],
                  [:dd, 'm', [:br]]]]],
            "{{mcomment(1)
|0|u|m
}}")
    end