Skip to content

Commit

Permalink
bump gems and remove one crazy shoulda-matchers monkeypatch
Browse files Browse the repository at this point in the history
thoughtbot/shoulda-matchers#784 fixes the issues with
validate_numericality_of, though validate_uniqueness_of still
fails without some intense hinting about what values are
allowed for user_type
  • Loading branch information
tjgrathwell authored and scottyschup committed Mar 26, 2016
1 parent f56c7ea commit 554a84b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 37 deletions.
28 changes: 14 additions & 14 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,10 @@ GEM
autoprefixer-rails (>= 5.0.0.1)
sass (>= 3.3.0)
builder (3.2.2)
bullet (4.14.7)
bullet (4.14.10)
activesupport (>= 3.0.0)
uniform_notifier (~> 1.9.0)
byebug (5.0.0)
columnize (= 0.9.0)
byebug (6.0.2)
capybara (2.5.0)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
Expand All @@ -84,7 +83,6 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.9.1.1)
columnize (0.9.0)
crack (0.4.2)
safe_yaml (~> 1.0.0)
crass (1.0.2)
Expand Down Expand Up @@ -117,7 +115,7 @@ GEM
railties (>= 3.0.0)
faker (1.5.0)
i18n (~> 0.5)
faraday (0.9.1)
faraday (0.9.2)
multipart-post (>= 1.2, < 3)
font-awesome-rails (4.4.0.0)
railties (>= 3.2, < 5.0)
Expand All @@ -131,7 +129,8 @@ GEM
multi_json (~> 1.0)
sprockets (>= 2.0.0, < 4.0)
tilt (~> 1.2)
hashie (3.4.2)
hashdiff (0.2.2)
hashie (3.4.3)
heroku-api (0.3.23)
excon (~> 0.44)
multi_json (~> 1.8)
Expand Down Expand Up @@ -170,12 +169,12 @@ GEM
railties
mime-types (2.6.2)
mini_portile (0.6.2)
minitest (5.8.1)
minitest (5.8.2)
multi_json (1.11.2)
multi_xml (0.5.5)
multipart-post (2.0.0)
nested_form (0.3.2)
newrelic_rpm (3.13.2.302)
newrelic_rpm (3.14.0.305)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
nokogumbo (1.4.1)
Expand All @@ -201,7 +200,7 @@ GEM
omniauth-oauth (1.1.0)
oauth
omniauth (~> 1.0)
omniauth-oauth2 (1.3.1)
omniauth-oauth2 (1.4.0)
oauth2 (~> 1.0)
omniauth (~> 1.2)
omniauth-twitter (1.2.1)
Expand Down Expand Up @@ -289,7 +288,7 @@ GEM
crass (~> 1.0.2)
nokogiri (>= 1.4.4)
nokogumbo (= 1.4.1)
sass (3.4.18)
sass (3.4.19)
sass-rails (5.0.4)
railties (>= 4.0.0, < 5.0)
sass (~> 3.1)
Expand All @@ -298,18 +297,18 @@ GEM
tilt (>= 1.1, < 3)
sentry-raven (0.15.2)
faraday (>= 0.7.6)
shoulda-matchers (3.0.0)
shoulda-matchers (3.0.1)
activesupport (>= 4.0.0)
simple_form (3.2.0)
actionpack (~> 4.0)
activemodel (~> 4.0)
sprockets (3.3.5)
sprockets (3.4.0)
rack (> 1, < 3)
sprockets-rails (2.3.3)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
sqlite3 (1.3.10)
sqlite3 (1.3.11)
test_after_commit (0.4.1)
activerecord (>= 3.2)
thor (0.19.1)
Expand All @@ -323,9 +322,10 @@ GEM
uniform_notifier (1.9.0)
warden (1.2.3)
rack (>= 1.0)
webmock (1.21.0)
webmock (1.22.1)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff
websocket-driver (0.6.2)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2)
Expand Down
4 changes: 2 additions & 2 deletions app/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ class Event < ActiveRecord::Base

with_options(unless: :historical?) do |normal_event|
normal_event.with_options(if: :allow_student_rsvp?) do |workshop_event|
workshop_event.validates_numericality_of :student_rsvp_limit, only_integer: true, greater_than: 0
workshop_event.validates_numericality_of :student_rsvp_limit, greater_than: 0
workshop_event.validate :validate_student_rsvp_limit
end

with_options(if: :has_volunteer_limit?) do |workshop_event|
workshop_event.validates_numericality_of :volunteer_rsvp_limit, only_integer: true, greater_than: 0
workshop_event.validates_numericality_of :volunteer_rsvp_limit, greater_than: 0
workshop_event.validate :validate_volunteer_rsvp_limit
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/models/event_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
it { is_expected.to belong_to(:location) }
it { is_expected.to have_many(:rsvps) }
it { is_expected.to have_many(:event_sessions) }
it { is_expected.to validate_numericality_of(:student_rsvp_limit) }
it { is_expected.to validate_numericality_of(:volunteer_rsvp_limit) }
it { is_expected.to validate_numericality_of(:student_rsvp_limit).is_greater_than(0) }
it { is_expected.to validate_numericality_of(:volunteer_rsvp_limit).is_greater_than(0) }
it { is_expected.to validate_presence_of(:title) }

describe "validation of target_audience" do
Expand Down
19 changes: 0 additions & 19 deletions spec/support/shoulda_matchers_monkeypatch.rb
Original file line number Diff line number Diff line change
@@ -1,22 +1,3 @@
module Shoulda
module Matchers
module ActiveModel
class ValidateNumericalityOfMatcher
def add_disallow_value_matcher
disallow_value_matcher = DisallowValueMatcher.new(NON_NUMERIC_VALUE).
for(@attribute).
with_message(:not_a_number)
disallow_value_matcher
.instance_variable_get(:@allow_matcher)
.ignoring_interference_by_writer

add_submatcher(disallow_value_matcher)
end
end
end
end
end

module Shoulda
module Matchers
module ActiveRecord
Expand Down

0 comments on commit 554a84b

Please sign in to comment.