releaf 1.1.21 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f0b6f031a1e1021297e07ba243738190f627820023ee83bc7a4797845c6b8058
4
- data.tar.gz: 38bb61cb5b6aedff7b1bab578ad567ed6f4bd96123e3cef9ca5a8e1457686592
3
+ metadata.gz: 4c93eb6d7f909d36e5bf7eec843bae353abe88071bc2332504541cfe24f84e3e
4
+ data.tar.gz: b68f9327a71d331178449165902c187ad96456ab18bfe8dd7025457b6f940b44
5
5
  SHA512:
6
- metadata.gz: eca6412be33fb6b3408bbe74b2ba117aa8b441853add2df8e0011d7a87c35453f85de6fc17553b23132545e01ea2f2d1e36bb461cf9b2cd279ce5b43bb903de4
7
- data.tar.gz: 73c49509f7b70db22917d359517aace2fc6451dc419b51118e7ef0805ac77dff6b0c7448828d8292ed8f02bc0558d6a172a6e7d4c276e13a1bd56acec77173fd
6
+ metadata.gz: 144fd0983eb27be09f4ae709effaef4f74828426ccbfae80c739270b26ebefc42265c2a0f21fb6f9c2ef96a82b6d118a9b03f716baf4f99a5c59962d3846570b
7
+ data.tar.gz: ebcd732770f21a19b84baa6fff3bf9862ea5059e20592686b5cd01b19946f406e405e79005663d78b515d80b32911fce406e4931f037fc495955a5c4e521c1e1
@@ -1,4 +1,5 @@
1
1
  require 'releaf/test'
2
+ require 'releaf/rspec/matchers/have_number_of_resources'
2
3
  require 'releaf/rspec/matchers/match_html'
3
4
  require 'releaf/rspec/matchers/cache_instance_method'
4
5
  require 'releaf/rspec/helpers'
@@ -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?(*args)
16
- has_css?("#{primary_header_css_rule} h1", *args)
15
+ def has_header?(**args)
16
+ has_css?("#{primary_header_css_rule} h1", **args)
17
17
  end
18
18
 
19
- def has_no_header?(*args)
20
- has_no_css?("#{primary_header_css_rule} h1", *args)
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
@@ -54,7 +54,7 @@ module Releaf::Test
54
54
  end
55
55
 
56
56
  def create_resource
57
- click_link "Create new resource" unless first("form.new-resource")
57
+ click_link "Create new resource" unless first("form.new-resource", minimum: 0)
58
58
  within "form.new-resource" do
59
59
  yield
60
60
  end
@@ -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)').length
93
- number_of_localized_richtexts = page.all('.field.type-richtext.i18n .localization', visible: false).length
94
- number_of_richtexts = number_of_normal_richtexts + number_of_localized_richtexts
95
- if (number_of_richtexts > 0)
96
- expect(page).to have_css(".ckeditor-initialized", visible: false, count: number_of_richtexts)
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 save_and_check_response(status_text)
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
- click_button 'Save'
125
- expect(page).to have_css('body > .notifications .notification[data-id="resource_status"][data-type="success"]', text: status_text)
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,9 +226,9 @@ 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
- textarea = richtext_box.first(:field, locator, visible: false)
231
+ textarea = richtext_box.first(:field, locator, visible: false, minimum: 0)
212
232
  textareas << textarea if textarea.present?
213
233
  end
214
234
 
@@ -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
- within(".item[data-name=\"#{block_name}\"][data-index=\"#{expected_item_index}\"]") do
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
@@ -254,5 +280,13 @@ module Releaf::Test
254
280
  expect(page).to have_css(".item[data-name=\"#{block_name}\"][data-index=\"#{item_index}\"][style=\"opacity: 1; display: block;\"]")
255
281
  end
256
282
 
283
+ def download_file(url)
284
+ require "open-uri"
285
+ file = Tempfile.new
286
+ file.binmode
287
+ file.write(URI.open(url).read)
288
+ file.flush
289
+ file
290
+ end
257
291
  end
258
292
  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
@@ -1,3 +1,3 @@
1
1
  module Releaf
