assignable_values 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -3,5 +3,3 @@ pkg
3
3
  *.gem
4
4
  .idea
5
5
  spec/*/log/*
6
- Gemfile.lock
7
-
data/Rakefile CHANGED
@@ -23,11 +23,10 @@ namespace :all do
23
23
  end
24
24
  end
25
25
 
26
- desc "Update a gem given by the GEM environment variable"
26
+ desc "Update all gems, or a list of gem given by the GEM environment variable"
27
27
  task :update do
28
- gem = ENV['GEM'] or raise "Name the gem you wish to update by setting a environment variable GEM"
29
28
  for_each_directory_of('spec/**/Gemfile') do |directory|
30
- system("cd #{directory} && bundle update #{gem}")
29
+ system("cd #{directory} && bundle update #{ENV['GEM']}")
31
30
  end
32
31
  end
33
32
 
@@ -39,10 +39,13 @@ module AssignableValues
39
39
 
40
40
  def assignable_values(record, decorate = false)
41
41
  assignable_values = []
42
- old_value = previously_saved_value(record)
43
- assignable_values << old_value if old_value.present?
44
42
  parsed_values = parsed_assignable_values(record)
45
- assignable_values |= parsed_values.delete(:values)
43
+ current_values = parsed_values.delete(:values)
44
+ old_value = previously_saved_value(record)
45
+ if old_value.present? && !current_values.include?(old_value)
46
+ assignable_values << old_value
47
+ end
48
+ assignable_values += current_values
46
49
  parsed_values.each do |meta_name, meta_content|
47
50
  assignable_values.singleton_class.send(:define_method, meta_name) { meta_content }
48
51
  end
@@ -1,3 +1,3 @@
1
1
  module AssignableValues
2
- VERSION = '0.5.1'
2
+ VERSION = '0.5.2'
3
3
  end
