judge 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +1 -7
- data/README.md +0 -2
- data/Rakefile +2 -2
- data/VERSION +1 -1
- data/judge.gemspec +18 -3
- data/lib/generators/judge/templates/judge.js +21 -2
- data/lib/judge.rb +4 -3
- data/lib/judge/form.rb +56 -0
- data/lib/judge/utils.rb +13 -0
- data/spec/javascripts/JudgeSpec.js +54 -0
- data/spec/javascripts/fixtures/form.html +9 -0
- data/test/dummy/app/controllers/foos_controller.rb +6 -0
- data/test/dummy/app/models/city.rb +5 -0
- data/test/dummy/app/models/continent.rb +4 -0
- data/test/dummy/app/models/country.rb +6 -0
- data/test/dummy/app/models/fake.rb +2 -0
- data/test/dummy/app/models/foo.rb +2 -0
- data/test/dummy/app/views/foos/new.html.erb +12 -4
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/20110724201117_create_fake_collections.rb +14 -0
- data/test/dummy/db/migrate/20110724201548_rename_fake_collection_to_fake.rb +9 -0
- data/test/dummy/db/migrate/20110725082530_create_continent_country_and_city_tables.rb +24 -0
- data/test/dummy/db/schema.rb +22 -1
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +214 -0
- data/test/judge_test.rb +16 -5
- metadata +20 -5
- data/lib/judge/helpers.rb +0 -31
data/.travis.yml
CHANGED
@@ -1,13 +1,7 @@
|
|
1
1
|
rvm:
|
2
2
|
- 1.9.2
|
3
3
|
|
4
|
-
script: "bundle exec rake test:
|
5
|
-
|
6
|
-
#before_script:
|
7
|
-
# - "sudo apt-get install qt4-qmake"
|
8
|
-
# - "git clone git://github.com/ariya/phantomjs.git && cd phantomjs"
|
9
|
-
# - "git checkout 1.2"
|
10
|
-
# - "qmake-qt4 && make"
|
4
|
+
script: "bundle exec rake test:form"
|
11
5
|
|
12
6
|
notifications:
|
13
7
|
recipients:
|
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -37,7 +37,7 @@ Rake::RDocTask.new do |rdoc|
|
|
37
37
|
end
|
38
38
|
|
39
39
|
namespace :test do
|
40
|
-
Rake::TestTask.new(:
|
40
|
+
Rake::TestTask.new(:form) do |test|
|
41
41
|
test.libs << 'lib' << 'test'
|
42
42
|
test.pattern = 'test/**/*_test.rb'
|
43
43
|
test.verbose = true
|
@@ -47,5 +47,5 @@ namespace :test do
|
|
47
47
|
task :js => ["jasmine:phantom"]
|
48
48
|
|
49
49
|
desc "Run all tests"
|
50
|
-
task :all => [:
|
50
|
+
task :all => [:form, :js]
|
51
51
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/judge.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{judge}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Joe Corcoran"]
|
12
|
-
s.date = %q{2011-07-
|
12
|
+
s.date = %q{2011-07-25}
|
13
13
|
s.description = %q{Validate forms in-place using your model validations}
|
14
14
|
s.email = %q{joe@tribesports.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -31,7 +31,8 @@ Gem::Specification.new do |s|
|
|
31
31
|
"lib/generators/judge/templates/judge.js",
|
32
32
|
"lib/generators/judge/templates/underscore.js",
|
33
33
|
"lib/judge.rb",
|
34
|
-
"lib/judge/
|
34
|
+
"lib/judge/form.rb",
|
35
|
+
"lib/judge/utils.rb",
|
35
36
|
"lib/tasks/js_tests.rake",
|
36
37
|
"spec/javascripts/JudgeSpec.js",
|
37
38
|
"spec/javascripts/fixtures/form.html",
|
@@ -48,6 +49,10 @@ Gem::Specification.new do |s|
|
|
48
49
|
"test/dummy/app/controllers/application_controller.rb",
|
49
50
|
"test/dummy/app/controllers/foos_controller.rb",
|
50
51
|
"test/dummy/app/helpers/application_helper.rb",
|
52
|
+
"test/dummy/app/models/city.rb",
|
53
|
+
"test/dummy/app/models/continent.rb",
|
54
|
+
"test/dummy/app/models/country.rb",
|
55
|
+
"test/dummy/app/models/fake.rb",
|
51
56
|
"test/dummy/app/models/foo.rb",
|
52
57
|
"test/dummy/app/views/foos/new.html.erb",
|
53
58
|
"test/dummy/app/views/layouts/application.html.erb",
|
@@ -68,6 +73,9 @@ Gem::Specification.new do |s|
|
|
68
73
|
"test/dummy/config/routes.rb",
|
69
74
|
"test/dummy/db/development.sqlite3",
|
70
75
|
"test/dummy/db/migrate/20110624115516_create_foos.rb",
|
76
|
+
"test/dummy/db/migrate/20110724201117_create_fake_collections.rb",
|
77
|
+
"test/dummy/db/migrate/20110724201548_rename_fake_collection_to_fake.rb",
|
78
|
+
"test/dummy/db/migrate/20110725082530_create_continent_country_and_city_tables.rb",
|
71
79
|
"test/dummy/db/schema.rb",
|
72
80
|
"test/dummy/db/test.sqlite3",
|
73
81
|
"test/dummy/log/development.log",
|
@@ -99,6 +107,10 @@ Gem::Specification.new do |s|
|
|
99
107
|
"test/dummy/app/controllers/application_controller.rb",
|
100
108
|
"test/dummy/app/controllers/foos_controller.rb",
|
101
109
|
"test/dummy/app/helpers/application_helper.rb",
|
110
|
+
"test/dummy/app/models/city.rb",
|
111
|
+
"test/dummy/app/models/continent.rb",
|
112
|
+
"test/dummy/app/models/country.rb",
|
113
|
+
"test/dummy/app/models/fake.rb",
|
102
114
|
"test/dummy/app/models/foo.rb",
|
103
115
|
"test/dummy/config/application.rb",
|
104
116
|
"test/dummy/config/boot.rb",
|
@@ -113,6 +125,9 @@ Gem::Specification.new do |s|
|
|
113
125
|
"test/dummy/config/initializers/session_store.rb",
|
114
126
|
"test/dummy/config/routes.rb",
|
115
127
|
"test/dummy/db/migrate/20110624115516_create_foos.rb",
|
128
|
+
"test/dummy/db/migrate/20110724201117_create_fake_collections.rb",
|
129
|
+
"test/dummy/db/migrate/20110724201548_rename_fake_collection_to_fake.rb",
|
130
|
+
"test/dummy/db/migrate/20110725082530_create_continent_country_and_city_tables.rb",
|
116
131
|
"test/dummy/db/schema.rb",
|
117
132
|
"test/judge_test.rb",
|
118
133
|
"test/test_helper.rb"
|
@@ -23,10 +23,10 @@ judge.Watcher = function (element) {
|
|
23
23
|
throw new TypeError('[judge] Cannot construct new Watcher for object of this type');
|
24
24
|
}
|
25
25
|
if (element.getAttribute('data-validate') === null) {
|
26
|
-
throw new ReferenceError('[judge] Cannot construct new Watcher for this element, please use judge
|
26
|
+
throw new ReferenceError('[judge] Cannot construct new Watcher for this element, please use judge form builder methods in your view');
|
27
27
|
}
|
28
28
|
if (element.form.getAttribute('data-error-messages') === null) {
|
29
|
-
throw new ReferenceError('[judge] Element parent form was not created using judge helper, please amend');
|
29
|
+
throw new ReferenceError('[judge] Element parent form was not created using judge form helper, please amend');
|
30
30
|
}
|
31
31
|
|
32
32
|
|
@@ -151,6 +151,25 @@ judge.Watcher.prototype.validates = function() {
|
|
151
151
|
if (withoutReg.test(value)) { msgs.push(options.message || instance.defaultMessages.invalid); }
|
152
152
|
}
|
153
153
|
return msgs.length ? { valid:false, messages:msgs } : { valid:true };
|
154
|
+
},
|
155
|
+
|
156
|
+
acceptance: function(options) {
|
157
|
+
if (instance.element.checked === true) {
|
158
|
+
return { valid:true };
|
159
|
+
} else {
|
160
|
+
return { valid:false, messages:[options.message || instance.defaultMessages.accepted] };
|
161
|
+
}
|
162
|
+
},
|
163
|
+
|
164
|
+
confirmation: function(options) {
|
165
|
+
var id = instance.element.getAttribute('id'),
|
166
|
+
confId = id + '_confirmation',
|
167
|
+
confElem = document.getElementById(confId);
|
168
|
+
if (instance.element.value === confElem.value) {
|
169
|
+
return { valid:true };
|
170
|
+
} else {
|
171
|
+
return { valid:false, messages:[options.message || instance.defaultMessages.confirmation] };
|
172
|
+
}
|
154
173
|
}
|
155
174
|
};
|
156
175
|
return _.extend(methods, extendedMethods);
|
data/lib/judge.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/judge/
|
1
|
+
require File.dirname(__FILE__) + '/judge/utils'
|
2
|
+
require File.dirname(__FILE__) + '/judge/form'
|
2
3
|
|
3
|
-
::ActionView::Helpers::FormBuilder.send(:include, Judge::
|
4
|
-
::ActionView::Helpers::FormHelper.send(:include, Judge::
|
4
|
+
::ActionView::Helpers::FormBuilder.send(:include, Judge::FormBuilder)
|
5
|
+
::ActionView::Helpers::FormHelper.send(:include, Judge::FormHelper)
|
data/lib/judge/form.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
module Judge
|
2
|
+
|
3
|
+
module FormBuilder
|
4
|
+
|
5
|
+
include ActionView::Helpers::TagHelper
|
6
|
+
|
7
|
+
%w{text_field text_area}.each do |type|
|
8
|
+
helper = <<-END
|
9
|
+
def validated_#{type}(method, options = {})
|
10
|
+
options = { "data-validate" => Judge::Utils.jsonify_validators(self.object, method) }.merge(options)
|
11
|
+
@template.#{type}(self.object_name, method, options)
|
12
|
+
end
|
13
|
+
END
|
14
|
+
class_eval helper, __FILE__, __LINE__
|
15
|
+
end
|
16
|
+
|
17
|
+
def validated_radio_button(method, tag_value, options = {})
|
18
|
+
options = { "data-validate" => Judge::Utils.jsonify_validators(self.object, method) }.merge(options)
|
19
|
+
@template.radio_button(@object_name, method, tag_value, objectify_options(options))
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
def validated_check_box(method, options = {}, checked_value = "1", unchecked_value = "0")
|
24
|
+
options = { "data-validate" => Judge::Utils.jsonify_validators(self.object, method) }.merge(options)
|
25
|
+
@template.check_box(self.object_name, method, objectify_options(options), checked_value, unchecked_value)
|
26
|
+
end
|
27
|
+
|
28
|
+
def validated_select(method, choices, options = {}, html_options = {})
|
29
|
+
html_options = { "data-validate" => Judge::Utils.jsonify_validators(self.object, method) }.merge(html_options)
|
30
|
+
@template.select(self.object_name, method, choices, objectify_options(options), @default_options.merge(html_options))
|
31
|
+
end
|
32
|
+
|
33
|
+
def validated_collection_select(method, collection, value_method, text_method, options = {}, html_options = {})
|
34
|
+
html_options = { "data-validate" => Judge::Utils.jsonify_validators(self.object, method) }.merge(html_options)
|
35
|
+
@template.collection_select(self.object_name, method, collection, value_method, text_method, objectify_options(options), @default_options.merge(html_options))
|
36
|
+
end
|
37
|
+
|
38
|
+
def validated_grouped_collection_select(method, collection, group_method, group_label_method, option_key_method, option_value_method, options = {}, html_options = {})
|
39
|
+
html_options = { "data-validate" => Judge::Utils.jsonify_validators(self.object, method) }.merge(html_options)
|
40
|
+
@template.grouped_collection_select(self.object_name, method, collection, group_method, group_label_method, option_key_method, option_value_method, objectify_options(options), @default_options.merge(html_options))
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
module FormHelper
|
46
|
+
|
47
|
+
def validated_form_for(record_or_name_or_array, *args, &proc)
|
48
|
+
options = args.extract_options!
|
49
|
+
options[:html] ||= {}
|
50
|
+
options[:html]["data-error-messages"] = I18n.t("errors.messages").to_json
|
51
|
+
form_for(record_or_name_or_array, *(args << options), &proc)
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
data/lib/judge/utils.rb
ADDED
@@ -504,6 +504,60 @@ describe('judge', function() {
|
|
504
504
|
|
505
505
|
});
|
506
506
|
|
507
|
+
describe('acceptance', function() {
|
508
|
+
|
509
|
+
var j;
|
510
|
+
|
511
|
+
beforeEach(function() {
|
512
|
+
j = new judge.Watcher(document.getElementById('foo_six'));
|
513
|
+
});
|
514
|
+
|
515
|
+
it('validates when element is checked', function() {
|
516
|
+
j.element.checked = true;
|
517
|
+
expect(j.validate().valid).toEqual(true);
|
518
|
+
});
|
519
|
+
|
520
|
+
it('invalidates when element is not checked', function() {
|
521
|
+
expect(j.validate().valid).toEqual(false);
|
522
|
+
});
|
523
|
+
|
524
|
+
it('invalidates with custom message when present', function() {
|
525
|
+
_(j.validators).first().options.message = 'must be ticked';
|
526
|
+
expect(j.validate().messages).toContain('must be ticked');
|
527
|
+
});
|
528
|
+
|
529
|
+
});
|
530
|
+
|
531
|
+
describe('confirmation', function() {
|
532
|
+
|
533
|
+
var j, c;
|
534
|
+
|
535
|
+
beforeEach(function() {
|
536
|
+
j = new judge.Watcher(document.getElementById('foo_seven'));
|
537
|
+
c = document.getElementById('foo_seven_confirmation');
|
538
|
+
});
|
539
|
+
|
540
|
+
it('validates when confirmed', function() {
|
541
|
+
j.element.value = 'password';
|
542
|
+
c.value = 'password';
|
543
|
+
expect(j.validate().valid).toEqual(true);
|
544
|
+
});
|
545
|
+
|
546
|
+
it('invalidates when not confirmed', function() {
|
547
|
+
j.element.value = 'password';
|
548
|
+
c.value = 'wrongpassword';
|
549
|
+
expect(j.validate().valid).toEqual(false);
|
550
|
+
});
|
551
|
+
|
552
|
+
it('invalidates with custom message when present', function() {
|
553
|
+
_(j.validators).first().options.message = 'must be same';
|
554
|
+
j.element.value = 'password';
|
555
|
+
c.value = 'wrongpassword';
|
556
|
+
expect(j.validate().messages).toContain('must be same');
|
557
|
+
});
|
558
|
+
|
559
|
+
});
|
560
|
+
|
507
561
|
});
|
508
562
|
|
509
563
|
describe('utils', function() {
|
@@ -44,6 +44,15 @@
|
|
44
44
|
<label for="foo_five_wo">Five</label><br />
|
45
45
|
<input data-validate="[{"kind":"format","options":{"without":"(?-mix:[A-Za-z]+)"}}]" id="foo_five_wo" name="foo[five_wo]" size="30" type="text" />
|
46
46
|
</div>
|
47
|
+
<div class="field">
|
48
|
+
<label for="foo_six">Six</label><br />
|
49
|
+
<input data-validate="[{"kind":"acceptance","options":{"accept":"1","allow_nil":"true"}}]" id="foo_six" name="foo[six]" type="checkbox" />
|
50
|
+
</div>
|
51
|
+
<div class="field">
|
52
|
+
<label for="foo_seven">Six</label><br />
|
53
|
+
<input data-validate="[{"kind":"confirmation","options":{}}]" id="foo_seven" name="foo[seven]" type="text" />
|
54
|
+
</div>
|
55
|
+
<input id="foo_seven_confirmation" name="foo[seven_confirmation]" type="text" />
|
47
56
|
<div class="actions">
|
48
57
|
<input id="foo_submit" name="commit" type="submit" value="Create Foo" />
|
49
58
|
</div>
|
@@ -1,5 +1,11 @@
|
|
1
1
|
class FoosController < ApplicationController
|
2
2
|
def new
|
3
3
|
@foo = Foo.new
|
4
|
+
|
5
|
+
continent = Continent.new(:id => 1, :name => "Europe")
|
6
|
+
country = Country.new(:id => 1, :name => "Germany")
|
7
|
+
country.cities << City.new(:id => 1, :name => "Hamburg")
|
8
|
+
continent.countries << country
|
9
|
+
@continents = [continent]
|
4
10
|
end
|
5
11
|
end
|
@@ -6,6 +6,8 @@ class Foo < ActiveRecord::Base
|
|
6
6
|
validates :four, :numericality => { :only_integer => true, :odd => true, :less_than_or_equal_to => 7 },
|
7
7
|
:exclusion => { :in => [3,12] }
|
8
8
|
validates :five, :format => { :without => /[A-Za-z]+/ }
|
9
|
+
validates :six, :acceptance => true
|
10
|
+
validates :seven, :confirmation => true
|
9
11
|
|
10
12
|
end
|
11
13
|
|
@@ -15,15 +15,15 @@
|
|
15
15
|
|
16
16
|
<div class="field">
|
17
17
|
<%= f.label :one %><br />
|
18
|
-
<%= f.
|
18
|
+
<%= f.validated_select :one, [["hello", "HELLO"],["goodbye", "GOODBYE"]] %>
|
19
19
|
</div>
|
20
20
|
<div class="field">
|
21
21
|
<%= f.label :two %><br />
|
22
|
-
<%= f.
|
22
|
+
<%= f.validated_radio_button :two, "FOOBAR" %>
|
23
23
|
</div>
|
24
24
|
<div class="field">
|
25
25
|
<%= f.label :three %><br />
|
26
|
-
<%= f.
|
26
|
+
<%= f.validated_collection_select :three, [Fake.new(:text => "Dave", :value => 24), Fake.new(:text => "Alice", :value => 30)], :value, :text %>
|
27
27
|
</div>
|
28
28
|
<div class="field">
|
29
29
|
<%= f.label :four %><br />
|
@@ -31,7 +31,15 @@
|
|
31
31
|
</div>
|
32
32
|
<div class="field">
|
33
33
|
<%= f.label :five %><br />
|
34
|
-
<%= f.
|
34
|
+
<%= f.validated_grouped_collection_select :five, @continents, :countries, :name, :id, :name %>
|
35
|
+
</div>
|
36
|
+
<div class="field">
|
37
|
+
<%= f.label :six %><br />
|
38
|
+
<%= f.validated_check_box :six %>
|
39
|
+
</div>
|
40
|
+
<div class="field">
|
41
|
+
<%= f.label :seven %><br />
|
42
|
+
<%= f.validated_text_field :seven %>
|
35
43
|
</div>
|
36
44
|
<div class="actions">
|
37
45
|
<%= f.submit %>
|
Binary file
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class CreateContinentCountryAndCityTables < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :continents do |t|
|
4
|
+
t.integer :id
|
5
|
+
t.string :name
|
6
|
+
end
|
7
|
+
create_table :countries do |t|
|
8
|
+
t.integer :id
|
9
|
+
t.integer :continent_id
|
10
|
+
t.string :name
|
11
|
+
end
|
12
|
+
create_table :cities do |t|
|
13
|
+
t.integer :id
|
14
|
+
t.integer :country_id
|
15
|
+
t.string :name
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.down
|
20
|
+
drop_table :continents
|
21
|
+
drop_table :countries
|
22
|
+
drop_table :cities
|
23
|
+
end
|
24
|
+
end
|
data/test/dummy/db/schema.rb
CHANGED
@@ -10,7 +10,28 @@
|
|
10
10
|
#
|
11
11
|
# It's strongly recommended to check this file into your version control system.
|
12
12
|
|
13
|
-
ActiveRecord::Schema.define(:version =>
|
13
|
+
ActiveRecord::Schema.define(:version => 20110725082530) do
|
14
|
+
|
15
|
+
create_table "cities", :force => true do |t|
|
16
|
+
t.integer "country_id"
|
17
|
+
t.string "name"
|
18
|
+
end
|
19
|
+
|
20
|
+
create_table "continents", :force => true do |t|
|
21
|
+
t.string "name"
|
22
|
+
end
|
23
|
+
|
24
|
+
create_table "countries", :force => true do |t|
|
25
|
+
t.integer "continent_id"
|
26
|
+
t.string "name"
|
27
|
+
end
|
28
|
+
|
29
|
+
create_table "fakes", :force => true do |t|
|
30
|
+
t.string "value"
|
31
|
+
t.string "text"
|
32
|
+
t.datetime "created_at"
|
33
|
+
t.datetime "updated_at"
|
34
|
+
end
|
14
35
|
|
15
36
|
create_table "foos", :force => true do |t|
|
16
37
|
t.string "one"
|
data/test/dummy/db/test.sqlite3
CHANGED
Binary file
|
@@ -57,3 +57,217 @@ Migrating to CreateFoos (20110624115516)
|
|
57
57
|
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
58
58
|
[1m[36mSQL (0.1ms)[0m [1mSELECT version FROM "schema_migrations"[0m
|
59
59
|
[1m[35mSQL (1.1ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20110624115516')
|
60
|
+
[1m[36mSQL (0.5ms)[0m [1m SELECT name
|
61
|
+
FROM sqlite_master
|
62
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
63
|
+
[0m
|
64
|
+
[1m[35mSQL (0.1ms)[0m SELECT name
|
65
|
+
FROM sqlite_master
|
66
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
67
|
+
[1m[36mSQL (0.1ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations"[0m
|
68
|
+
Migrating to CreateFoos (20110624115516)
|
69
|
+
Migrating to CreateFakeCollections (20110724201117)
|
70
|
+
[1m[35mSQL (0.0ms)[0m select sqlite_version(*)
|
71
|
+
[1m[36mSQL (0.5ms)[0m [1mCREATE TABLE "fake_collections" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "value" varchar(255), "text" varchar(255), "created_at" datetime, "updated_at" datetime) [0m
|
72
|
+
[1m[35mSQL (0.1ms)[0m INSERT INTO "schema_migrations" ("version") VALUES ('20110724201117')
|
73
|
+
[1m[36mSQL (0.3ms)[0m [1m SELECT name
|
74
|
+
FROM sqlite_master
|
75
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
76
|
+
[0m
|
77
|
+
[1m[35mSQL (0.1ms)[0m SELECT "schema_migrations"."version" FROM "schema_migrations"
|
78
|
+
[1m[36mSQL (0.1ms)[0m [1m SELECT name
|
79
|
+
FROM sqlite_master
|
80
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
81
|
+
[0m
|
82
|
+
[1m[35mSQL (0.0ms)[0m PRAGMA index_list("fake_collections")
|
83
|
+
[1m[36mSQL (0.0ms)[0m [1mPRAGMA index_list("foos")[0m
|
84
|
+
[1m[36mSQL (0.5ms)[0m [1mselect sqlite_version(*)[0m
|
85
|
+
[1m[35mSQL (0.3ms)[0m SELECT name
|
86
|
+
FROM sqlite_master
|
87
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
88
|
+
[1m[36mSQL (0.1ms)[0m [1m SELECT name
|
89
|
+
FROM sqlite_master
|
90
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
91
|
+
[0m
|
92
|
+
[1m[35mSQL (0.2ms)[0m SELECT "schema_migrations"."version" FROM "schema_migrations"
|
93
|
+
[1m[36mSQL (0.1ms)[0m [1m SELECT name
|
94
|
+
FROM sqlite_master
|
95
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
96
|
+
[0m
|
97
|
+
[1m[35mSQL (0.0ms)[0m PRAGMA index_list("fake_collections")
|
98
|
+
[1m[36mSQL (0.0ms)[0m [1mPRAGMA index_list("foos")[0m
|
99
|
+
[1m[35mSQL (0.2ms)[0m select sqlite_version(*)
|
100
|
+
[1m[36mSQL (0.1ms)[0m [1m SELECT name
|
101
|
+
FROM sqlite_master
|
102
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
103
|
+
[0m
|
104
|
+
[1m[35mSQL (1.7ms)[0m CREATE TABLE "fake_collections" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "value" varchar(255), "text" varchar(255), "created_at" datetime, "updated_at" datetime)
|
105
|
+
[1m[36mSQL (0.1ms)[0m [1m SELECT name
|
106
|
+
FROM sqlite_master
|
107
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
108
|
+
[0m
|
109
|
+
[1m[35mSQL (1.3ms)[0m CREATE TABLE "foos" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "one" varchar(255), "two" varchar(255), "three" varchar(255), "four" varchar(255), "five" varchar(255), "six" varchar(255), "seven" varchar(255), "eight" varchar(255), "nine" varchar(255), "ten" varchar(255), "eleven" varchar(255), "twelve" varchar(255), "thirteen" varchar(255), "fourteen" varchar(255), "created_at" datetime, "updated_at" datetime)
|
110
|
+
[1m[36mSQL (0.1ms)[0m [1m SELECT name
|
111
|
+
FROM sqlite_master
|
112
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
113
|
+
[0m
|
114
|
+
[1m[35mSQL (1.4ms)[0m CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
|
115
|
+
[1m[36mSQL (0.0ms)[0m [1mPRAGMA index_list("schema_migrations")[0m
|
116
|
+
[1m[35mSQL (27.8ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
117
|
+
[1m[36mSQL (0.1ms)[0m [1m SELECT name
|
118
|
+
FROM sqlite_master
|
119
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
120
|
+
[0m
|
121
|
+
[1m[35mSQL (0.1ms)[0m SELECT version FROM "schema_migrations"
|
122
|
+
[1m[36mSQL (1.1ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20110724201117')[0m
|
123
|
+
[1m[35mSQL (1.1ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20110624115516')
|
124
|
+
[1m[36mSQL (0.6ms)[0m [1m SELECT name
|
125
|
+
FROM sqlite_master
|
126
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
127
|
+
[0m
|
128
|
+
[1m[35mSQL (0.3ms)[0m SELECT name
|
129
|
+
FROM sqlite_master
|
130
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
131
|
+
[1m[36mSQL (0.2ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations"[0m
|
132
|
+
Migrating to CreateFoos (20110624115516)
|
133
|
+
Migrating to CreateFakeCollections (20110724201117)
|
134
|
+
Migrating to RenameFakeCollectionToFake (20110724201548)
|
135
|
+
[1m[35mSQL (0.1ms)[0m select sqlite_version(*)
|
136
|
+
[1m[36mSQL (16.0ms)[0m [1mALTER TABLE "fake_collections" RENAME TO "fakes"[0m
|
137
|
+
[1m[35mSQL (0.2ms)[0m INSERT INTO "schema_migrations" ("version") VALUES ('20110724201548')
|
138
|
+
[1m[36mSQL (0.3ms)[0m [1m SELECT name
|
139
|
+
FROM sqlite_master
|
140
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
141
|
+
[0m
|
142
|
+
[1m[35mSQL (0.1ms)[0m SELECT "schema_migrations"."version" FROM "schema_migrations"
|
143
|
+
[1m[36mSQL (0.1ms)[0m [1m SELECT name
|
144
|
+
FROM sqlite_master
|
145
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
146
|
+
[0m
|
147
|
+
[1m[35mSQL (0.0ms)[0m PRAGMA index_list("fakes")
|
148
|
+
[1m[36mSQL (0.1ms)[0m [1mPRAGMA index_list("foos")[0m
|
149
|
+
[1m[36mSQL (0.4ms)[0m [1mselect sqlite_version(*)[0m
|
150
|
+
[1m[35mSQL (0.2ms)[0m SELECT name
|
151
|
+
FROM sqlite_master
|
152
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
153
|
+
[1m[36mSQL (0.1ms)[0m [1m SELECT name
|
154
|
+
FROM sqlite_master
|
155
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
156
|
+
[0m
|
157
|
+
[1m[35mSQL (0.2ms)[0m SELECT "schema_migrations"."version" FROM "schema_migrations"
|
158
|
+
[1m[36mSQL (0.1ms)[0m [1m SELECT name
|
159
|
+
FROM sqlite_master
|
160
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
161
|
+
[0m
|
162
|
+
[1m[35mSQL (0.0ms)[0m PRAGMA index_list("fakes")
|
163
|
+
[1m[36mSQL (0.0ms)[0m [1mPRAGMA index_list("foos")[0m
|
164
|
+
[1m[35mSQL (0.2ms)[0m select sqlite_version(*)
|
165
|
+
[1m[36mSQL (0.1ms)[0m [1m SELECT name
|
166
|
+
FROM sqlite_master
|
167
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
168
|
+
[0m
|
169
|
+
[1m[35mSQL (1.8ms)[0m CREATE TABLE "fakes" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "value" varchar(255), "text" varchar(255), "created_at" datetime, "updated_at" datetime)
|
170
|
+
[1m[36mSQL (0.1ms)[0m [1m SELECT name
|
171
|
+
FROM sqlite_master
|
172
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
173
|
+
[0m
|
174
|
+
[1m[35mSQL (1.8ms)[0m CREATE TABLE "foos" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "one" varchar(255), "two" varchar(255), "three" varchar(255), "four" varchar(255), "five" varchar(255), "six" varchar(255), "seven" varchar(255), "eight" varchar(255), "nine" varchar(255), "ten" varchar(255), "eleven" varchar(255), "twelve" varchar(255), "thirteen" varchar(255), "fourteen" varchar(255), "created_at" datetime, "updated_at" datetime)
|
175
|
+
[1m[36mSQL (0.2ms)[0m [1m SELECT name
|
176
|
+
FROM sqlite_master
|
177
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
178
|
+
[0m
|
179
|
+
[1m[35mSQL (1.4ms)[0m CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
|
180
|
+
[1m[36mSQL (0.0ms)[0m [1mPRAGMA index_list("schema_migrations")[0m
|
181
|
+
[1m[35mSQL (1.4ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
182
|
+
[1m[36mSQL (0.2ms)[0m [1m SELECT name
|
183
|
+
FROM sqlite_master
|
184
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
185
|
+
[0m
|
186
|
+
[1m[35mSQL (0.1ms)[0m SELECT version FROM "schema_migrations"
|
187
|
+
[1m[36mSQL (1.9ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20110724201548')[0m
|
188
|
+
[1m[35mSQL (1.2ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20110624115516')
|
189
|
+
[1m[36mSQL (1.2ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20110724201117')[0m
|
190
|
+
[1m[36mSQL (0.5ms)[0m [1m SELECT name
|
191
|
+
FROM sqlite_master
|
192
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
193
|
+
[0m
|
194
|
+
[1m[35mSQL (0.1ms)[0m SELECT name
|
195
|
+
FROM sqlite_master
|
196
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
197
|
+
[1m[36mSQL (0.1ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations"[0m
|
198
|
+
Migrating to CreateFoos (20110624115516)
|
199
|
+
Migrating to CreateFakeCollections (20110724201117)
|
200
|
+
Migrating to RenameFakeCollectionToFake (20110724201548)
|
201
|
+
Migrating to CreateContinentCountryAndCityTables (20110725082530)
|
202
|
+
[1m[35mSQL (0.1ms)[0m select sqlite_version(*)
|
203
|
+
[1m[36mSQL (0.5ms)[0m [1mCREATE TABLE "continents" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) [0m
|
204
|
+
[1m[35mSQL (0.1ms)[0m CREATE TABLE "countries" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "continent_id" integer, "name" varchar(255))
|
205
|
+
[1m[36mSQL (0.1ms)[0m [1mCREATE TABLE "cities" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "country_id" integer, "name" varchar(255)) [0m
|
206
|
+
[1m[35mSQL (0.3ms)[0m INSERT INTO "schema_migrations" ("version") VALUES ('20110725082530')
|
207
|
+
[1m[36mSQL (0.3ms)[0m [1m SELECT name
|
208
|
+
FROM sqlite_master
|
209
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
210
|
+
[0m
|
211
|
+
[1m[35mSQL (0.1ms)[0m SELECT "schema_migrations"."version" FROM "schema_migrations"
|
212
|
+
[1m[36mSQL (0.1ms)[0m [1m SELECT name
|
213
|
+
FROM sqlite_master
|
214
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
215
|
+
[0m
|
216
|
+
[1m[35mSQL (0.0ms)[0m PRAGMA index_list("cities")
|
217
|
+
[1m[36mSQL (0.0ms)[0m [1mPRAGMA index_list("continents")[0m
|
218
|
+
[1m[35mSQL (0.0ms)[0m PRAGMA index_list("countries")
|
219
|
+
[1m[36mSQL (0.0ms)[0m [1mPRAGMA index_list("fakes")[0m
|
220
|
+
[1m[35mSQL (0.0ms)[0m PRAGMA index_list("foos")
|
221
|
+
[1m[36mSQL (0.5ms)[0m [1mselect sqlite_version(*)[0m
|
222
|
+
[1m[35mSQL (0.2ms)[0m SELECT name
|
223
|
+
FROM sqlite_master
|
224
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
225
|
+
[1m[36mSQL (0.1ms)[0m [1m SELECT name
|
226
|
+
FROM sqlite_master
|
227
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
228
|
+
[0m
|
229
|
+
[1m[35mSQL (0.1ms)[0m SELECT "schema_migrations"."version" FROM "schema_migrations"
|
230
|
+
[1m[36mSQL (0.1ms)[0m [1m SELECT name
|
231
|
+
FROM sqlite_master
|
232
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
233
|
+
[0m
|
234
|
+
[1m[35mSQL (0.0ms)[0m PRAGMA index_list("cities")
|
235
|
+
[1m[36mSQL (0.0ms)[0m [1mPRAGMA index_list("continents")[0m
|
236
|
+
[1m[35mSQL (0.0ms)[0m PRAGMA index_list("countries")
|
237
|
+
[1m[36mSQL (0.0ms)[0m [1mPRAGMA index_list("fakes")[0m
|
238
|
+
[1m[35mSQL (0.0ms)[0m PRAGMA index_list("foos")
|
239
|
+
[1m[36mSQL (0.2ms)[0m [1mselect sqlite_version(*)[0m
|
240
|
+
[1m[35mSQL (0.1ms)[0m SELECT name
|
241
|
+
FROM sqlite_master
|
242
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
243
|
+
[1m[36mSQL (1.9ms)[0m [1mCREATE TABLE "cities" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "country_id" integer, "name" varchar(255)) [0m
|
244
|
+
[1m[35mSQL (0.1ms)[0m SELECT name
|
245
|
+
FROM sqlite_master
|
246
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
247
|
+
[1m[36mSQL (1.4ms)[0m [1mCREATE TABLE "continents" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) [0m
|
248
|
+
[1m[35mSQL (0.1ms)[0m SELECT name
|
249
|
+
FROM sqlite_master
|
250
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
251
|
+
[1m[36mSQL (1.7ms)[0m [1mCREATE TABLE "countries" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "continent_id" integer, "name" varchar(255)) [0m
|
252
|
+
[1m[35mSQL (0.1ms)[0m SELECT name
|
253
|
+
FROM sqlite_master
|
254
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
255
|
+
[1m[36mSQL (1.5ms)[0m [1mCREATE TABLE "fakes" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "value" varchar(255), "text" varchar(255), "created_at" datetime, "updated_at" datetime) [0m
|
256
|
+
[1m[35mSQL (0.2ms)[0m SELECT name
|
257
|
+
FROM sqlite_master
|
258
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
259
|
+
[1m[36mSQL (1.9ms)[0m [1mCREATE TABLE "foos" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "one" varchar(255), "two" varchar(255), "three" varchar(255), "four" varchar(255), "five" varchar(255), "six" varchar(255), "seven" varchar(255), "eight" varchar(255), "nine" varchar(255), "ten" varchar(255), "eleven" varchar(255), "twelve" varchar(255), "thirteen" varchar(255), "fourteen" varchar(255), "created_at" datetime, "updated_at" datetime) [0m
|
260
|
+
[1m[35mSQL (0.1ms)[0m SELECT name
|
261
|
+
FROM sqlite_master
|
262
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
263
|
+
[1m[36mSQL (1.7ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) [0m
|
264
|
+
[1m[35mSQL (0.0ms)[0m PRAGMA index_list("schema_migrations")
|
265
|
+
[1m[36mSQL (1.8ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
266
|
+
[1m[35mSQL (0.1ms)[0m SELECT name
|
267
|
+
FROM sqlite_master
|
268
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
269
|
+
[1m[36mSQL (0.1ms)[0m [1mSELECT version FROM "schema_migrations"[0m
|
270
|
+
[1m[35mSQL (1.4ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20110725082530')
|
271
|
+
[1m[36mSQL (1.3ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20110624115516')[0m
|
272
|
+
[1m[35mSQL (1.2ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20110724201117')
|
273
|
+
[1m[36mSQL (1.3ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20110724201548')[0m
|
data/test/judge_test.rb
CHANGED
@@ -15,11 +15,11 @@ class JudgeTest < ActionController::TestCase
|
|
15
15
|
setup { get :new }
|
16
16
|
|
17
17
|
should "include presence validation in data attribute" do
|
18
|
-
assert_equal "presence", validators_from("
|
18
|
+
assert_equal "presence", validators_from("select#foo_one").first["kind"]
|
19
19
|
end
|
20
20
|
|
21
21
|
should "include length (within range) validation in data attribute" do
|
22
|
-
validators = validators_from("input#
|
22
|
+
validators = validators_from("input#foo_two_foobar")
|
23
23
|
assert_equal "length", validators.first["kind"]
|
24
24
|
assert_equal Fixnum, validators.first["options"]["minimum"].class
|
25
25
|
assert_equal Fixnum, validators.first["options"]["maximum"].class
|
@@ -27,12 +27,12 @@ class JudgeTest < ActionController::TestCase
|
|
27
27
|
end
|
28
28
|
|
29
29
|
should "include allow_blank validation in data attribute" do
|
30
|
-
validators = validators_from("input#
|
30
|
+
validators = validators_from("input#foo_two_foobar")
|
31
31
|
assert validators.first["options"]["allow_blank"]
|
32
32
|
end
|
33
33
|
|
34
34
|
should "include exclusion validation in data atribute" do
|
35
|
-
validators = validators_from("
|
35
|
+
validators = validators_from("select#foo_three")
|
36
36
|
assert_equal "exclusion", validators.first["kind"]
|
37
37
|
assert_equal Array, validators.first["options"]["in"].class
|
38
38
|
end
|
@@ -53,10 +53,21 @@ class JudgeTest < ActionController::TestCase
|
|
53
53
|
end
|
54
54
|
|
55
55
|
should "include format validator in data attribute" do
|
56
|
-
validator = validators_from("
|
56
|
+
validator = validators_from("select#foo_five").first
|
57
57
|
assert_equal "format", validator["kind"]
|
58
58
|
assert_match /\(.+\:.+\)/, validator["options"]["without"]
|
59
59
|
end
|
60
|
+
|
61
|
+
should "include acceptance validator in data attribute" do
|
62
|
+
validator = validators_from("input#foo_six").first
|
63
|
+
assert_equal "acceptance", validator["kind"]
|
64
|
+
assert validator["options"]["accept"]
|
65
|
+
end
|
66
|
+
|
67
|
+
should "include confirmation validator in data attribute" do
|
68
|
+
validator = validators_from("input#foo_seven").first
|
69
|
+
assert_equal "confirmation", validator["kind"]
|
70
|
+
end
|
60
71
|
end
|
61
72
|
|
62
73
|
def validators_from(input_selector)
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
7
|
+
- 3
|
8
8
|
- 0
|
9
|
-
version: 0.
|
9
|
+
version: 0.3.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Joe Corcoran
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-07-
|
17
|
+
date: 2011-07-25 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -161,7 +161,8 @@ files:
|
|
161
161
|
- lib/generators/judge/templates/judge.js
|
162
162
|
- lib/generators/judge/templates/underscore.js
|
163
163
|
- lib/judge.rb
|
164
|
-
- lib/judge/
|
164
|
+
- lib/judge/form.rb
|
165
|
+
- lib/judge/utils.rb
|
165
166
|
- lib/tasks/js_tests.rake
|
166
167
|
- spec/javascripts/JudgeSpec.js
|
167
168
|
- spec/javascripts/fixtures/form.html
|
@@ -178,6 +179,10 @@ files:
|
|
178
179
|
- test/dummy/app/controllers/application_controller.rb
|
179
180
|
- test/dummy/app/controllers/foos_controller.rb
|
180
181
|
- test/dummy/app/helpers/application_helper.rb
|
182
|
+
- test/dummy/app/models/city.rb
|
183
|
+
- test/dummy/app/models/continent.rb
|
184
|
+
- test/dummy/app/models/country.rb
|
185
|
+
- test/dummy/app/models/fake.rb
|
181
186
|
- test/dummy/app/models/foo.rb
|
182
187
|
- test/dummy/app/views/foos/new.html.erb
|
183
188
|
- test/dummy/app/views/layouts/application.html.erb
|
@@ -198,6 +203,9 @@ files:
|
|
198
203
|
- test/dummy/config/routes.rb
|
199
204
|
- test/dummy/db/development.sqlite3
|
200
205
|
- test/dummy/db/migrate/20110624115516_create_foos.rb
|
206
|
+
- test/dummy/db/migrate/20110724201117_create_fake_collections.rb
|
207
|
+
- test/dummy/db/migrate/20110724201548_rename_fake_collection_to_fake.rb
|
208
|
+
- test/dummy/db/migrate/20110725082530_create_continent_country_and_city_tables.rb
|
201
209
|
- test/dummy/db/schema.rb
|
202
210
|
- test/dummy/db/test.sqlite3
|
203
211
|
- test/dummy/log/development.log
|
@@ -231,7 +239,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
231
239
|
requirements:
|
232
240
|
- - ">="
|
233
241
|
- !ruby/object:Gem::Version
|
234
|
-
hash:
|
242
|
+
hash: 2587494504961944285
|
235
243
|
segments:
|
236
244
|
- 0
|
237
245
|
version: "0"
|
@@ -256,6 +264,10 @@ test_files:
|
|
256
264
|
- test/dummy/app/controllers/application_controller.rb
|
257
265
|
- test/dummy/app/controllers/foos_controller.rb
|
258
266
|
- test/dummy/app/helpers/application_helper.rb
|
267
|
+
- test/dummy/app/models/city.rb
|
268
|
+
- test/dummy/app/models/continent.rb
|
269
|
+
- test/dummy/app/models/country.rb
|
270
|
+
- test/dummy/app/models/fake.rb
|
259
271
|
- test/dummy/app/models/foo.rb
|
260
272
|
- test/dummy/config/application.rb
|
261
273
|
- test/dummy/config/boot.rb
|
@@ -270,6 +282,9 @@ test_files:
|
|
270
282
|
- test/dummy/config/initializers/session_store.rb
|
271
283
|
- test/dummy/config/routes.rb
|
272
284
|
- test/dummy/db/migrate/20110624115516_create_foos.rb
|
285
|
+
- test/dummy/db/migrate/20110724201117_create_fake_collections.rb
|
286
|
+
- test/dummy/db/migrate/20110724201548_rename_fake_collection_to_fake.rb
|
287
|
+
- test/dummy/db/migrate/20110725082530_create_continent_country_and_city_tables.rb
|
273
288
|
- test/dummy/db/schema.rb
|
274
289
|
- test/judge_test.rb
|
275
290
|
- test/test_helper.rb
|
data/lib/judge/helpers.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
module Judge
|
2
|
-
|
3
|
-
module FieldHelpers
|
4
|
-
|
5
|
-
include ActionView::Helpers::TagHelper
|
6
|
-
|
7
|
-
%w{text_field text_area}.each do |type|
|
8
|
-
helper = <<-END
|
9
|
-
def validated_#{type}(method, options = {})
|
10
|
-
validators = self.object.class.validators_on(method).collect{ |v| { :kind => v.kind.to_s, :options => v.options } }
|
11
|
-
options = { "data-validate" => validators.to_json }.merge(options)
|
12
|
-
@template.#{type}(self.object_name, method, options)
|
13
|
-
end
|
14
|
-
END
|
15
|
-
class_eval helper, __FILE__, __LINE__
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
|
20
|
-
module FormHelpers
|
21
|
-
|
22
|
-
def validated_form_for(record_or_name_or_array, *args, &proc)
|
23
|
-
options = args.extract_options!
|
24
|
-
options[:html] ||= {}
|
25
|
-
options[:html]["data-error-messages"] = I18n.t("errors.messages").to_json
|
26
|
-
form_for(record_or_name_or_array, *(args << options), &proc)
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|