]> git.openstreetmap.org Git - rails.git/blob - test/system/element_history_test.rb
Merge remote-tracking branch 'upstream/pull/6115'
[rails.git] / test / system / element_history_test.rb
1 require "application_system_test_case"
2
3 class ElementHistoryTest < ApplicationSystemTestCase
4   test "can view node history" do
5     node = create(:node, :with_history, :version => 41)
6
7     visit node_path(node)
8
9     check_element_history(->(v) { old_node_path(node, v) })
10   end
11
12   test "can view way history" do
13     way = create(:way, :with_history, :version => 41)
14
15     visit way_path(way)
16
17     check_element_history(->(v) { old_way_path(way, v) })
18   end
19
20   test "can view relation history" do
21     relation = create(:relation, :with_history, :version => 41)
22
23     visit relation_path(relation)
24
25     check_element_history(->(v) { old_relation_path(relation, v) })
26   end
27
28   private
29
30   def check_element_history(get_path)
31     within_sidebar do
32       click_on "View History"
33
34       41.downto(22) do |v|
35         assert_link v.to_s, :href => get_path.call(v)
36       end
37
38       click_on "Older Versions"
39
40       41.downto(2) do |v|
41         assert_link v.to_s, :href => get_path.call(v)
42       end
43
44       click_on "Older Versions"
45
46       41.downto(1) do |v|
47         assert_link v.to_s, :href => get_path.call(v)
48       end
49
50       assert_no_link "Older Versions"
51     end
52   end
53 end