@@ -0,0 +1,56 @@
1
+ PATH
2
+ remote: ../..
3
+ specs:
4
+ assignable_values (0.5.1)
5
+ activerecord
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ actionmailer (2.3.10)
11
+ actionpack (= 2.3.10)
12
+ actionpack (2.3.10)
13
+ activesupport (= 2.3.10)
14
+ rack (~> 1.1.0)
15
+ activerecord (2.3.10)
16
+ activesupport (= 2.3.10)
17
+ activeresource (2.3.10)
18
+ activesupport (= 2.3.10)
19
+ activesupport (2.3.10)
20
+ columnize (0.3.6)
21
+ linecache (0.46)
22
+ rbx-require-relative (> 0.0.4)
23
+ rack (1.1.3)
24
+ rails (2.3.10)
25
+ actionmailer (= 2.3.10)
26
+ actionpack (= 2.3.10)
27
+ activerecord (= 2.3.10)
28
+ activeresource (= 2.3.10)
29
+ activesupport (= 2.3.10)
30
+ rake (>= 0.8.3)
31
+ rake (10.0.2)
32
+ rbx-require-relative (0.0.9)
33
+ rspec (1.3.2)
34
+ rspec-rails (1.3.4)
35
+ rack (>= 1.0.0)
36
+ rspec (~> 1.3.1)
37
+ rspec_candy (0.2.1)
38
+ rspec
39
+ ruby-debug (0.10.4)
40
+ columnize (>= 0.1)
41
+ ruby-debug-base (~> 0.10.4.0)
42
+ ruby-debug-base (0.10.4)
43
+ linecache (>= 0.3)
44
+ sqlite3 (1.3.6)
45
+
46
+ PLATFORMS
47
+ ruby
48
+
49
+ DEPENDENCIES
50
+ assignable_values!
51
+ rails (= 2.3.10)
52
+ rspec (< 2)
53
+ rspec-rails (< 2)
54
+ rspec_candy
55
+ ruby-debug
56
+ sqlite3
@@ -0,0 +1,112 @@
1
+ PATH
2
+ remote: ../..
3
+ specs:
4
+ assignable_values (0.5.1)
5
+ activerecord
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ abstract (1.0.0)
11
+ actionmailer (3.0.3)
12
+ actionpack (= 3.0.3)
13
+ mail (~> 2.2.9)
14
+ actionpack (3.0.3)
15
+ activemodel (= 3.0.3)
16
+ activesupport (= 3.0.3)
17
+ builder (~> 2.1.2)
18
+ erubis (~> 2.6.6)
19
+ i18n (~> 0.4)
20
+ rack (~> 1.2.1)
21
+ rack-mount (~> 0.6.13)
22
+ rack-test (~> 0.5.6)
23
+ tzinfo (~> 0.3.23)
24
+ activemodel (3.0.3)
25
+ activesupport (= 3.0.3)
26
+ builder (~> 2.1.2)
27
+ i18n (~> 0.4)
28
+ activerecord (3.0.3)
29
+ activemodel (= 3.0.3)
30
+ activesupport (= 3.0.3)
31
+ arel (~> 2.0.2)
32
+ tzinfo (~> 0.3.23)
33
+ activeresource (3.0.3)
34
+ activemodel (= 3.0.3)
35
+ activesupport (= 3.0.3)
36
+ activesupport (3.0.3)
37
+ arel (2.0.10)
38
+ builder (2.1.2)
39
+ columnize (0.3.6)
40
+ diff-lcs (1.1.3)
41
+ erubis (2.6.6)
42
+ abstract (>= 1.0.0)
43
+ i18n (0.6.1)
44
+ linecache (0.46)
45
+ rbx-require-relative (> 0.0.4)
46
+ mail (2.2.19)
47
+ activesupport (>= 2.3.6)
48
+ i18n (>= 0.4.0)
49
+ mime-types (~> 1.16)
50
+ treetop (~> 1.4.8)
51
+ mime-types (1.19)
52
+ polyglot (0.3.3)
53
+ rack (1.2.5)
54
+ rack-mount (0.6.14)
55
+ rack (>= 1.0.0)
56
+ rack-test (0.5.7)
57
+ rack (>= 1.0)
58
+ rails (3.0.3)
59
+ actionmailer (= 3.0.3)
60
+ actionpack (= 3.0.3)
61
+ activerecord (= 3.0.3)
62
+ activeresource (= 3.0.3)
63
+ activesupport (= 3.0.3)
64
+ bundler (~> 1.0)
65
+ railties (= 3.0.3)
66
+ railties (3.0.3)
67
+ actionpack (= 3.0.3)
68
+ activesupport (= 3.0.3)
69
+ rake (>= 0.8.7)
70
+ thor (~> 0.14.4)
71
+ rake (10.0.2)
72
+ rbx-require-relative (0.0.9)
73
+ rspec (2.12.0)
74
+ rspec-core (~> 2.12.0)
75
+ rspec-expectations (~> 2.12.0)
76
+ rspec-mocks (~> 2.12.0)
77
+ rspec-core (2.12.0)
78
+ rspec-expectations (2.12.0)
79
+ diff-lcs (~> 1.1.3)
80
+ rspec-mocks (2.12.0)
81
+ rspec-rails (2.12.0)
82
+ actionpack (>= 3.0)
83
+ activesupport (>= 3.0)
84
+ railties (>= 3.0)
85
+ rspec-core (~> 2.12.0)
86
+ rspec-expectations (~> 2.12.0)
87
+ rspec-mocks (~> 2.12.0)
88
+ rspec_candy (0.2.1)
89
+ rspec
90
+ ruby-debug (0.10.4)
91
+ columnize (>= 0.1)
92
+ ruby-debug-base (~> 0.10.4.0)
93
+ ruby-debug-base (0.10.4)
94
+ linecache (>= 0.3)
95
+ sqlite3 (1.3.6)
96
+ thor (0.14.6)
97
+ treetop (1.4.12)
98
+ polyglot
99
+ polyglot (>= 0.3.1)
100
+ tzinfo (0.3.35)
101
+
102
+ PLATFORMS
103
+ ruby
104
+
105
+ DEPENDENCIES
106
+ assignable_values!
107
+ rails (= 3.0.3)
108
+ rspec
109
+ rspec-rails
110
+ rspec_candy
111
+ ruby-debug
112
+ sqlite3
@@ -0,0 +1,126 @@
1
+ PATH
2
+ remote: ../..
3
+ specs:
4
+ assignable_values (0.5.1)
5
+ activerecord
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ actionmailer (3.2.9)
11
+ actionpack (= 3.2.9)
12
+ mail (~> 2.4.4)
13
+ actionpack (3.2.9)
14
+ activemodel (= 3.2.9)
15
+ activesupport (= 3.2.9)
16
+ builder (~> 3.0.0)
17
+ erubis (~> 2.7.0)
18
+ journey (~> 1.0.4)
19
+ rack (~> 1.4.0)
20
+ rack-cache (~> 1.2)
21
+ rack-test (~> 0.6.1)
22
+ sprockets (~> 2.2.1)
23
+ activemodel (3.2.9)
24
+ activesupport (= 3.2.9)
25
+ builder (~> 3.0.0)
26
+ activerecord (3.2.9)
27
+ activemodel (= 3.2.9)
28
+ activesupport (= 3.2.9)
29
+ arel (~> 3.0.2)
30
+ tzinfo (~> 0.3.29)
31
+ activeresource (3.2.9)
32
+ activemodel (= 3.2.9)
33
+ activesupport (= 3.2.9)
34
+ activesupport (3.2.9)
35
+ i18n (~> 0.6)
36
+ multi_json (~> 1.0)
37
+ arel (3.0.2)
38
+ builder (3.0.4)
39
+ columnize (0.3.6)
40
+ diff-lcs (1.1.3)
41
+ erubis (2.7.0)
42
+ hike (1.2.1)
43
+ i18n (0.6.1)
44
+ journey (1.0.4)
45
+ json (1.7.5)
46
+ linecache (0.46)
47
+ rbx-require-relative (> 0.0.4)
48
+ mail (2.4.4)
49
+ i18n (>= 0.4.0)
50
+ mime-types (~> 1.16)
51
+ treetop (~> 1.4.8)
52
+ mime-types (1.19)
53
+ multi_json (1.3.7)
54
+ polyglot (0.3.3)
55
+ rack (1.4.1)
56
+ rack-cache (1.2)
57
+ rack (>= 0.4)
58
+ rack-ssl (1.3.2)
59
+ rack
60
+ rack-test (0.6.2)
61
+ rack (>= 1.0)
62
+ rails (3.2.9)
63
+ actionmailer (= 3.2.9)
64
+ actionpack (= 3.2.9)
65
+ activerecord (= 3.2.9)
66
+ activeresource (= 3.2.9)
67
+ activesupport (= 3.2.9)
68
+ bundler (~> 1.0)
69
+ railties (= 3.2.9)
70
+ railties (3.2.9)
71
+ actionpack (= 3.2.9)
72
+ activesupport (= 3.2.9)
73
+ rack-ssl (~> 1.3.2)
74
+ rake (>= 0.8.7)
75
+ rdoc (~> 3.4)
76
+ thor (>= 0.14.6, < 2.0)
77
+ rake (10.0.2)
78
+ rbx-require-relative (0.0.9)
79
+ rdoc (3.12)
80
+ json (~> 1.4)
81
+ rspec (2.12.0)
82
+ rspec-core (~> 2.12.0)
83
+ rspec-expectations (~> 2.12.0)
84
+ rspec-mocks (~> 2.12.0)
85
+ rspec-core (2.12.0)
86
+ rspec-expectations (2.12.0)
87
+ diff-lcs (~> 1.1.3)
88
+ rspec-mocks (2.12.0)
89
+ rspec-rails (2.12.0)
90
+ actionpack (>= 3.0)
91
+ activesupport (>= 3.0)
92
+ railties (>= 3.0)
93
+ rspec-core (~> 2.12.0)
94
+ rspec-expectations (~> 2.12.0)
95
+ rspec-mocks (~> 2.12.0)
96
+ rspec_candy (0.2.1)
97
+ rspec
98
+ ruby-debug (0.10.4)
99
+ columnize (>= 0.1)
100
+ ruby-debug-base (~> 0.10.4.0)
101
+ ruby-debug-base (0.10.4)
102
+ linecache (>= 0.3)
103
+ sprockets (2.2.2)
104
+ hike (~> 1.2)
105
+ multi_json (~> 1.0)
106
+ rack (~> 1.0)
107
+ tilt (~> 1.1, != 1.3.0)
108
+ sqlite3 (1.3.6)
109
+ thor (0.16.0)
110
+ tilt (1.3.3)
111
+ treetop (1.4.12)
112
+ polyglot
113
+ polyglot (>= 0.3.1)
114
+ tzinfo (0.3.35)
115
+
116
+ PLATFORMS
117
+ ruby
118
+
119
+ DEPENDENCIES
120
+ assignable_values!
121
+ rails (~> 3.2)
122
+ rspec
123
+ rspec-rails
124
+ rspec_candy
125
+ ruby-debug
126
+ sqlite3
@@ -366,7 +366,7 @@ describe AssignableValues::ActiveRecord do
366
366
  klass.new.assignable_genres.should == %w[pop rock]
