incline 0.3.4 → 0.3.5

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
  SHA1:
3
- metadata.gz: 9d96e55810baf0d915bdb874534070120851caf9
4
- data.tar.gz: ec16f41a12046871cbd1b3e0f286774656c6070a
3
+ metadata.gz: a9f80a4684c30ac694722071ae774bf990844c5c
4
+ data.tar.gz: 840e9f021e47c41512ac3e956acf19f6cfec1fe4
5
5
  SHA512:
6
- metadata.gz: ee7a85e95e74cfef19053c895f0cc98e74ff839dd680674cac1988d3e502490463dbd919524cace694abba225a10ee89865c77ba4b5c09be10af4e2272db97cc
7
- data.tar.gz: 7be4972faad9c4cac1394d0df507005b9fd6b1f5c437edab00165cef01ba30073187e381d8f8b200b20437ae263efac1e98ff0fac8c9ab2cb0fd487ffe106a53
6
+ metadata.gz: c7da4a8f9c25f06e661f087da00f7e573315ecf8d9f59f3a96ef569602e463c4ad9a92e19a59065550b3fecadd282337b29a686544ed679686af4f304addeb36
7
+ data.tar.gz: 12690886ff01de202d58b6614881e89d1570b635566b68e0493ecfe2daed03a9769b22269dbe649f8cb9c387fa9d85200795bb61182e2d5eba642440c4c51fbf
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- incline (0.3.4)
4
+ incline (0.3.5)
5
5
  ansi (~> 1.5.0)
6
6
  bcrypt
7
7
  bootstrap-sass
@@ -83,7 +83,7 @@ GEM
83
83
  execjs (2.7.0)
84
84
  faker (1.7.3)
85
85
  i18n (~> 0.5)
86
- ffi (1.9.21)
86
+ ffi (1.9.22)
87
87
  globalid (0.4.1)
88
88
  activesupport (>= 4.2.0)
89
89
  i18n (0.9.3)
@@ -220,13 +220,13 @@ module Incline::Extensions
220
220
  def main_app
221
221
  Rails.application.class.routes.url_helpers
222
222
  end
223
-
223
+
224
224
  ##
225
225
  # Make sure incline is available and working correctly in tests.
226
226
  def incline
227
227
  Incline::Engine.routes.url_helpers
228
228
  end
229
-
229
+
230
230
  ##
231
231
  # Determines if a user is logged into the test session
232
232
  def is_logged_in?
@@ -425,6 +425,9 @@ module Incline::Extensions
425
425
  # values, the model should once again be valid.
426
426
  # The alternative scopes are processed one at a time and the original values are restored
427
427
  # before moving onto the next scope.
428
+ # A special key :unique_fields, allows you to provide values for other unique fields in the model so they
429
+ # don't affect testing. If the value of :unique_fields is not a hash, then it is put back into the
430
+ # alternate_scopes hash for testing.
428
431
  #
429
432
  def assert_uniqueness(model, attribute, case_sensitive = false, message = nil, regex = /has already been taken/i, alternate_scopes = {})
430
433
  setter = :"#{attribute}="
@@ -448,6 +451,18 @@ module Incline::Extensions
448
451
  model.save!
449
452
  copy = model.dup
450
453
 
454
+ other_unique_fields = alternate_scopes.delete(:unique_fields)
455
+ if other_unique_fields
456
+ if other_unique_fields.is_a?(::Hash)
457
+ other_unique_fields.each do |attr,val|
458
+ setter = :"#{attr}="
459
+ copy.send setter, val
460
+ end
461
+ else
462
+ alternate_scopes[:unique_fields] = other_unique_fields
463
+ end
464
+ end
465
+
451
466
  assert_not copy.valid?, message ? (message + ": (#{copy.send(attribute).inspect})") : "Duplicate model with #{attribute}=#{copy.send(attribute).inspect} should not be valid."
452
467
  assert copy.errors[attribute].to_s =~ regex, message ? (message + ': (error message)') : "Did not fail for expected reason"
453
468
  if original_value.is_a?(::String)
@@ -1,3 +1,3 @@
1
1
  module Incline
2
- VERSION = "0.3.4"
2
+ VERSION = "0.3.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: incline
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Beau Barker
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-02-19 00:00:00.000000000 Z
11
+ date: 2018-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -610,7 +610,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
610
610
  version: '0'
611
611
  requirements: []
612
612
  rubyforge_project:
613
- rubygems_version: 2.6.13
613
+ rubygems_version: 2.6.11
614
614
  signing_key:
615
615
  specification_version: 4
616
616
  summary: A gem designed to get off to an even quicker start with Rails.