html5_validators 1.5.0 → 1.7.0

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: e661f883c54a76d6b77c4bfe4693d56a79292d04
4
- data.tar.gz: d3eb675e09dbd2bcf4dacd142ac719f4c036f85b
3
+ metadata.gz: f42582a45b426a624233abfd0c846d2b4253c09c
4
+ data.tar.gz: f699d9d08608826ea5f7926dc55a0047e1a1866b
5
5
  SHA512:
6
- metadata.gz: 2e8e247612a555fcb2d48bbda8ec5780afc0fc04fdef16cc2c465bbc57e599a408a92cfa6597ffee50c689b45a5eeeb35ca272a559c8c444eeaf3dd5ec95c5aa
7
- data.tar.gz: b7826041634d9996bf8616c1998de4072b6bfcb90894725b864bd22e555961ae4a160a39433725dde957ea8c2aa3751c80a1829b14e06daca0d94f5babf7bda6
6
+ metadata.gz: 390f53c7bd1726de0d717495680841bf7174612a2a46d2b5f0cc7a091c24195966649172c0e1dd7c51173c3cd8757e54cab5e101033e9e189b31291c16562d1e
7
+ data.tar.gz: 3063081e6158297715a1a1de5efdfa6dc32dfda33adfbf267c66847956ca975b43fbec6ed1f243e75b6ceb08e5cb01e60d5655b074a518ba6aeba5c9c5e804c5
data/.travis.yml CHANGED
@@ -3,8 +3,9 @@ language: ruby
3
3
  rvm:
4
4
  - 2.0.0
5
5
  - 2.1.10
6
- - 2.2.6
7
- - 2.3.3
6
+ - 2.2.7
7
+ - 2.3.4
8
+ - 2.4.1
8
9
  - ruby-head
9
10
 
10
11
  gemfile:
@@ -27,11 +28,25 @@ matrix:
27
28
  gemfile: gemfiles/Gemfile.rails-edge
28
29
  - rvm: 2.1.10
29
30
  gemfile: gemfiles/Gemfile.rails-edge
30
- - rvm: 2.2.6
31
+ - rvm: 2.2.7
31
32
  gemfile: gemfiles/Gemfile.rails-3.2
32
- - rvm: 2.3.3
33
+ - rvm: 2.3.4
33
34
  gemfile: gemfiles/Gemfile.rails-3.2
35
+ - rvm: 2.4.1
36
+ gemfile: gemfiles/Gemfile.rails-3.2
37
+ - rvm: 2.4.1
38
+ gemfile: gemfiles/Gemfile.rails-4.0
39
+ - rvm: 2.4.1
40
+ gemfile: gemfiles/Gemfile.rails-4.1
41
+ - rvm: 2.4.1
42
+ gemfile: gemfiles/Gemfile.rails-4.2
34
43
  - rvm: ruby-head
35
44
  gemfile: gemfiles/Gemfile.rails-3.2
45
+ - rvm: ruby-head
46
+ gemfile: gemfiles/Gemfile.rails-4.0
47
+ - rvm: ruby-head
48
+ gemfile: gemfiles/Gemfile.rails-4.1
49
+ - rvm: ruby-head
50
+ gemfile: gemfiles/Gemfile.rails-4.2
36
51
  allow_failures:
37
52
  - rvm: ruby-head
@@ -2,5 +2,6 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem 'railties', '~> 4.0.0'
4
4
  gem 'activerecord', '~> 4.0.0'
5
+ gem 'nokogiri', '~> 1.6.8' if RUBY_VERSION < '2.1.0'
5
6
 
6
7
  gemspec path: '..'
@@ -2,5 +2,6 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem 'railties', '~> 4.1.0'
4
4
  gem 'activerecord', '~> 4.1.0'
5
+ gem 'nokogiri', '~> 1.6.8' if RUBY_VERSION < '2.1.0'
5
6
 
6
7
  gemspec path: '..'
@@ -2,5 +2,6 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem 'railties', '~> 4.2.0'
4
4
  gem 'activerecord', '~> 4.2.0'
5
+ gem 'nokogiri', '~> 1.6.8' if RUBY_VERSION < '2.1.0'
5
6
 
6
7
  gemspec path: '..'
@@ -15,7 +15,7 @@ module Html5Validators
15
15
  module PresenceValidator
16
16
  def render
