Sha256: 2d0ed919e6875790ff15820adcadbd657450bf35a8f85e0b9b2c3593009959cd

Contents?: true

Size: 1.34 KB

Versions: 5

Compression:

Stored size: 1.34 KB

Contents

require 'test_helper'
require 'nextable_test'

module ParamTests
  class CycleTest < NextableTest
    test "default_will_cycle_by_id" do
      @first, @second, @third = create_three_users

      # final record of each direction
      assert_equal @first.previous_record(cycle: true), @third
      assert_equal @third.next_record(cycle: true), @first
    end

    test "cycle_by_date_field_example_date_of_birth" do
      @feb_1965, @feb_1942, @jan_1929 = create_three_users

      # final record of each direction
      assert_equal @jan_1929.previous_record(
        field: 'date_of_birth', cycle: true), @feb_1965
        assert_equal @feb_1965.next_record(
          field: 'date_of_birth', cycle: true), @jan_1929
    end

    test "cycle_by_integer_field_example_total_friends" do
      @six, @eight, @seven = create_three_users

      # final record of each direction
      assert_equal @six.previous_record(
        cycle: true, field: 'total_friends'), @eight
        assert_equal @eight.next_record(
          cycle: true, field: 'total_friends'), @six
    end

    test "cycle_by_string_field_example_name" do
      @malcolm, @huey, @mlk = create_three_users

      # final record of each direction
      assert_equal @mlk.next_record(cycle: true, field: 'name'), @huey
      assert_equal @huey.previous_record(cycle: true, field: 'name'), @mlk
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
nextable-0.0.11 test/param_tests/cycle_test.rb
nextable-0.0.10 test/param_tests/cycle_test.rb
nextable-0.0.9 test/param_tests/cycle_test.rb
nextable-0.0.8 test/param_tests/cycle_test.rb
nextable-0.0.7 test/param_tests/cycle_test.rb