unchanged_validator 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.rspec +2 -0
- data/.travis.yml +9 -0
- data/Appraisals +19 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +101 -0
- data/Rakefile +2 -0
- data/config/locales/en.yml +4 -0
- data/gemfiles/rails_3.1.gemfile +7 -0
- data/gemfiles/rails_3.1.gemfile.lock +118 -0
- data/gemfiles/rails_3.2.gemfile +7 -0
- data/gemfiles/rails_3.2.gemfile.lock +114 -0
- data/gemfiles/rails_4.0.gemfile +7 -0
- data/gemfiles/rails_4.0.gemfile.lock +107 -0
- data/gemfiles/rails_4.1.gemfile +7 -0
- data/gemfiles/rails_4.1.gemfile.lock +113 -0
- data/gemfiles/rails_4.2.gemfile +7 -0
- data/gemfiles/rails_4.2.gemfile.lock +133 -0
- data/lib/active_model/validations/unchanged_validator.rb +35 -0
- data/lib/unchanged_validator/engine.rb +5 -0
- data/lib/unchanged_validator/version.rb +3 -0
- data/lib/unchanged_validator.rb +7 -0
- data/spec/active_model/validations/helper_methods_spec.rb +152 -0
- data/spec/active_model/validations/unchanged_validator_spec.rb +56 -0
- data/spec/spec_helper.rb +97 -0
- data/unchanged_validator.gemspec +27 -0
- metadata +160 -0
@@ -0,0 +1,133 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ../
|
3
|
+
specs:
|
4
|
+
unchanged_validator (0.0.1)
|
5
|
+
activemodel (>= 3.1)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
actionmailer (4.2.0)
|
11
|
+
actionpack (= 4.2.0)
|
12
|
+
actionview (= 4.2.0)
|
13
|
+
activejob (= 4.2.0)
|
14
|
+
mail (~> 2.5, >= 2.5.4)
|
15
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
16
|
+
actionpack (4.2.0)
|
17
|
+
actionview (= 4.2.0)
|
18
|
+
activesupport (= 4.2.0)
|
19
|
+
rack (~> 1.6.0)
|
20
|
+
rack-test (~> 0.6.2)
|
21
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
22
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.1)
|
23
|
+
actionview (4.2.0)
|
24
|
+
activesupport (= 4.2.0)
|
25
|
+
builder (~> 3.1)
|
26
|
+
erubis (~> 2.7.0)
|
27
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
28
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.1)
|
29
|
+
activejob (4.2.0)
|
30
|
+
activesupport (= 4.2.0)
|
31
|
+
globalid (>= 0.3.0)
|
32
|
+
activemodel (4.2.0)
|
33
|
+
activesupport (= 4.2.0)
|
34
|
+
builder (~> 3.1)
|
35
|
+
activerecord (4.2.0)
|
36
|
+
activemodel (= 4.2.0)
|
37
|
+
activesupport (= 4.2.0)
|
38
|
+
arel (~> 6.0)
|
39
|
+
activesupport (4.2.0)
|
40
|
+
i18n (~> 0.7)
|
41
|
+
json (~> 1.7, >= 1.7.7)
|
42
|
+
minitest (~> 5.1)
|
43
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
44
|
+
tzinfo (~> 1.1)
|
45
|
+
appraisal (1.0.2)
|
46
|
+
bundler
|
47
|
+
rake
|
48
|
+
thor (>= 0.14.0)
|
49
|
+
arel (6.0.0)
|
50
|
+
builder (3.2.2)
|
51
|
+
diff-lcs (1.2.5)
|
52
|
+
erubis (2.7.0)
|
53
|
+
globalid (0.3.0)
|
54
|
+
activesupport (>= 4.1.0)
|
55
|
+
hike (1.2.3)
|
56
|
+
i18n (0.7.0)
|
57
|
+
json (1.8.1)
|
58
|
+
loofah (2.0.1)
|
59
|
+
nokogiri (>= 1.5.9)
|
60
|
+
mail (2.6.3)
|
61
|
+
mime-types (>= 1.16, < 3)
|
62
|
+
mime-types (2.4.3)
|
63
|
+
mini_portile (0.6.1)
|
64
|
+
minitest (5.5.0)
|
65
|
+
multi_json (1.10.1)
|
66
|
+
nokogiri (1.6.5)
|
67
|
+
mini_portile (~> 0.6.0)
|
68
|
+
rack (1.6.0)
|
69
|
+
rack-test (0.6.2)
|
70
|
+
rack (>= 1.0)
|
71
|
+
rails (4.2.0)
|
72
|
+
actionmailer (= 4.2.0)
|
73
|
+
actionpack (= 4.2.0)
|
74
|
+
actionview (= 4.2.0)
|
75
|
+
activejob (= 4.2.0)
|
76
|
+
activemodel (= 4.2.0)
|
77
|
+
activerecord (= 4.2.0)
|
78
|
+
activesupport (= 4.2.0)
|
79
|
+
bundler (>= 1.3.0, < 2.0)
|
80
|
+
railties (= 4.2.0)
|
81
|
+
sprockets-rails
|
82
|
+
rails-deprecated_sanitizer (1.0.3)
|
83
|
+
activesupport (>= 4.2.0.alpha)
|
84
|
+
rails-dom-testing (1.0.5)
|
85
|
+
activesupport (>= 4.2.0.beta, < 5.0)
|
86
|
+
nokogiri (~> 1.6.0)
|
87
|
+
rails-deprecated_sanitizer (>= 1.0.1)
|
88
|
+
rails-html-sanitizer (1.0.1)
|
89
|
+
loofah (~> 2.0)
|
90
|
+
railties (4.2.0)
|
91
|
+
actionpack (= 4.2.0)
|
92
|
+
activesupport (= 4.2.0)
|
93
|
+
rake (>= 0.8.7)
|
94
|
+
thor (>= 0.18.1, < 2.0)
|
95
|
+
rake (10.4.2)
|
96
|
+
rspec (3.1.0)
|
97
|
+
rspec-core (~> 3.1.0)
|
98
|
+
rspec-expectations (~> 3.1.0)
|
99
|
+
rspec-mocks (~> 3.1.0)
|
100
|
+
rspec-core (3.1.7)
|
101
|
+
rspec-support (~> 3.1.0)
|
102
|
+
rspec-expectations (3.1.2)
|
103
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
104
|
+
rspec-support (~> 3.1.0)
|
105
|
+
rspec-mocks (3.1.3)
|
106
|
+
rspec-support (~> 3.1.0)
|
107
|
+
rspec-support (3.1.2)
|
108
|
+
sprockets (2.12.3)
|
109
|
+
hike (~> 1.2)
|
110
|
+
multi_json (~> 1.0)
|
111
|
+
rack (~> 1.0)
|
112
|
+
tilt (~> 1.1, != 1.3.0)
|
113
|
+
sprockets-rails (2.2.2)
|
114
|
+
actionpack (>= 3.0)
|
115
|
+
activesupport (>= 3.0)
|
116
|
+
sprockets (>= 2.8, < 4.0)
|
117
|
+
thor (0.19.1)
|
118
|
+
thread_safe (0.3.4)
|
119
|
+
tilt (1.4.1)
|
120
|
+
tzinfo (1.2.2)
|
121
|
+
thread_safe (~> 0.1)
|
122
|
+
|
123
|
+
PLATFORMS
|
124
|
+
ruby
|
125
|
+
|
126
|
+
DEPENDENCIES
|
127
|
+
activesupport (>= 3.1)
|
128
|
+
appraisal (~> 1.0)
|
129
|
+
bundler (~> 1.6)
|
130
|
+
rails (= 4.2.0)
|
131
|
+
rake (~> 10.0)
|
132
|
+
rspec (~> 3.1)
|
133
|
+
unchanged_validator!
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'active_model/validations'
|
2
|
+
|
3
|
+
module ActiveModel
|
4
|
+
module Validations
|
5
|
+
# == Active Model Unchanged Validator
|
6
|
+
class UnchangedValidator < EachValidator #:nodoc:
|
7
|
+
def validate_each(record, attr_name, value)#
|
8
|
+
if !record.new_record? && record.send(:"#{attr_name}_changed?")
|
9
|
+
record.errors.add(attr_name, :changed, options)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
module HelperMethods
|
15
|
+
# Validates that the specified attributes are unchanged (unless the record is new).
|
16
|
+
# Happens by default on save.
|
17
|
+
#
|
18
|
+
# class Person < ActiveRecord::Base
|
19
|
+
# validates_unchanged :first_name
|
20
|
+
# end
|
21
|
+
#
|
22
|
+
# The first_name attribute must be in the object and it must not have changed.
|
23
|
+
#
|
24
|
+
# Configuration options:
|
25
|
+
# * <tt>:message</tt> - A custom error message (default is: "must not change").
|
26
|
+
#
|
27
|
+
# There is also a list of default options supported by every validator:
|
28
|
+
# +:if+, +:unless+, +:on+, +:allow_nil+, +:allow_blank+, and +:strict+.
|
29
|
+
# See <tt>ActiveModel::Validation#validates</tt> for more information
|
30
|
+
def validates_unchanged(*attr_names)
|
31
|
+
validates_with UnchangedValidator, _merge_attributes(attr_names)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,152 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ActiveModel::Validations::HelperMethods do
|
4
|
+
class Person
|
5
|
+
include ActiveModel::Dirty
|
6
|
+
include ActiveModel::Validations
|
7
|
+
|
8
|
+
define_attribute_methods [:name]
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@name = nil
|
12
|
+
@new_record = true
|
13
|
+
end
|
14
|
+
|
15
|
+
def name
|
16
|
+
@name
|
17
|
+
end
|
18
|
+
|
19
|
+
def name=(val)
|
20
|
+
name_will_change! unless val == @name
|
21
|
+
@name = val
|
22
|
+
end
|
23
|
+
|
24
|
+
def save
|
25
|
+
changes_applied
|
26
|
+
@new_record = false
|
27
|
+
end
|
28
|
+
|
29
|
+
def reload
|
30
|
+
clear_changes_information
|
31
|
+
end
|
32
|
+
|
33
|
+
def deprecated_reload
|
34
|
+
reset_changes
|
35
|
+
end
|
36
|
+
|
37
|
+
def new_record?
|
38
|
+
@new_record
|
39
|
+
end
|
40
|
+
|
41
|
+
def changes_applied
|
42
|
+
@previously_changed = changes
|
43
|
+
@changed_attributes = ActiveSupport::HashWithIndifferentAccess.new
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '.validates_unchanged' do
|
48
|
+
let(:attribute) { :name }
|
49
|
+
let(:options) { {} }
|
50
|
+
let(:previous_value) { 'Dave' }
|
51
|
+
let(:new_value) { 'Bob' }
|
52
|
+
|
53
|
+
before do
|
54
|
+
Person.reset_callbacks(:validate)
|
55
|
+
Person.validates_unchanged(attribute, options)
|
56
|
+
end
|
57
|
+
|
58
|
+
context 'when the record is' do
|
59
|
+
context 'new' do
|
60
|
+
let(:record) { Person.new }
|
61
|
+
|
62
|
+
context 'and the attribute has' do
|
63
|
+
context 'been set' do
|
64
|
+
|
65
|
+
it 'does not add an error' do
|
66
|
+
record.name = new_value
|
67
|
+
expect(record).to be_valid
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
context 'not been set' do
|
72
|
+
|
73
|
+
it 'does not add an error' do
|
74
|
+
expect(record).to be_valid
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
context 'not new' do
|
80
|
+
let(:record) do
|
81
|
+
p = Person.new
|
82
|
+
p.name = previous_value
|
83
|
+
p.save
|
84
|
+
p
|
85
|
+
end
|
86
|
+
|
87
|
+
context 'and the attribute has' do
|
88
|
+
context 'been set to' do
|
89
|
+
context 'the same value' do
|
90
|
+
|
91
|
+
it 'does not add an error' do
|
92
|
+
record.name = record.name
|
93
|
+
expect(record).to be_valid
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
context 'a different value' do
|
98
|
+
|
99
|
+
it 'adds an error' do
|
100
|
+
record.name = new_value
|
101
|
+
expect(record).not_to be_valid
|
102
|
+
expect(record.errors[:name]).to eq ['must not change']
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
context 'when the option' do
|
108
|
+
context 'allow_blank is true' do
|
109
|
+
let(:options) { { allow_blank: true } }
|
110
|
+
|
111
|
+
context 'and the attribute was not blank and the new value is blank' do
|
112
|
+
let(:new_value) { '' }
|
113
|
+
|
114
|
+
it 'does not add an error' do
|
115
|
+
record.name = new_value
|
116
|
+
expect(record).to be_valid
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
context 'allow_nil is true' do
|
122
|
+
let(:options) { { allow_nil: true } }
|
123
|
+
|
124
|
+
context 'and the attribute was not nil and the new value is nil' do
|
125
|
+
let(:new_value) { nil }
|
126
|
+
|
127
|
+
it 'does not add an error' do
|
128
|
+
record.name = new_value
|
129
|
+
expect(record).to be_valid
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
context 'message has been specified' do
|
136
|
+
let(:message) { 'should not change' }
|
137
|
+
let(:options) { { message: message } }
|
138
|
+
|
139
|
+
context 'when an error is added' do
|
140
|
+
it 'gives specified message' do
|
141
|
+
record.name = new_value
|
142
|
+
expect(record).not_to be_valid
|
143
|
+
expect(record.errors[:name]).to eq [message]
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ActiveModel::Validations::UnchangedValidator do
|
4
|
+
describe '#validate_each' do
|
5
|
+
let(:record) { double('Model') }
|
6
|
+
let(:record_is_new) { false }
|
7
|
+
let(:record_attribute) { :attribute }
|
8
|
+
let(:record_attribute_has_changed) { false }
|
9
|
+
let(:record_errors) { double('errors') }
|
10
|
+
let(:options) { { attributes: record_attribute, a: 1, b: 2} }
|
11
|
+
let(:validator) { ActiveModel::Validations::UnchangedValidator.new(options) }
|
12
|
+
let(:value) { 'something' }
|
13
|
+
|
14
|
+
before do
|
15
|
+
allow(record).to receive(:new_record?).and_return(record_is_new)
|
16
|
+
allow(record).to receive(:"#{record_attribute}_changed?").and_return(record_attribute_has_changed)
|
17
|
+
allow(record).to receive(:errors).and_return(record_errors)
|
18
|
+
allow(record_errors).to receive(:add).with(record_attribute, :changed, options.reject { |k| k == :attributes} )
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'when the record is' do
|
22
|
+
context 'new' do
|
23
|
+
let(:record_is_new) { true }
|
24
|
+
|
25
|
+
it 'does not add an error' do
|
26
|
+
validator.validate_each(record, record_attribute, value)
|
27
|
+
expect(record_errors).not_to have_received(:add)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'not new' do
|
32
|
+
let(:record_is_new) { false }
|
33
|
+
|
34
|
+
context 'and the attribute has' do
|
35
|
+
context 'changed' do
|
36
|
+
let(:record_attribute_has_changed) { true }
|
37
|
+
|
38
|
+
it 'adds and error' do
|
39
|
+
validator.validate_each(record, record_attribute, value)
|
40
|
+
expect(record_errors).to have_received(:add)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'not changed' do
|
45
|
+
let(:record_attribute_has_changed) { false }
|
46
|
+
|
47
|
+
it 'adds and error' do
|
48
|
+
validator.validate_each(record, record_attribute, value)
|
49
|
+
expect(record_errors).not_to have_received(:add)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
# This file was generated by the `rspec --init` 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
|
+
|
18
|
+
require 'active_support'
|
19
|
+
|
20
|
+
require 'active_model'
|
21
|
+
require 'unchanged_validator'
|
22
|
+
|
23
|
+
I18n.load_path += Dir[File.expand_path(File.join(File.dirname(__FILE__), '../config/locales', '*.yml')).to_s]
|
24
|
+
|
25
|
+
RSpec.configure do |config|
|
26
|
+
# rspec-expectations config goes here. You can use an alternate
|
27
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
28
|
+
# assertions if you prefer.
|
29
|
+
config.expect_with :rspec do |expectations|
|
30
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
31
|
+
# and `failure_message` of custom matchers include text for helper methods
|
32
|
+
# defined using `chain`, e.g.:
|
33
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
34
|
+
# # => "be bigger than 2 and smaller than 4"
|
35
|
+
# ...rather than:
|
36
|
+
# # => "be bigger than 2"
|
37
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
38
|
+
end
|
39
|
+
|
40
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
41
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
42
|
+
config.mock_with :rspec do |mocks|
|
43
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
44
|
+
# a real object. This is generally recommended, and will default to
|
45
|
+
# `true` in RSpec 4.
|
46
|
+
mocks.verify_partial_doubles = true
|
47
|
+
end
|
48
|
+
|
49
|
+
# The settings below are suggested to provide a good initial experience
|
50
|
+
# with RSpec, but feel free to customize to your heart's content.
|
51
|
+
=begin
|
52
|
+
# These two settings work together to allow you to limit a spec run
|
53
|
+
# to individual examples or groups you care about by tagging them with
|
54
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
55
|
+
# get run.
|
56
|
+
config.filter_run :focus
|
57
|
+
config.run_all_when_everything_filtered = true
|
58
|
+
|
59
|
+
# Limits the available syntax to the non-monkey patched syntax that is recommended.
|
60
|
+
# For more details, see:
|
61
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
62
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
63
|
+
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
64
|
+
config.disable_monkey_patching!
|
65
|
+
|
66
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
67
|
+
# be too noisy due to issues in dependencies.
|
68
|
+
config.warnings = true
|
69
|
+
|
70
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
71
|
+
# file, and it's useful to allow more verbose output when running an
|
72
|
+
# individual spec file.
|
73
|
+
if config.files_to_run.one?
|
74
|
+
# Use the documentation formatter for detailed output,
|
75
|
+
# unless a formatter has already been configured
|
76
|
+
# (e.g. via a command-line flag).
|
77
|
+
config.default_formatter = 'doc'
|
78
|
+
end
|
79
|
+
|
80
|
+
# Print the 10 slowest examples and example groups at the
|
81
|
+
# end of the spec run, to help surface which specs are running
|
82
|
+
# particularly slow.
|
83
|
+
config.profile_examples = 10
|
84
|
+
|
85
|
+
# Run specs in random order to surface order dependencies. If you find an
|
86
|
+
# order dependency and want to debug it, you can fix the order by providing
|
87
|
+
# the seed, which is printed after each run.
|
88
|
+
# --seed 1234
|
89
|
+
config.order = :random
|
90
|
+
|
91
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
92
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
93
|
+
# test failures related to randomization by passing the same `--seed` value
|
94
|
+
# as the one that triggered the failure.
|
95
|
+
Kernel.srand config.seed
|
96
|
+
=end
|
97
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'unchanged_validator/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "unchanged_validator"
|
8
|
+
spec.version = UnchangedValidator::VERSION
|
9
|
+
spec.authors = ["Peter Marsh"]
|
10
|
+
spec.email = ["pete.d.marsh@gmail.com"]
|
11
|
+
spec.summary = "A validator for ActiveModels that checks that attributes have not been modified since the last time the model was saved."
|
12
|
+
spec.homepage = ""
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["config", "lib"]
|
19
|
+
|
20
|
+
spec.add_runtime_dependency "activemodel", ">= 3.1"
|
21
|
+
|
22
|
+
spec.add_development_dependency "activesupport", ">= 3.1"
|
23
|
+
spec.add_development_dependency "appraisal", "~> 1.0"
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.1"
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: unchanged_validator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Peter Marsh
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-31 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activemodel
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activesupport
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.1'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: appraisal
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.6'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.6'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.1'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.1'
|
97
|
+
description:
|
98
|
+
email:
|
99
|
+
- pete.d.marsh@gmail.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- .gitignore
|
105
|
+
- .rspec
|
106
|
+
- .travis.yml
|
107
|
+
- Appraisals
|
108
|
+
- Gemfile
|
109
|
+
- LICENSE.txt
|
110
|
+
- README.md
|
111
|
+
- Rakefile
|
112
|
+
- config/locales/en.yml
|
113
|
+
- gemfiles/rails_3.1.gemfile
|
114
|
+
- gemfiles/rails_3.1.gemfile.lock
|
115
|
+
- gemfiles/rails_3.2.gemfile
|
116
|
+
- gemfiles/rails_3.2.gemfile.lock
|
117
|
+
- gemfiles/rails_4.0.gemfile
|
118
|
+
- gemfiles/rails_4.0.gemfile.lock
|
119
|
+
- gemfiles/rails_4.1.gemfile
|
120
|
+
- gemfiles/rails_4.1.gemfile.lock
|
121
|
+
- gemfiles/rails_4.2.gemfile
|
122
|
+
- gemfiles/rails_4.2.gemfile.lock
|
123
|
+
- lib/active_model/validations/unchanged_validator.rb
|
124
|
+
- lib/unchanged_validator.rb
|
125
|
+
- lib/unchanged_validator/engine.rb
|
126
|
+
- lib/unchanged_validator/version.rb
|
127
|
+
- spec/active_model/validations/helper_methods_spec.rb
|
128
|
+
- spec/active_model/validations/unchanged_validator_spec.rb
|
129
|
+
- spec/spec_helper.rb
|
130
|
+
- unchanged_validator.gemspec
|
131
|
+
homepage: ''
|
132
|
+
licenses:
|
133
|
+
- MIT
|
134
|
+
metadata: {}
|
135
|
+
post_install_message:
|
136
|
+
rdoc_options: []
|
137
|
+
require_paths:
|
138
|
+
- config
|
139
|
+
- lib
|
140
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - '>='
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
requirements: []
|
151
|
+
rubyforge_project:
|
152
|
+
rubygems_version: 2.2.2
|
153
|
+
signing_key:
|
154
|
+
specification_version: 4
|
155
|
+
summary: A validator for ActiveModels that checks that attributes have not been modified
|
156
|
+
since the last time the model was saved.
|
157
|
+
test_files:
|
158
|
+
- spec/active_model/validations/helper_methods_spec.rb
|
159
|
+
- spec/active_model/validations/unchanged_validator_spec.rb
|
160
|
+
- spec/spec_helper.rb
|