367
367
  end
368
368
 
369
- it 'should include a previously saved value, even if is no longer allowed' do
369
+ it 'should prepend a previously saved value to the top of the list, even if is no longer allowed' do
370
370
  klass = Song.disposable_copy do
371
371
  assignable_values_for :genre do
372
372
  %w[pop rock]
@@ -374,7 +374,17 @@ describe AssignableValues::ActiveRecord do
374
374
  end
375
375
  record = klass.create!(:genre => 'pop')
376
376
  klass.update_all(:genre => 'ballad') # update without validation for the sake of this test
377
- record.reload.assignable_genres.should =~ %w[pop rock ballad]
377
+ record.reload.assignable_genres.should == %w[ballad pop rock]
378
+ end
379
+
380
+ it 'should not prepend a previously saved value to the top of the list if it is still allowed (bugfix)' do
381
+ klass = Song.disposable_copy do
382
+ assignable_values_for :genre do
383
+ %w[pop rock]
384
+ end
385
+ end
386
+ record = klass.create!(:genre => 'rock')
387
+ record.assignable_genres.should == %w[pop rock]
378
388
  end
379
389
 
380
390
  context 'humanization' do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: assignable_values
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 1
10
- version: 0.5.1
9
+ - 2
10
+ version: 0.5.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Henning Koch
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-11-28 00:00:00 +01:00
18
+ date: 2012-12-05 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -114,6 +114,7 @@ files:
114
114
  - lib/assignable_values/humanized_value.rb