2
- VERSION = "1.1.21"
2
+ VERSION = "2.1.1"
3
3
  end
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: 1.1.21
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - CubeSystems
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-29 00:00:00.000000000 Z
11
+ date: 2021-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: releaf-core
@@ -16,58 +16,72 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 1.1.21
19
+ version: 2.1.1
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: 1.1.21
26
+ version: 2.1.1
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: 1.1.21
33
+ version: 2.1.1
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: 1.1.21
40
+ version: 2.1.1
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: 1.1.21
47
+ version: 2.1.1
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: 1.1.21
54
+ version: 2.1.1
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: 1.1.21
61
+ version: 2.1.1
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: 1.1.21
68
+ version: 2.1.1
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec-rails
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '4.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '4.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rails-controller-testing
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
87
  - - ">="
@@ -80,48 +94,62 @@ dependencies:
80
94
  - - ">="
81
95
  - !ruby/object:Gem::Version
82
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: listen
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.0'
83
111
  - !ruby/object:Gem::Dependency
84
112
  name: capybara
85
113
  requirement: !ruby/object:Gem::Requirement
86
114
  requirements:
87
- - - ">="
115
+ - - "~>"
88
116
  - !ruby/object:Gem::Version
89
- version: '0'
117
+ version: '3.0'
90
118
  type: :development
91
119
  prerelease: false
92
120
  version_requirements: !ruby/object:Gem::Requirement
93
121
  requirements:
94
- - - ">="
122
+ - - "~>"
95
123
  - !ruby/object:Gem::Version
96
- version: '0'
124
+ version: '3.0'
97
125
  - !ruby/object:Gem::Dependency
98
- name: poltergeist
126
+ name: selenium-webdriver
99
127
  requirement: !ruby/object:Gem::Requirement
100
128
  requirements:
101
- - - ">="
129
+ - - "~>"
102
130
  - !ruby/object:Gem::Version
103
- version: '0'
131
+ version: '3.0'
104
132
  type: :development
105
133
  prerelease: false
106
134
  version_requirements: !ruby/object:Gem::Requirement
107
135
  requirements:
108
- - - ">="
136
+ - - "~>"
109
137
  - !ruby/object:Gem::Version
110
- version: '0'
138
+ version: '3.0'
111
139
  - !ruby/object:Gem::Dependency
112
- name: factory_girl_rails
140
+ name: factory_bot
113
141
  requirement: !ruby/object:Gem::Requirement
114
142
  requirements:
115
- - - '='
143
+ - - "~>"
116
144
  - !ruby/object:Gem::Version
117
- version: 4.8.0
145
+ version: '5.2'
118
146
  type: :development
119
147
  prerelease: false
120
148
  version_requirements: !ruby/object:Gem::Requirement
121
149
  requirements:
122
- - - '='
150
+ - - "~>"
123
151
  - !ruby/object:Gem::Version
124
- version: 4.8.0
152
+ version: '5.2'
125
153
  - !ruby/object:Gem::Dependency
126
154
  name: syntax
127
155
  requirement: !ruby/object:Gem::Requirement
@@ -140,16 +168,16 @@ dependencies:
140
168
  name: simplecov
141
169
  requirement: !ruby/object:Gem::Requirement
142
170
  requirements:
143
- - - ">="
171
+ - - "~>"
144
172
  - !ruby/object:Gem::Version
145
- version: '0'
173
+ version: '0.16'
146
174
  type: :development
147
175
  prerelease: false
148
176
  version_requirements: !ruby/object:Gem::Requirement
149
177
  requirements:
150
- - - ">="
178
+ - - "~>"
151
179
  - !ruby/object:Gem::Version
152
- version: '0'
180
+ version: '0.16'
153
181
  - !ruby/object:Gem::Dependency
154
182
  name: simplecov-rcov
155
183
  requirement: !ruby/object:Gem::Requirement
@@ -168,30 +196,30 @@ dependencies:
168
196
  name: database_cleaner
169
197
  requirement: !ruby/object:Gem::Requirement
170
198
  requirements:
171
- - - ">="
199
+ - - "~>"
172
200
  - !ruby/object:Gem::Version
173
- version: '0'
201
+ version: '1.0'
174
202
  type: :development
175
203
  prerelease: false
176
204
  version_requirements: !ruby/object:Gem::Requirement
177
205
  requirements:
178
- - - ">="
206
+ - - "~>"
179
207
  - !ruby/object:Gem::Version
180
- version: '0'
208
+ version: '1.0'
181
209
  - !ruby/object:Gem::Dependency
