-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbulk_tagging_spec.rb
123 lines (94 loc) · 2.64 KB
/
bulk_tagging_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
require 'spec_helper'
require 'pry'
feature "Bulk tagging", :ui, :nightly do
shared_steps 'visit bulk tagging' do
include_steps 'login'
Given 'I am on the bulk tagging page' do
visit '/ip_taggings/create_many'
end
end
given(:tag) {'test'}
given(:submit) {'tag-submit-button'}
after do
# TODO: This is done because it is too hard to remove a tag using the UI
DB.new.del_tag tag
end
given(:tag_validation) {'#tag_validation'}
given(:ip_validation) {'#ips_and_fqdns_validation'}
Steps "requires all fields to be populated" do
include_steps 'visit bulk tagging'
When "I submit an empty form" do
click_button submit
end
Then "I should see an error on the tag field" do
within tag_validation do
expect(page).to have_content "This field is required."
end
end
Then "I should see an error on the IP / FQDN field" do
within ip_validation do
expect(page).to have_content "This field is required."
end
end
end
given(:ip) {'1.1.1.1'}
Steps "can tag IPs" do
include_steps 'visit bulk tagging'
When "I tag an IP" do
fill_in 'ips_and_fqdns', with: ip
fill_in 'Tag', with: tag
click_button submit
end
Then "the IP count raises" do
within '#results-ips-added' do
expect(page).to have_content '1'
end
end
And "the IP is tagged" do
visit "/ip/#{ip}"
within '#tag_list' do
expect(page).to have_content tag
end
end
end
given(:fqdn) {'google.com'}
Steps "can tag FQDNs" do
include_steps 'visit bulk tagging'
When 'I tag an FQDN' do
fill_in 'ips_and_fqdns', with: fqdn
fill_in 'Tag', with: tag
click_button submit
end
Then 'the FQDN count raises' do
within '#results-fqdn-added' do
expect(page).to have_content '1'
end
end
And 'the FQDN is tagged' do
visit "/dns/#{fqdn}"
within '#tag_list' do
expect(page).to have_content tag
end
end
end
Steps "marks duplicated tags" do
include_steps 'visit bulk tagging'
When 'I tag multiple IP and FQDNS' do
fill_in 'ips_and_fqdns', with: "#{ip}\n#{ip}\n#{fqdn}\n#{fqdn}\n#{fqdn}"
fill_in 'Tag', with: tag
click_button submit
# it can take a while for the bulk tagging page to return
wait_for do
page.has_selector? '#results-ips-duplicate'
end
end
Then 'it shows duplicates' do
within '#results-ips-duplicate' do
expect(page).to have_content '1'
end
within '#results-fqdn-duplicate' do
expect(page).to have_content '2'
end
end
end
end