115
115
  - lib/assignable_values/version.rb
116
116
  - spec/rails-2.3/Gemfile
117
+ - spec/rails-2.3/Gemfile.lock
117
118
  - spec/rails-2.3/Rakefile
118
119
  - spec/rails-2.3/app_root/config/boot.rb
119
120
  - spec/rails-2.3/app_root/config/database.yml
@@ -129,6 +130,7 @@ files:
129
130
  - spec/rails-2.3/spec_helper.rb
130
131
  - spec/rails-3.0/.rspec
131
132
  - spec/rails-3.0/Gemfile
133
+ - spec/rails-3.0/Gemfile.lock
132
134
  - spec/rails-3.0/Rakefile
133
135
  - spec/rails-3.0/app_root/.gitignore
134
136
  - spec/rails-3.0/app_root/config/application.rb
@@ -149,6 +151,7 @@ files:
149
151
  - spec/rails-3.0/spec_helper.rb
150
152
  - spec/rails-3.2/.rspec
151
153
  - spec/rails-3.2/Gemfile
154
+ - spec/rails-3.2/Gemfile.lock
152
155
  - spec/rails-3.2/Rakefile
153
156
  - spec/rails-3.2/app_root/.gitignore
154
157
  - spec/rails-3.2/app_root/config/application.rb