Skip to content

Commit

Permalink
fix hound style violations in tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
botandrose-machine committed Apr 19, 2016
1 parent c97fca2 commit 99bc150
Showing 1 changed file with 29 additions and 17 deletions.
46 changes: 29 additions & 17 deletions test/test_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -626,50 +626,62 @@ def test_position_after_moving_to_empty_list
class TouchTest < ActsAsListTestCase
def setup
setup_db
4.times { ListMixin.create! updated_at: 1.day.ago }
4.times { ListMixin.create! updated_at: yesterday }
end

def now
Time.now.utc
end

def yesterday
1.day.ago
end

def updated_ats
ListMixin.pluck(:updated_at)
end

def test_moving_item_lower_touches_self_and_lower_item
ListMixin.first.move_lower
ListMixin.pluck(:updated_at)[0..1].each do |updated_at|
assert_in_delta updated_at, Time.now.utc, 1.second
updated_ats[0..1].each do |updated_at|
assert_in_delta updated_at, now, 1.second
end
ListMixin.pluck(:updated_at)[2..3].each do |updated_at|
assert_in_delta updated_at, 1.day.ago, 1.second
updated_ats[2..3].each do |updated_at|
assert_in_delta updated_at, yesterday, 1.second
end
end

def test_moving_item_higher_touches_self_and_higher_item
ListMixin.all.second.move_higher
ListMixin.pluck(:updated_at)[0..1].each do |updated_at|
assert_in_delta updated_at, Time.now.utc, 1.second
updated_ats[0..1].each do |updated_at|
assert_in_delta updated_at, now, 1.second
end
ListMixin.pluck(:updated_at)[2..3].each do |updated_at|
assert_in_delta updated_at, 1.day.ago, 1.second
updated_ats[2..3].each do |updated_at|
assert_in_delta updated_at, yesterday, 1.second
end
end

def test_moving_item_to_bottom_touches_all_other_items
ListMixin.first.move_to_bottom
ListMixin.pluck(:updated_at).each do |updated_at|
assert_in_delta updated_at, Time.now.utc, 1.second
updated_ats.each do |updated_at|
assert_in_delta updated_at, now, 1.second
end
end

def test_moving_item_to_top_touches_all_other_items
ListMixin.last.move_to_top
ListMixin.pluck(:updated_at).each do |updated_at|
assert_in_delta updated_at, Time.now.utc, 1.second
updated_ats.each do |updated_at|
assert_in_delta updated_at, now, 1.second
end
end

def test_removing_item_touches_all_lower_items
ListMixin.all.third.remove_from_list
ListMixin.pluck(:updated_at)[0..1].each do |updated_at|
assert_in_delta updated_at, 1.day.ago, 1.second
updated_ats[0..1].each do |updated_at|
assert_in_delta updated_at, yesterday, 1.second
end
ListMixin.pluck(:updated_at)[2..2].each do |updated_at|
assert_in_delta updated_at, Time.now.utc, 1.second
updated_ats[2..2].each do |updated_at|
assert_in_delta updated_at, now, 1.second
end
end
end

0 comments on commit 99bc150

Please sign in to comment.