17
17
  if object.class.ancestors.include?(ActiveModel::Validations) && (object.auto_html5_validation != false) && (object.class.auto_html5_validation != false)
18
- @options["required"] ||= @options[:required] || object.class.attribute_required?(@method_name)
18
+ @options["required"] ||= @options.fetch(:required) { object.class.attribute_required?(@method_name) }
19
19
  end
20
20
  super
21
21
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Html5Validators
3
- VERSION = '1.5.0'
3
+ VERSION = '1.7.0'
4
4
  end
data/test/fake_app.rb CHANGED
@@ -18,12 +18,14 @@ app.routes.draw do
18
18
  collection do
19
19
  get :new_without_html5_validation
20
20
  get :new_with_required_true
21
+ get :new_with_required_false
21
22
  end
22
23
  end
23
24
  resources :items, only: [:new, :create] do
24
25
  collection do
25
26
  get :new_without_html5_validation
26
27
  get :new_with_required_true
28
+ get :new_with_required_false
27
29
  end
28
30
  end
29
31
  end
@@ -74,6 +76,15 @@ ERB
74
76
  render inline: <<-ERB
75
77
  <%= form_for @person do |f| %>
76
78
  <%= f.text_field :email, required: true %>
79
+ <% end %>
80
+ ERB
81
+ end
82
+
83
+ def new_with_required_false
84
+ @person = Person.new
85
+ render inline: <<-ERB
86
+ <%= form_for @person do |f| %>
87
+ <%= f.text_field :email, required: false %>
77
88
  <% end %>
78
89
  ERB
79
90
  end
@@ -104,6 +115,15 @@ ERB
104
115
  render inline: <<-ERB
105
116
  <%= form_for @item do |f| %>
106
117
  <%= f.text_field :name, required: true %>
118
+ <% end %>
119
+ ERB
120
+ end
121
+
122
+ def new_with_required_false
123
+ @item = Item.new
124
+ render inline: <<-ERB
125
+ <%= form_for @item do |f| %>
126
+ <%= f.text_field :name, required: false %>
107
127
  <% end %>
108
128
  ERB
109
129
  end
@@ -113,7 +133,7 @@ end
113
133
  module ApplicationHelper; end
114
134
 
115
135
  #migrations
116
- class CreateAllTables < ActiveRecord::Migration
136
+ class CreateAllTables < ActiveRecord::VERSION::MAJOR >= 5 ? ActiveRecord::Migration[5.0] : ActiveRecord::Migration
117
137
  def self.up
118
138
  create_table :people do |t|
119
139
  t.string :name
@@ -39,7 +39,11 @@ class ActiveRecordValidationTest < ActionDispatch::IntegrationTest
39
39
 
40
40
  assert_equal 'required', find('input#person_email')[:required]
41
41
  end
42
+ test 'new_with_required_false form' do
43
+ visit '/people/new_with_required_false'
42
44
 
45
+ assert_nil find('input#person_email')[:required]
46
+ end
43
47
  sub_test_case 'disabling html5_validation in class level' do
44
48
  setup do
45
49
  Person.class_eval do |kls|
@@ -141,7 +145,11 @@ class ActiveModelValidationTest < ActionDispatch::IntegrationTest
141
145
 
142
146
  assert_equal 'required', find('input#item_name')[:required]
143
147
  end
148
+ test 'new_with_required_false form' do
149
+ visit '/items/new_with_required_false'
144
150
 
151
+ assert_nil find('input#item_name')[:required]
152
+ end
145
153
  sub_test_case 'disabling html5_validation in class level' do
146
154
  setup do
147
155
  Item.class_eval do |kls|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: html5_validators
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akira Matsuda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-26 00:00:00.000000000 Z
11
+ date: 2017-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-unit-rails
@@ -75,7 +75,6 @@ extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
77
  - ".gitignore"
78
- - ".rspec"
79
78
  - ".travis.yml"
80
79
  - Gemfile
81
80
  - MIT-LICENSE
@@ -119,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
118
  version: '0'
120
119
  requirements: []
121
120
  rubyforge_project: html5_validators
122
- rubygems_version: 2.6.8
121
+ rubygems_version: 2.6.11
123
122
  signing_key:
124
123
  specification_version: 4
125
124
  summary: Automatic client side validation using HTML5 Form Validation
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --color
2
- --format=d
3
- --warning