class TestActNew

Public Instance Methods

test_create_new() click to toggle source
# File vendor/qwik/lib/qwik/act-new.rb, line 129
def test_create_new
  t_add_user

  # See .new page
  res = session('/test/.new')
  assert_attr({:action=>'.new', :method=>'POST'}, 'form')
  ok_xp([:input, {:value=>nil, :class=>'focus', :name=>'t'}], '//input')
  ok_xp([:input, {:value=>'New page', :type=>'submit'}], "//input[2]")

  # Create a new page.
  res = session("POST /test/.new?t=FirstPage")
  ok_title('New page')
  ok_in(['Edit new page'], "//div[@class='section']//a")
  ok_xp([:a, {:href=>'FirstPage.edit'}, 'Edit new page'],
        "//div[@class='section']//a")
end
test_opensite_new() click to toggle source
# File vendor/qwik/lib/qwik/act-new.rb, line 156
def test_opensite_new
  t_add_user
  t_site_open       # OPEN site

  res = session('/test/') {|req|
    req.cookies.clear
  }
  ok_title('FrontPage')     # You can see the FrontPage.
  ok_in(['Login'], "//div[@class='adminmenu']//a")  # But, not logged in.

  # Try to see the .new page
  res = session('/test/.new') {|req|
    req.cookies.clear
  }
  ok_title('Please log in.') # You can't see the form.
  ok_in(['You need to log in to use this function.'], 'p')
end
test_with_tag() click to toggle source
# File vendor/qwik/lib/qwik/act-new.rb, line 146
def test_with_tag
  t_add_user

  res = session("POST /test/.new?t=[tag] t")
  ok_xp([:a, {:href=>'t.edit'}, 'Edit new page'],
        "//div[@class='section']//a")
  page = @site['t']
  ok_eq("* [tag] t\n", page.load)
end