182
210
  name: shoulda-matchers
183
211
  requirement: !ruby/object:Gem::Requirement
184
212
  requirements:
185
213
  - - "~>"
186
214
  - !ruby/object:Gem::Version
187
- version: '2.8'
215
+ version: '4.0'
188
216
  type: :development
189
217
  prerelease: false
190
218
  version_requirements: !ruby/object:Gem::Requirement
191
219
  requirements:
192
220
  - - "~>"
193
221
  - !ruby/object:Gem::Version
194
- version: '2.8'
222
+ version: '4.0'
195
223
  - !ruby/object:Gem::Dependency
196
224
  name: db-query-matchers
197
225
  requirement: !ruby/object:Gem::Requirement
@@ -210,16 +238,16 @@ dependencies:
210
238
  name: coveralls
211
239
  requirement: !ruby/object:Gem::Requirement
212
240
  requirements:
213
- - - ">="
241
+ - - "~>"
214
242
  - !ruby/object:Gem::Version
215
- version: '0'
243
+ version: '0.8'
216
244
  type: :development
217
245
  prerelease: false
218
246
  version_requirements: !ruby/object:Gem::Requirement
219
247
  requirements:
220
- - - ">="
248
+ - - "~>"
221
249
  - !ruby/object:Gem::Version
222
- version: '0'
250
+ version: '0.8'
223
251
  - !ruby/object:Gem::Dependency
224
252
  name: timecop
225
253
  requirement: !ruby/object:Gem::Requirement
@@ -238,16 +266,16 @@ dependencies:
238
266
  name: with_model
239
267
  requirement: !ruby/object:Gem::Requirement
240
268
  requirements:
241
- - - '='
269
+ - - "~>"
242
270
  - !ruby/object:Gem::Version
243
- version: 1.2.2
271
+ version: '2.0'
244
272
  type: :development
245
273
  prerelease: false
246
274
  version_requirements: !ruby/object:Gem::Requirement
247
275
  requirements:
248
- - - '='
276
+ - - "~>"
249
277
  - !ruby/object:Gem::Version
250
- version: 1.2.2
278
+ version: '2.0'
251
279
  - !ruby/object:Gem::Dependency
252
280
  name: pry
253
281
  requirement: !ruby/object:Gem::Requirement
@@ -263,7 +291,7 @@ dependencies:
263
291
  - !ruby/object:Gem::Version
264
292
  version: '0'
265
293
  - !ruby/object:Gem::Dependency
266
- name: pry-nav
294
+ name: roo
267
295
  requirement: !ruby/object:Gem::Requirement
268
296
  requirements:
269
297
  - - ">="
@@ -277,7 +305,7 @@ dependencies:
277
305
  - !ruby/object:Gem::Version
278
306
  version: '0'
279
307
  - !ruby/object:Gem::Dependency
280
- name: roo
308
+ name: puma
281
309
  requirement: !ruby/object:Gem::Requirement
282
310
  requirements:
283
311
  - - ">="
@@ -304,32 +332,15 @@ files:
304
332
  - lib/releaf/rspec/features_matchers.rb
305
333
  - lib/releaf/rspec/helpers.rb
306
334
  - lib/releaf/rspec/matchers/cache_instance_method.rb
335
+ - lib/releaf/rspec/matchers/have_number_of_resources.rb
307
336
  - lib/releaf/rspec/matchers/match_html.rb
308
337
  - lib/releaf/test.rb
309
338
  - lib/releaf/version.rb
310
- - spec/factories/author.rb
311
- - spec/factories/banner_page.rb
312
- - spec/factories/book.rb
313
- - spec/factories/chapter.rb
314
- - spec/factories/common.rb
315
- - spec/factories/home_page.rb
316
- - spec/factories/node.rb
317
- - spec/factories/node_route.rb
318
- - spec/factories/publisher.rb
319
- - spec/factories/role.rb
320
- - spec/factories/text_page.rb
321
- - spec/factories/user.rb
322
- - spec/rails_helper.rb
323
- - spec/spec_helper.rb
324
- - spec/support/controller_macros.rb
325
- - spec/support/excel_helpers.rb
326
- - spec/support/shared/service_includer.rb
327
- - spec/support/wait_steps.rb
328
339
  homepage: https://github.com/cubesystems/releaf
329
340
  licenses:
330
341
  - MIT
