releaf 2.0.0 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/releaf/rspec.rb +1 -0
- data/lib/releaf/rspec/features_matchers.rb +7 -13
- data/lib/releaf/rspec/helpers.rb +38 -12
- data/lib/releaf/rspec/matchers/have_number_of_resources.rb +13 -0
- data/lib/releaf/version.rb +1 -1
- metadata +31 -68
- data/spec/factories/author.rb +0 -6
- data/spec/factories/banner_page.rb +0 -5
- data/spec/factories/book.rb +0 -5
- data/spec/factories/chapter.rb +0 -7
- data/spec/factories/common.rb +0 -5
- data/spec/factories/home_page.rb +0 -5
- data/spec/factories/node.rb +0 -50
- data/spec/factories/node_route.rb +0 -7
- data/spec/factories/publisher.rb +0 -5
- data/spec/factories/role.rb +0 -21
- data/spec/factories/text_page.rb +0 -5
- data/spec/factories/user.rb +0 -22
- data/spec/rails_helper.rb +0 -129
- data/spec/spec_helper.rb +0 -86
- data/spec/support/capybra_actions.rb +0 -6
- data/spec/support/controller_macros.rb +0 -8
- data/spec/support/excel_helpers.rb +0 -63
- data/spec/support/shared/service_includer.rb +0 -9
- data/spec/support/wait_steps.rb +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b895082ef3e58a6e13a00b977fc54a6b01250030fb874f9db98dfa6ef14a5535
|
4
|
+
data.tar.gz: fe83d701140fb0a52fceb1532e0026ea971e60d8f4972f024b96c5de95fd608c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81443f4803c172bc01160a29f77805163ed395bbbe44ac94ab0b27ec30345a2acc9dc005cd0fcd77c66033a5f1545495b80026cb9149e491be1feb2c6703178b
|
7
|
+
data.tar.gz: e340295630ea9468f25ad6142283b8dca734a4dc66b74ee2920954046a97766022b071ea9cf6056965b66f22a00a4206cd6aa8a7a3bc6c85e558ab54cb07c838
|
data/lib/releaf/rspec.rb
CHANGED
@@ -12,20 +12,14 @@ module Capybara
|
|
12
12
|
has_selector?(type, count: cells_count) && has_text?(cells.join(""))
|
13
13
|
end
|
14
14
|
|
15
|
-
def has_header?(
|
16
|
-
has_css?("#{primary_header_css_rule} h1",
|
15
|
+
def has_header?(**args)
|
16
|
+
has_css?("#{primary_header_css_rule} h1", **args)
|
17
17
|
end
|
18
18
|
|
19
|
-
def has_no_header?(
|
20
|
-
has_no_css?("#{primary_header_css_rule} h1",
|
19
|
+
def has_no_header?(**args)
|
20
|
+
has_no_css?("#{primary_header_css_rule} h1", **args)
|
21
21
|
end
|
22
22
|
|
23
|
-
|
24
|
-
def has_number_of_resources?(count)
|
25
|
-
has_css?("#{primary_header_css_rule} .totals", text: "#{count} resources found")
|
26
|
-
end
|
27
|
-
|
28
|
-
|
29
23
|
# Allows to match againg validation errors within forms
|
30
24
|
# Support either model specific (base) errors with:
|
31
25
|
# expect(page).to have_error('Global form error message')
|
@@ -40,7 +34,7 @@ module Capybara
|
|
40
34
|
error_found = false
|
41
35
|
if options[:field]
|
42
36
|
first('.field.has-error', minimum: 1) # wait for any errors to come from validation
|
43
|
-
all(".field.has-error").each do |field_container|
|
37
|
+
all(".field.has-error", wait: false).each do |field_container|
|
44
38
|
if !error_found
|
45
39
|
within(field_container) do
|
46
40
|
if has_field?(options[:field], wait: false) && has_css?(".error", text: error_message, wait: false)
|
@@ -50,7 +44,7 @@ module Capybara
|
|
50
44
|
end
|
51
45
|
end
|
52
46
|
else
|
53
|
-
if first(".form-error-box .error", text: error_message)
|
47
|
+
if first(".form-error-box .error", text: error_message, minimum: 0)
|
54
48
|
error_found = true
|
55
49
|
end
|
56
50
|
end
|
@@ -74,7 +68,7 @@ module Capybara
|
|
74
68
|
|
75
69
|
def has_notification?(text, type="success")
|
76
70
|
result = has_css?(".notifications .notification[data-type='#{type}']", text: text)
|
77
|
-
if first(".notifications button.close")
|
71
|
+
if first(".notifications button.close", minimum: 0)
|
78
72
|
find(".notifications .notification[data-type='#{type}'] button.close").click
|
79
73
|
has_no_css?(".notifications .notification[data-type='#{type}'] button.close")
|
80
74
|
end
|
data/lib/releaf/rspec/helpers.rb
CHANGED
@@ -89,11 +89,17 @@ module Releaf::Test
|
|
89
89
|
def wait_for_all_richtexts
|
90
90
|
# wait for all ckeditors to fully initialize before moving on.
|
91
91
|
# otherwise the page sometimes produces random js errors in fast tests
|
92
|
-
number_of_normal_richtexts = page.all('.field.type-richtext:not(.i18n)', wait:
|
93
|
-
number_of_localized_richtexts = page.all('.field.type-richtext.i18n .localization', wait:
|
94
|
-
|
95
|
-
|
96
|
-
|
92
|
+
number_of_normal_richtexts = page.all('.field.type-richtext:not(.i18n)', wait: false).length
|
93
|
+
number_of_localized_richtexts = page.all('.field.type-richtext.i18n .localization', wait: false, visible: false).length
|
94
|
+
|
95
|
+
# some richtexts may have been inside nested association items that have been removed (they actually only get hidden).
|
96
|
+
# they must be included in the count because they retain their 'ckeditor-initialized' class even after the editor has been unloaded
|
97
|
+
number_of_removed_normal_richtexts = page.all('fieldset.item.type-association.removed .field.type-richtext:not(.i18n)', wait: false, visible: false).length
|
98
|
+
|
99
|
+
number_of_initialized_richtexts = number_of_normal_richtexts + number_of_localized_richtexts + number_of_removed_normal_richtexts
|
100
|
+
if number_of_initialized_richtexts > 0
|
101
|
+
# expect _at least_ that many richtexts. others may have been initialized and hidden by some custom code
|
102
|
+
expect(page).to have_css(".ckeditor-initialized", visible: false, minimum: number_of_initialized_richtexts)
|
97
103
|
end
|
98
104
|
end
|
99
105
|
|
@@ -119,13 +125,27 @@ module Releaf::Test
|
|
119
125
|
wait_for_all_richtexts
|
120
126
|
end
|
121
127
|
|
122
|
-
def
|
128
|
+
def close_all_notifications
|
129
|
+
page.all('body > .notifications .notification[data-id="resource_status"]', wait: false).each do |notification|
|
130
|
+
within(notification) { find('button.close').click }
|
131
|
+
end
|
132
|
+
expect(page).to have_no_css('body > .notifications .notification[data-id="resource_status"]')
|
133
|
+
end
|
134
|
+
|
135
|
+
def save_and_check_response(status_text, button_text = "Save")
|
123
136
|
wait_for_all_richtexts
|
124
|
-
|
125
|
-
|
137
|
+
# close any existing notifications
|
138
|
+
close_all_notifications
|
139
|
+
within page.document.find("form[data-remote-validation-initialized='true']") do
|
140
|
+
click_button button_text
|
141
|
+
end
|
142
|
+
notification = find('body > .notifications .notification[data-id="resource_status"][data-type="success"]', text: status_text)
|
143
|
+
within(notification) { find('button.close').click }
|
144
|
+
expect(page).to have_no_css('body > .notifications .notification[data-id="resource_status"]')
|
126
145
|
wait_for_all_richtexts
|
127
146
|
end
|
128
147
|
|
148
|
+
|
129
149
|
# As there is no visual UI for settings update being successful
|
130
150
|
# do check against database
|
131
151
|
def wait_for_settings_update(key, value = true)
|
@@ -206,7 +226,7 @@ module Releaf::Test
|
|
206
226
|
|
207
227
|
# locate possibly hidden textarea among active/visible richtext fields ignoring hidden localization versions
|
208
228
|
textareas = []
|
209
|
-
richtext_boxes = all(".field.type-richtext:not(.i18n), .field.type-richtext.i18n .localization.active")
|
229
|
+
richtext_boxes = all(".field.type-richtext:not(.i18n), .field.type-richtext.i18n .localization.active", wait: false)
|
210
230
|
richtext_boxes.each do |richtext_box|
|
211
231
|
textarea = richtext_box.first(:field, locator, visible: false, minimum: 0)
|
212
232
|
textareas << textarea if textarea.present?
|
@@ -231,16 +251,22 @@ module Releaf::Test
|
|
231
251
|
|
232
252
|
def add_nested_item(block_name, expected_item_index)
|
233
253
|
scroll_to_bottom_of_page
|
234
|
-
all('button', text: 'Add item').last.click # use last button in case of multiple nested items
|
254
|
+
all('button', text: 'Add item', wait: false).last.click # use last button in case of multiple nested items
|
235
255
|
wait_for_nested_item block_name, expected_item_index
|
236
256
|
|
237
257
|
if block_given?
|
238
|
-
|
258
|
+
within_nested_item block_name, expected_item_index do
|
239
259
|
yield
|
240
260
|
end
|
241
261
|
end
|
242
262
|
end
|
243
263
|
|
264
|
+
def within_nested_item block_name, item_index
|
265
|
+
within(".item[data-name='#{block_name}'][data-index='#{item_index}']") do
|
266
|
+
yield
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
244
270
|
def remove_nested_item(block_name, item_index)
|
245
271
|
base_selector = ".item[data-name=\"#{block_name}\"][data-index=\"#{item_index}\"]"
|
246
272
|
page.find("#{base_selector} > .remove-item-box button.remove-nested-item").click
|
@@ -258,7 +284,7 @@ module Releaf::Test
|
|
258
284
|
require "open-uri"
|
259
285
|
file = Tempfile.new
|
260
286
|
file.binmode
|
261
|
-
file.write(open(url).read)
|
287
|
+
file.write(URI.open(url).read)
|
262
288
|
file.flush
|
263
289
|
file
|
264
290
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
RSpec::Matchers.define :have_number_of_resources do |number_of_resources|
|
2
|
+
|
3
|
+
match do |subject|
|
4
|
+
@text = "#{number_of_resources} resources found"
|
5
|
+
@node = find "main > section header .totals"
|
6
|
+
@node.has_text? @text, exact: true
|
7
|
+
end
|
8
|
+
|
9
|
+
failure_message do |subject|
|
10
|
+
"expected #{@node.text.inspect} to match #{@text.inspect}"
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
data/lib/releaf/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: releaf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CubeSystems
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: releaf-core
|
@@ -16,56 +16,56 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.
|
19
|
+
version: 2.1.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.
|
26
|
+
version: 2.1.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: releaf-i18n_database
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 2.
|
33
|
+
version: 2.1.2
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 2.
|
40
|
+
version: 2.1.2
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: releaf-permissions
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - '='
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 2.
|
47
|
+
version: 2.1.2
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - '='
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 2.
|
54
|
+
version: 2.1.2
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: releaf-content
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 2.
|
61
|
+
version: 2.1.2
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 2.
|
68
|
+
version: 2.1.2
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec-rails
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,42 +100,42 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 3.
|
103
|
+
version: '3.0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 3.
|
110
|
+
version: '3.0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: capybara
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: '3.
|
117
|
+
version: '3.0'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: '3.
|
124
|
+
version: '3.0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: selenium-webdriver
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: '3.
|
131
|
+
version: '3.0'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: '3.
|
138
|
+
version: '3.0'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: factory_bot
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -170,14 +170,14 @@ dependencies:
|
|
170
170
|
requirements:
|
171
171
|
- - "~>"
|
172
172
|
- !ruby/object:Gem::Version
|
173
|
-
version: 0.16
|
173
|
+
version: '0.16'
|
174
174
|
type: :development
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
178
|
- - "~>"
|
179
179
|
- !ruby/object:Gem::Version
|
180
|
-
version: 0.16
|
180
|
+
version: '0.16'
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
182
|
name: simplecov-rcov
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -198,28 +198,28 @@ dependencies:
|
|
198
198
|
requirements:
|
199
199
|
- - "~>"
|
200
200
|
- !ruby/object:Gem::Version
|
201
|
-
version: '1.
|
201
|
+
version: '1.0'
|
202
202
|
type: :development
|
203
203
|
prerelease: false
|
204
204
|
version_requirements: !ruby/object:Gem::Requirement
|
205
205
|
requirements:
|
206
206
|
- - "~>"
|
207
207
|
- !ruby/object:Gem::Version
|
208
|
-
version: '1.
|
208
|
+
version: '1.0'
|
209
209
|
- !ruby/object:Gem::Dependency
|
210
210
|
name: shoulda-matchers
|
211
211
|
requirement: !ruby/object:Gem::Requirement
|
212
212
|
requirements:
|
213
213
|
- - "~>"
|
214
214
|
- !ruby/object:Gem::Version
|
215
|
-
version: '4.
|
215
|
+
version: '4.0'
|
216
216
|
type: :development
|
217
217
|
prerelease: false
|
218
218
|
version_requirements: !ruby/object:Gem::Requirement
|
219
219
|
requirements:
|
220
220
|
- - "~>"
|
221
221
|
- !ruby/object:Gem::Version
|
222
|
-
version: '4.
|
222
|
+
version: '4.0'
|
223
223
|
- !ruby/object:Gem::Dependency
|
224
224
|
name: db-query-matchers
|
225
225
|
requirement: !ruby/object:Gem::Requirement
|
@@ -268,14 +268,14 @@ dependencies:
|
|
268
268
|
requirements:
|
269
269
|
- - "~>"
|
270
270
|
- !ruby/object:Gem::Version
|
271
|
-
version: '2.
|
271
|
+
version: '2.0'
|
272
272
|
type: :development
|
273
273
|
prerelease: false
|
274
274
|
version_requirements: !ruby/object:Gem::Requirement
|
275
275
|
requirements:
|
276
276
|
- - "~>"
|
277
277
|
- !ruby/object:Gem::Version
|
278
|
-
version: '2.
|
278
|
+
version: '2.0'
|
279
279
|
- !ruby/object:Gem::Dependency
|
280
280
|
name: pry
|
281
281
|
requirement: !ruby/object:Gem::Requirement
|
@@ -308,16 +308,16 @@ dependencies:
|
|
308
308
|
name: puma
|
309
309
|
requirement: !ruby/object:Gem::Requirement
|
310
310
|
requirements:
|
311
|
-
- - "
|
311
|
+
- - ">="
|
312
312
|
- !ruby/object:Gem::Version
|
313
|
-
version: '
|
313
|
+
version: '0'
|
314
314
|
type: :development
|
315
315
|
prerelease: false
|
316
316
|
version_requirements: !ruby/object:Gem::Requirement
|
317
317
|
requirements:
|
318
|
-
- - "
|
318
|
+
- - ">="
|
319
319
|
- !ruby/object:Gem::Version
|
320
|
-
version: '
|
320
|
+
version: '0'
|
321
321
|
description: Administration interface for Ruby on Rails
|
322
322
|
email: info@cubesystems.lv
|
323
323
|
executables: []
|
@@ -332,28 +332,10 @@ files:
|
|
332
332
|
- lib/releaf/rspec/features_matchers.rb
|
333
333
|
- lib/releaf/rspec/helpers.rb
|
334
334
|
- lib/releaf/rspec/matchers/cache_instance_method.rb
|
335
|
+
- lib/releaf/rspec/matchers/have_number_of_resources.rb
|
335
336
|
- lib/releaf/rspec/matchers/match_html.rb
|
336
337
|
- lib/releaf/test.rb
|
337
338
|
- lib/releaf/version.rb
|
338
|
-
- spec/factories/author.rb
|
339
|
-
- spec/factories/banner_page.rb
|
340
|
-
- spec/factories/book.rb
|
341
|
-
- spec/factories/chapter.rb
|
342
|
-
- spec/factories/common.rb
|
343
|
-
- spec/factories/home_page.rb
|
344
|
-
- spec/factories/node.rb
|
345
|
-
- spec/factories/node_route.rb
|
346
|
-
- spec/factories/publisher.rb
|
347
|
-
- spec/factories/role.rb
|
348
|
-
- spec/factories/text_page.rb
|
349
|
-
- spec/factories/user.rb
|
350
|
-
- spec/rails_helper.rb
|
351
|
-
- spec/spec_helper.rb
|
352
|
-
- spec/support/capybra_actions.rb
|
353
|
-
- spec/support/controller_macros.rb
|
354
|
-
- spec/support/excel_helpers.rb
|
355
|
-
- spec/support/shared/service_includer.rb
|
356
|
-
- spec/support/wait_steps.rb
|
357
339
|
homepage: https://github.com/cubesystems/releaf
|
358
340
|
licenses:
|
359
341
|
- MIT
|
@@ -373,27 +355,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
373
355
|
- !ruby/object:Gem::Version
|
374
356
|
version: '0'
|
375
357
|
requirements: []
|
376
|
-
rubygems_version: 3.
|
358
|
+
rubygems_version: 3.2.6
|
377
359
|
signing_key:
|
378
360
|
specification_version: 4
|
379
361
|
summary: Administration interface for Ruby on Rails
|
380
|
-
test_files:
|
381
|
-
- spec/factories/node_route.rb
|
382
|
-
- spec/factories/publisher.rb
|
383
|
-
- spec/factories/node.rb
|
384
|
-
- spec/factories/banner_page.rb
|
385
|
-
- spec/factories/book.rb
|
386
|
-
- spec/factories/common.rb
|
387
|
-
- spec/factories/home_page.rb
|
388
|
-
- spec/factories/author.rb
|
389
|
-
- spec/factories/role.rb
|
390
|
-
- spec/factories/text_page.rb
|
391
|
-
- spec/factories/user.rb
|
392
|
-
- spec/factories/chapter.rb
|
393
|
-
- spec/support/wait_steps.rb
|
394
|
-
- spec/support/controller_macros.rb
|
395
|
-
- spec/support/excel_helpers.rb
|
396
|
-
- spec/support/capybra_actions.rb
|
397
|
-
- spec/support/shared/service_includer.rb
|
398
|
-
- spec/spec_helper.rb
|
399
|
-
- spec/rails_helper.rb
|
362
|
+
test_files: []
|
data/spec/factories/author.rb
DELETED
data/spec/factories/book.rb
DELETED
data/spec/factories/chapter.rb
DELETED
data/spec/factories/common.rb
DELETED
data/spec/factories/home_page.rb
DELETED
data/spec/factories/node.rb
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
FactoryBot.define do
|
2
|
-
factory :node, class: ::Node do
|
3
|
-
sequence(:name) {|n| "node #{n}"}
|
4
|
-
sequence(:slug) {|n| "node-#{n}"}
|
5
|
-
content_type { "HomePage" }
|
6
|
-
end
|
7
|
-
|
8
|
-
factory :other_node, class: ::OtherSite::OtherNode do
|
9
|
-
sequence(:name) {|n| "node #{n}"}
|
10
|
-
sequence(:slug) {|n| "node-#{n}"}
|
11
|
-
content_type { "HomePage" }
|
12
|
-
end
|
13
|
-
|
14
|
-
factory :home_page_node, class: ::Node do
|
15
|
-
sequence(:name) {|n| "node #{n}"}
|
16
|
-
sequence(:slug) {|n| "node-#{n}"}
|
17
|
-
content_type { "HomePage" }
|
18
|
-
content_attributes {{ intro_text_html: "some <strong>STRRRONG</strong> text" }}
|
19
|
-
end
|
20
|
-
|
21
|
-
factory :other_home_page_node, class: ::OtherSite::OtherNode do
|
22
|
-
sequence(:name) {|n| "node #{n}"}
|
23
|
-
sequence(:slug) {|n| "node-#{n}"}
|
24
|
-
content_type { "HomePage" }
|
25
|
-
content_attributes {{ intro_text_html: "some <strong>STRRRONG</strong> text" }}
|
26
|
-
end
|
27
|
-
|
28
|
-
factory :text_page_node, class: ::Node do
|
29
|
-
sequence(:name) {|n| "node #{n}"}
|
30
|
-
sequence(:slug) {|n| "node-#{n}"}
|
31
|
-
content_type { "TextPage" }
|
32
|
-
content_attributes {{ text_html: "some <strong>STRIONG</strong> text" }}
|
33
|
-
end
|
34
|
-
|
35
|
-
factory :other_text_page_node, class: ::OtherSite::OtherNode do
|
36
|
-
sequence(:name) {|n| "node #{n}"}
|
37
|
-
sequence(:slug) {|n| "node-#{n}"}
|
38
|
-
content_type { "TextPage" }
|
39
|
-
content_attributes {{ text_html: "some <strong>STRIONG</strong> text" }}
|
40
|
-
end
|
41
|
-
|
42
|
-
factory :banner_page_node, class: ::Node do
|
43
|
-
sequence(:name) {|n| "node #{n}"}
|
44
|
-
sequence(:slug) {|n| "node-#{n}"}
|
45
|
-
content_type { "BannerPage" }
|
46
|
-
content_attributes {{}}
|
47
|
-
end
|
48
|
-
|
49
|
-
|
50
|
-
end
|
data/spec/factories/publisher.rb
DELETED
data/spec/factories/role.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
FactoryBot.define do
|
2
|
-
factory :roles, :class => Releaf::Permissions::Role do
|
3
|
-
sequence(:name) {|n| "role #{n}"}
|
4
|
-
|
5
|
-
factory :admin_role do
|
6
|
-
default_controller { "releaf/permissions/users" }
|
7
|
-
after(:create) do |role|
|
8
|
-
Releaf.application.config.available_controllers.each do|controller|
|
9
|
-
role.permissions.create!(permission: "controller.#{controller}")
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
factory :content_role do
|
15
|
-
default_controller { "admin/nodes" }
|
16
|
-
after(:create) do |role|
|
17
|
-
role.permissions.create!(permission: "controller.admin/nodes")
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
data/spec/factories/text_page.rb
DELETED
data/spec/factories/user.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
FactoryBot.define do
|
2
|
-
factory :users, class: Releaf::Permissions::User do
|
3
|
-
trait :user_basic do
|
4
|
-
email
|
5
|
-
name
|
6
|
-
surname
|
7
|
-
locale { 'en' }
|
8
|
-
password { 'password' }
|
9
|
-
password_confirmation { 'password' }
|
10
|
-
end
|
11
|
-
|
12
|
-
factory :user do
|
13
|
-
user_basic
|
14
|
-
association :role, factory: :admin_role
|
15
|
-
end
|
16
|
-
|
17
|
-
factory :content_user do
|
18
|
-
user_basic
|
19
|
-
association :role, factory: :content_role
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
data/spec/rails_helper.rb
DELETED
@@ -1,129 +0,0 @@
|
|
1
|
-
require 'simplecov'
|
2
|
-
require 'simplecov-rcov'
|
3
|
-
require 'coveralls'
|
4
|
-
require 'pry'
|
5
|
-
SimpleCov.command_name 'rspec'
|
6
|
-
|
7
|
-
Coveralls.wear!('rails')
|
8
|
-
|
9
|
-
if ENV["COVERAGE"]
|
10
|
-
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
|
11
|
-
SimpleCov::Formatter::HTMLFormatter,
|
12
|
-
SimpleCov::Formatter::RcovFormatter,
|
13
|
-
Coveralls::SimpleCov::Formatter
|
14
|
-
])
|
15
|
-
SimpleCov.start do
|
16
|
-
add_filter '/lib/releaf/rspec'
|
17
|
-
add_filter '/spec/'
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
ENV["RAILS_ENV"] ||= 'test'
|
22
|
-
require 'spec_helper'
|
23
|
-
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
24
|
-
require 'rspec/rails'
|
25
|
-
require 'rails-controller-testing'
|
26
|
-
require 'factory_bot'
|
27
|
-
require "shoulda-matchers"
|
28
|
-
require 'db-query-matchers'
|
29
|
-
require 'selenium/webdriver'
|
30
|
-
require 'with_model'
|
31
|
-
require 'timecop'
|
32
|
-
require 'with_model'
|
33
|
-
require 'database_cleaner'
|
34
|
-
require 'releaf/rspec'
|
35
|
-
|
36
|
-
Rails.backtrace_cleaner.remove_silencers!
|
37
|
-
# Load support files
|
38
|
-
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
39
|
-
|
40
|
-
# for devise testing
|
41
|
-
include Warden::Test::Helpers
|
42
|
-
|
43
|
-
Capybara.register_driver(:chrome) do |app|
|
44
|
-
options = ::Selenium::WebDriver::Chrome::Options.new
|
45
|
-
options.add_argument('--headless')
|
46
|
-
options.add_argument('--window-size=1400,900')
|
47
|
-
|
48
|
-
if ENV['CI']
|
49
|
-
options.add_argument('--no-sandbox')
|
50
|
-
options.add_argument('--disable-dev-shm-usage')
|
51
|
-
end
|
52
|
-
|
53
|
-
Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)
|
54
|
-
end
|
55
|
-
|
56
|
-
Capybara.javascript_driver = :chrome
|
57
|
-
|
58
|
-
Capybara.default_set_options = { clear: :backspace } # needed for 'fill_in "Foo", with: ""' to work
|
59
|
-
|
60
|
-
RSpec.configure do |config|
|
61
|
-
config.use_transactional_fixtures = false
|
62
|
-
config.infer_base_class_for_anonymous_controllers = false
|
63
|
-
config.order = "random"
|
64
|
-
config.infer_spec_type_from_file_location!
|
65
|
-
|
66
|
-
config.include Shoulda::Matchers::ActiveModel, type: :model
|
67
|
-
config.include Shoulda::Matchers::ActiveRecord, type: :model
|
68
|
-
config.include Shoulda::Matchers::Independent
|
69
|
-
|
70
|
-
config.color = true
|
71
|
-
|
72
|
-
if ENV['COVERAGE']
|
73
|
-
config.add_formatter(:progress)
|
74
|
-
end
|
75
|
-
|
76
|
-
config.include Releaf::Test::Helpers
|
77
|
-
config.include CapybaraActions, type: :feature
|
78
|
-
config.include WaitSteps
|
79
|
-
config.include ExcelHelpers
|
80
|
-
config.extend WithModel
|
81
|
-
|
82
|
-
config.include Rails.application.routes.url_helpers
|
83
|
-
|
84
|
-
# DEVISE
|
85
|
-
config.include Devise::Test::ControllerHelpers, type: :controller
|
86
|
-
config.extend ControllerMacros, type: :controller
|
87
|
-
config.include Devise::Test::ControllerHelpers, type: :helper
|
88
|
-
config.extend ControllerMacros, type: :helper
|
89
|
-
|
90
|
-
|
91
|
-
[:controller, :view, :request].each do |type|
|
92
|
-
config.include ::Rails::Controller::Testing::TestProcess, type: type
|
93
|
-
config.include ::Rails::Controller::Testing::TemplateAssertions, type: type
|
94
|
-
config.include ::Rails::Controller::Testing::Integration, type: type
|
95
|
-
end
|
96
|
-
|
97
|
-
|
98
|
-
config.include FactoryBot::Syntax::Methods
|
99
|
-
|
100
|
-
Capybara.default_normalize_ws = true
|
101
|
-
|
102
|
-
# disable empty translation creation
|
103
|
-
|
104
|
-
config.before(:each) do |example|
|
105
|
-
Rails.cache.clear
|
106
|
-
allow( Releaf.application.config.i18n_database ).to receive(:translation_auto_creation).and_return(false)
|
107
|
-
|
108
|
-
if example.metadata[:db_strategy]
|
109
|
-
DatabaseCleaner.strategy = example.metadata[:db_strategy]
|
110
|
-
elsif Capybara.current_driver == :rack_test
|
111
|
-
DatabaseCleaner.strategy = :transaction
|
112
|
-
else
|
113
|
-
DatabaseCleaner.strategy = :truncation
|
114
|
-
end
|
115
|
-
|
116
|
-
DatabaseCleaner.start
|
117
|
-
# set settings
|
118
|
-
I18n.locale = Releaf.application.config.available_locales.first
|
119
|
-
I18n.default_locale = Releaf.application.config.available_locales.first
|
120
|
-
end
|
121
|
-
|
122
|
-
config.after do
|
123
|
-
Timecop.return
|
124
|
-
DatabaseCleaner.clean
|
125
|
-
Releaf::Test.reset!
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
Dir["#{File.dirname(__FILE__)}/factories/*.rb"].each { |f| require f }
|
data/spec/spec_helper.rb
DELETED
@@ -1,86 +0,0 @@
|
|
1
|
-
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
|
2
|
-
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
-
# The generated `.rspec` file contains `--require spec_helper` which will cause this
|
4
|
-
# file to always be loaded, without a need to explicitly require it in any files.
|
5
|
-
#
|
6
|
-
# Given that it is always loaded, you are encouraged to keep this file as
|
7
|
-
# light-weight as possible. Requiring heavyweight dependencies from this file
|
8
|
-
# will add to the boot time of your test suite on EVERY test run, even for an
|
9
|
-
# individual file that may not need all of that loaded. Instead, consider making
|
10
|
-
# a separate helper file that requires the additional dependencies and performs
|
11
|
-
# the additional setup, and require it from the spec files that actually need it.
|
12
|
-
#
|
13
|
-
# The `.rspec` file also contains a few flags that are not defaults but that
|
14
|
-
# users commonly want.
|
15
|
-
#
|
16
|
-
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
17
|
-
RSpec.configure do |config|
|
18
|
-
# rspec-expectations config goes here. You can use an alternate
|
19
|
-
# assertion/expectation library such as wrong or the stdlib/minitest
|
20
|
-
# assertions if you prefer.
|
21
|
-
config.expect_with :rspec do |expectations|
|
22
|
-
# This option will default to `true` in RSpec 4. It makes the `description`
|
23
|
-
# and `failure_message` of custom matchers include text for helper methods
|
24
|
-
# defined using `chain`, e.g.:
|
25
|
-
# be_bigger_than(2).and_smaller_than(4).description
|
26
|
-
# # => "be bigger than 2 and smaller than 4"
|
27
|
-
# ...rather than:
|
28
|
-
# # => "be bigger than 2"
|
29
|
-
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
30
|
-
end
|
31
|
-
|
32
|
-
# rspec-mocks config goes here. You can use an alternate test double
|
33
|
-
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
34
|
-
config.mock_with :rspec do |mocks|
|
35
|
-
# Prevents you from mocking or stubbing a method that does not exist on
|
36
|
-
# a real object. This is generally recommended, and will default to
|
37
|
-
# `true` in RSpec 4.
|
38
|
-
mocks.verify_partial_doubles = true
|
39
|
-
end
|
40
|
-
|
41
|
-
# The settings below are suggested to provide a good initial experience
|
42
|
-
# with RSpec, but feel free to customize to your heart's content.
|
43
|
-
=begin
|
44
|
-
# These two settings work together to allow you to limit a spec run
|
45
|
-
# to individual examples or groups you care about by tagging them with
|
46
|
-
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
47
|
-
# get run.
|
48
|
-
config.filter_run :focus
|
49
|
-
config.run_all_when_everything_filtered = true
|
50
|
-
|
51
|
-
# Limits the available syntax to the non-monkey patched syntax that is recommended.
|
52
|
-
# For more details, see:
|
53
|
-
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
54
|
-
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
55
|
-
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
56
|
-
config.disable_monkey_patching!
|
57
|
-
|
58
|
-
# Many RSpec users commonly either run the entire suite or an individual
|
59
|
-
# file, and it's useful to allow more verbose output when running an
|
60
|
-
# individual spec file.
|
61
|
-
if config.files_to_run.one?
|
62
|
-
# Use the documentation formatter for detailed output,
|
63
|
-
# unless a formatter has already been configured
|
64
|
-
# (e.g. via a command-line flag).
|
65
|
-
config.default_formatter = 'doc'
|
66
|
-
end
|
67
|
-
|
68
|
-
# Print the 10 slowest examples and example groups at the
|
69
|
-
# end of the spec run, to help surface which specs are running
|
70
|
-
# particularly slow.
|
71
|
-
config.profile_examples = 10
|
72
|
-
|
73
|
-
# Run specs in random order to surface order dependencies. If you find an
|
74
|
-
# order dependency and want to debug it, you can fix the order by providing
|
75
|
-
# the seed, which is printed after each run.
|
76
|
-
# --seed 1234
|
77
|
-
config.order = :random
|
78
|
-
|
79
|
-
# Seed global randomization in this process using the `--seed` CLI option.
|
80
|
-
# Setting this allows you to use `--seed` to deterministically reproduce
|
81
|
-
# test failures related to randomization by passing the same `--seed` value
|
82
|
-
# as the one that triggered the failure.
|
83
|
-
Kernel.srand config.seed
|
84
|
-
=end
|
85
|
-
end
|
86
|
-
|
@@ -1,63 +0,0 @@
|
|
1
|
-
module ExcelHelpers
|
2
|
-
class ExcelMatcher
|
3
|
-
require 'roo'
|
4
|
-
|
5
|
-
def initialize(fixture_path)
|
6
|
-
@fixture_path = fixture_path
|
7
|
-
@errors = []
|
8
|
-
end
|
9
|
-
|
10
|
-
def matches?(actual_path)
|
11
|
-
match_excel(actual_path)
|
12
|
-
|
13
|
-
@errors.empty?
|
14
|
-
end
|
15
|
-
|
16
|
-
def failure_message
|
17
|
-
"Following cells differ from expected: #{error_messages}"
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def error_messages
|
23
|
-
messages = []
|
24
|
-
@errors.each do |error|
|
25
|
-
messages << "#{error[:cell]} (expect: #{error[:fixture_value]} was: #{error[:actual_value]})"
|
26
|
-
end
|
27
|
-
|
28
|
-
messages.join(', ')
|
29
|
-
end
|
30
|
-
|
31
|
-
def match_excel actual_path
|
32
|
-
fixture = Roo::Spreadsheet.open(@fixture_path)
|
33
|
-
fixture.default_sheet = fixture.sheets.first
|
34
|
-
|
35
|
-
actual = Roo::Spreadsheet.open(actual_path)
|
36
|
-
actual.default_sheet = actual.sheets.first
|
37
|
-
|
38
|
-
match_sheet(actual, fixture)
|
39
|
-
end
|
40
|
-
|
41
|
-
def match_sheet actual, fixture
|
42
|
-
rows = fixture.first_row..fixture.last_row
|
43
|
-
columns = fixture.first_column..fixture.last_column
|
44
|
-
for row in rows
|
45
|
-
for column in columns
|
46
|
-
fixture_value = fixture.cell(row, column)
|
47
|
-
actual_value = actual.cell(row, column)
|
48
|
-
if fixture_value.to_s != actual_value.to_s
|
49
|
-
@errors << {
|
50
|
-
cell: "#{Roo::Utils.number_to_letter(column)}#{row}",
|
51
|
-
fixture_value: fixture_value,
|
52
|
-
actual_value: actual_value
|
53
|
-
}
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def match_excel(fixture_path)
|
61
|
-
ExcelMatcher.new(fixture_path)
|
62
|
-
end
|
63
|
-
end
|
data/spec/support/wait_steps.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
require "timeout"
|
2
|
-
|
3
|
-
module WaitSteps
|
4
|
-
extend RSpec::Matchers::DSL
|
5
|
-
|
6
|
-
matcher :become_true do
|
7
|
-
match do |block|
|
8
|
-
begin
|
9
|
-
Timeout.timeout(Capybara.default_max_wait_time) do
|
10
|
-
sleep(0.1) until value = block.call
|
11
|
-
sleep(0.2)
|
12
|
-
value
|
13
|
-
end
|
14
|
-
rescue TimeoutError
|
15
|
-
false
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def supports_block_expectations?
|
20
|
-
true
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|