knockout-rails 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY.md CHANGED
@@ -3,6 +3,10 @@
3
3
  - Support collections (fetch multiple records)
4
4
  - JST templating support
5
5
 
6
+ # 1.0.1 - 23 December 2011
7
+
8
+ - Fix: ensure the validations are executed initially
9
+
6
10
 
7
11
  # 1.0.0 - 22 December 2011
8
12
 
@@ -42,6 +42,9 @@ class ValidationContext
42
42
  me.subject.errors[field](null)
43
43
  , me.subject, "beforeChange" if me._validations[field].isEmpty()
44
44
 
45
+ # Enforce validation right after enabling it
46
+ validatorSubscriber.notifySubscribers( validatorSubscriber(), 'change')
47
+
45
48
  me._validations[field].push validatorSubscriber
46
49
  me
47
50
 
@@ -1,3 +1,3 @@
1
1
  module KnockoutRails
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -20,6 +20,9 @@ describe "Validations", ->
20
20
  beforeEach ->
21
21
  @subject = new Page()
22
22
 
23
+ it "should initially be invalid", ->
24
+ expect(@subject.errors.name()).toBeTruthy()
25
+
23
26
  it "should set error on a field", ->
24
27
  @subject.name ''
25
28
  expect(@subject.errors.name()).toMatch /blank/i
@@ -41,6 +44,27 @@ describe "Validations", ->
41
44
  expect(@subject.errors.multiple()).toBe "xxx, xxx, xxx"
42
45
 
43
46
 
47
+ describe "when re-setting JSON", ->
48
+
49
+ it "should use existing observer", ->
50
+ prevName = @subject.name
51
+ @subject.set name: 'abcdef'
52
+ expect(@subject.name).toBe prevName
53
+
54
+ it "should change the values", ->
55
+ @subject.set name: 'abcdef'
56
+ expect(@subject.name()).toBe 'abcdef'
57
+
58
+ it "should make field valid", ->
59
+ @subject.set name:'a'
60
+ expect( @subject.errors.name() ).toBeFalsy()
61
+
62
+ it "should make field invalid", ->
63
+ @subject.name 'valid'
64
+ @subject.set name:''
65
+ expect( @subject.errors.name() ).toBeTruthy()
66
+
67
+
44
68
 
45
69
  describe "conditional validations", ->
46
70
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knockout-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-22 00:00:00.000000000 Z
12
+ date: 2011-12-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sprockets
16
- requirement: &70321102270000 !ruby/object:Gem::Requirement
16
+ requirement: &70272726273620 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 2.0.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70321102270000
24
+ version_requirements: *70272726273620
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: execjs
27
- requirement: &70321102269360 !ruby/object:Gem::Requirement
27
+ requirement: &70272726272640 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70321102269360
35
+ version_requirements: *70272726272640
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: jquery-rails
38
- requirement: &70321102268420 !ruby/object:Gem::Requirement
38
+ requirement: &70272726271740 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70321102268420
46
+ version_requirements: *70272726271740
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &70321102267680 !ruby/object:Gem::Requirement
49
+ requirement: &70272726271000 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70321102267680
57
+ version_requirements: *70272726271000
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rails
60
- requirement: &70321102266580 !ruby/object:Gem::Requirement
60
+ requirement: &70272726270000 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: 3.1.1
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70321102266580
68
+ version_requirements: *70272726270000
69
69
  description: Include the knockout.js and some of its extensions so you can pick what
70
70
  you need. Adds the support for models and interation with the Rails backend.
71
71
  email:
@@ -156,7 +156,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
156
156
  version: '0'
157
157
  segments:
158
158
  - 0
159
- hash: 3015828595550614504
159
+ hash: -3720006256451223351
160
160
  required_rubygems_version: !ruby/object:Gem::Requirement
161
161
  none: false
162
162
  requirements:
@@ -165,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
165
  version: '0'
166
166
  segments:
167
167
  - 0
168
- hash: 3015828595550614504
168
+ hash: -3720006256451223351
169
169
  requirements: []
170
170
  rubyforge_project: knockout-rails
171
171
  rubygems_version: 1.8.10