331
342
  metadata: {}
332
- post_install_message:
343
+ post_install_message:
333
344
  rdoc_options: []
334
345
  require_paths:
335
346
  - lib
@@ -337,33 +348,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
337
348
  requirements:
338
349
  - - ">="
339
350
  - !ruby/object:Gem::Version
340
- version: 2.2.0
351
+ version: 2.5.0
341
352
  required_rubygems_version: !ruby/object:Gem::Requirement
342
353
  requirements:
343
354
  - - ">="
344
355
  - !ruby/object:Gem::Version
345
356
  version: '0'
346
357
  requirements: []
347
- rubygems_version: 3.0.2
348
- signing_key:
358
+ rubygems_version: 3.2.6
359
+ signing_key:
349
360
  specification_version: 4
350
361
  summary: Administration interface for Ruby on Rails
351
- test_files:
352
- - spec/factories/node_route.rb
353
- - spec/factories/publisher.rb
354
- - spec/factories/node.rb
355
- - spec/factories/banner_page.rb
356
- - spec/factories/book.rb
357
- - spec/factories/common.rb
358
- - spec/factories/home_page.rb
359
- - spec/factories/author.rb
360
- - spec/factories/role.rb
361
- - spec/factories/text_page.rb
362
- - spec/factories/user.rb
363
- - spec/factories/chapter.rb
364
- - spec/support/wait_steps.rb
365
- - spec/support/controller_macros.rb
366
- - spec/support/excel_helpers.rb
367
- - spec/support/shared/service_includer.rb
368
- - spec/spec_helper.rb
369
- - spec/rails_helper.rb
362
+ test_files: []
@@ -1,6 +0,0 @@
1
- FactoryGirl.define do
2
- factory :author do
3
- name "Aleksandrs"
4
- surname "Lielais"
5
- end
6
- end
@@ -1,5 +0,0 @@
1
- FactoryGirl.define do
2
- factory :banner_page do
3
-
4
- end
5
- end
@@ -1,5 +0,0 @@
1
- FactoryGirl.define do
2
- factory :book do
3
- title "some book"
4
- end
5
- end
@@ -1,7 +0,0 @@
1
- FactoryGirl.define do
2
- factory :chapter do
3
- sequence(:title) { |n| "Chapter #{n}" }
4
- text 'Some awesome text for great test'
5
- sample_html '<strong>heavy</strong> words'
6
- end
7
- end
@@ -1,5 +0,0 @@
1
- FactoryGirl.define do
2
- sequence(:name) {|n| "name-#{n}" }
3
- sequence(:surname) {|n| "surname-#{n}" }
4
- sequence(:email) {|n| "email-#{n}@example.com" }
5
- end
@@ -1,5 +0,0 @@
1
- FactoryGirl.define do
2
- factory :home_page do
3
- text_html "xx duper"
4
- end
5
- end
@@ -1,50 +0,0 @@
1
- FactoryGirl.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
@@ -1,7 +0,0 @@
1
- FactoryGirl.define do
2
- factory :node_route, class: ::Releaf::Content::Route do
3
- sequence(:node_id) {|n| n}
4
- sequence(:path) {|n| "path-#{n}"}
5
- locale "en"
6
- end
7
- end
@@ -1,5 +0,0 @@
1
- FactoryGirl.define do
2
- factory :publisher do
3
- title "Good publisher"
4
- end
5
- end
@@ -1,21 +0,0 @@
1
- FactoryGirl.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
@@ -1,5 +0,0 @@
1
- FactoryGirl.define do
2
- factory :text_page do
3
- text_html "super duper"
4
- end
5
- end
@@ -1,22 +0,0 @@
1
- FactoryGirl.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
@@ -1,121 +0,0 @@
1
- require 'simplecov'
2
- require 'simplecov-rcov'
3
- require 'coveralls'
4
- require 'pry'
5
- require 'pry-nav'
6
- SimpleCov.command_name 'rspec'
7
-
8
- Coveralls.wear!('rails')
9
-
10
- if ENV["COVERAGE"]
11
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
12
- SimpleCov::Formatter::HTMLFormatter,
13
- SimpleCov::Formatter::RcovFormatter,
14
- Coveralls::SimpleCov::Formatter
15
- ])
16
- SimpleCov.start do
17
- add_filter '/lib/releaf/rspec'
18
- add_filter '/spec/'
19
- end
20
- end
21
-
22
- ENV["RAILS_ENV"] ||= 'test'
23
- require 'spec_helper'
24
- require File.expand_path("../dummy/config/environment.rb", __FILE__)
25
- require 'rspec/rails'
26
- require 'factory_girl'
27
- require "shoulda-matchers"
28
- require 'db-query-matchers'
29
- require 'capybara/poltergeist'
30
- require 'with_model'
31
- require 'timecop'
32
- require 'with_model'
33
- require 'database_cleaner'
34
- require 'releaf/rspec'
35
- require 'sass' # To stop these warnings: WARN: tilt autoloading 'sass' in a non thread-safe way; explicit require 'sass' suggested.
36
-
37
- Rails.backtrace_cleaner.remove_silencers!
38
- # Load support files
39
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
40
-
41
- # for devise testing
42
- include Warden::Test::Helpers
43
-
44
-
45
- Capybara.register_driver :poltergeist do |app|
46
- Capybara::Poltergeist::Driver.new(app, js_errors: true, inspector: true, phantomjs_logger: WarningSuppressor)
47
- end
48
-
49
- class WarningSuppressor
50
- IGNOREABLE = /CoreText performance|userSpaceScaleFactor/
51
-
52
- def write(message)
53
- if message =~ IGNOREABLE
54
- 0
55
- else
56
- puts(message)
57
- 1
58
- end
59
- end
60
- end
61
-
62
- RSpec.configure do |config|
63
- config.use_transactional_fixtures = false
64
- config.infer_base_class_for_anonymous_controllers = false
65
- config.order = "random"
66
- config.infer_spec_type_from_file_location!
67
-
68
- config.color = true
69
-
70
- if ENV['COVERAGE']
71
- config.add_formatter(:progress)
72
- end
73
-
74
- config.include Releaf::Test::Helpers
75
- config.include WaitSteps
76
- config.include ExcelHelpers
77
- config.extend WithModel
78
-
79
- config.include Rails.application.routes.url_helpers
80
-
81
- # DEVISE
82
- config.include Devise::Test::ControllerHelpers, type: :controller
83
- config.extend ControllerMacros, type: :controller
84
- config.include Devise::Test::ControllerHelpers, type: :helper
85
- config.extend ControllerMacros, type: :helper
86
-
87
-
88
- # FactoryGirl
89
- config.include FactoryGirl::Syntax::Methods
90
-
91
- Capybara.javascript_driver = :poltergeist
92
- Capybara.server = :webrick
93
-
94
- # disable empty translation creation
95
-
96
- config.before(:each) do |example|
97
- Rails.cache.clear
98
- allow( Releaf.application.config.i18n_database ).to receive(:translation_auto_creation).and_return(false)
99
-
100
- if example.metadata[:db_strategy]
101
- DatabaseCleaner.strategy = example.metadata[:db_strategy]
102
- elsif Capybara.current_driver == :rack_test
103
- DatabaseCleaner.strategy = :transaction
104
- else
105
- DatabaseCleaner.strategy = :truncation
106
- end
107
-
108
- DatabaseCleaner.start
109
- # set settings
110
- I18n.locale = Releaf.application.config.available_locales.first
111
- I18n.default_locale = Releaf.application.config.available_locales.first
112
- end
113
-
114
- config.after do
115
- Timecop.return
116
- DatabaseCleaner.clean
117
- Releaf::Test.reset!
118
- end
119
- end
120
-
121
- Dir["#{File.dirname(__FILE__)}/factories/*.rb"].each { |f| require f }
@@ -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,8 +0,0 @@
1
- module ControllerMacros
2
- def login_as_user factory
3
- before(:each) do
4
- @request.env["devise.mapping"] = Devise.mappings[:admin]
5
- sign_in FactoryGirl.create(factory) # Using factory girl as an example
6
- end
7
- end
8
- end
@@ -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 != actual_value
49
- @errors << {
50
- cell: "#{Roo::Base.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
@@ -1,9 +0,0 @@
1
- shared_examples "an Releaf::Service includer" do
2
- it "includes InternalUpdate module" do
3
- expect(described_class.included_modules).to include Releaf::Service
4
- end
5
-
6
- it "has instance #call method" do
7
- expect(subject.respond_to?(:call)).to be true
8
- end
9
- end
@@ -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