Sha256: 673edfe2b540e715e84ca96a8472ca56b93657fc97db4605390179d5a8ba00dd

Contents?: true

Size: 1.64 KB

Versions: 1

Compression:

Stored size: 1.64 KB

Contents

require "test_helper"

class NavigationTest < ActionDispatch::IntegrationTest
  include Capybara::DSL

  test "renders per_page and current_page options" do
    visit "/static"

    assert page.has_selector?("nav.flexirails")
    assert page.has_selector?("#per_page")
    assert page.has_selector?("#current_page")
  end

  test "handles next_page and prev_page clicks properly" do
    visit "/static"

    assert page.has_selector?(".row-25")
    refute page.has_selector?(".row-50")

    find(".pagination .next").click

    refute page.has_selector?(".row-25")
    assert page.has_selector?(".row-50")

    find(".pagination .prev").click

    assert page.has_selector?(".row-25")
    refute page.has_selector?(".row-50")
  end

  test "handles first_page and last_page clicks properly" do
    Capybara.current_driver = Capybara.javascript_driver

    visit "/static"

    page.select("5", :from => "per_page")
    assert page.has_selector?(".row-5")
    refute page.has_selector?(".row-6")

    find(".pagination .last").click
    assert page.has_selector?(".row-46")
    refute page.has_selector?(".row-45")

    find(".pagination .first").click
    assert page.has_selector?(".row-5")
    refute page.has_selector?(".row-6")

    Capybara.use_default_driver
  end

  test "handles current_page properly on per_page changes" do
    Capybara.current_driver = Capybara.javascript_driver

    visit "/static"

    page.select("5", :from => "per_page")
    find(".pagination .last").click
    assert_equal "10", find("#current_page").value

    page.select("50", :from => "per_page")
    assert_equal "1", find("#current_page").value

    Capybara.use_default_driver
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
flexirails-0.1.0 test/views/flexirails/navigation_test.rb