Commit 0346bd588d683ba891e2cf8c260302c0fd8a6ab4
1 parent
fe697067
Exists in
staging
and in
39 other branches
rails4: migrate set_table_name
Showing
21 changed files
with
83 additions
and
80 deletions
Show diff stats
app/models/article_categorization.rb
app/models/profile_categorization.rb
db/migrate/059_add_birth_date_to_person.rb
db/migrate/069_add_enviroment_id_to_role.rb
plugins/comment_classification/lib/comment_classification_plugin/comment_label_user.rb
plugins/comment_classification/lib/comment_classification_plugin/comment_status_user.rb
plugins/custom_forms/db/migrate/20130823151900_associate_fields_to_alternatives.rb
1 | 1 | class AssociateFieldsToAlternatives < ActiveRecord::Migration |
2 | 2 | class CustomFormsPlugin::Field < ActiveRecord::Base |
3 | - set_table_name :custom_forms_plugin_fields | |
3 | + self.table_name = :custom_forms_plugin_fields | |
4 | 4 | has_many :alternatives, :class_name => 'CustomFormsPlugin::Alternative' |
5 | 5 | serialize :choices, Hash |
6 | 6 | end | ... | ... |
plugins/custom_forms/lib/custom_forms_plugin/alternative.rb
plugins/custom_forms/lib/custom_forms_plugin/answer.rb
1 | 1 | class CustomFormsPlugin::Answer < ActiveRecord::Base |
2 | - set_table_name :custom_forms_plugin_answers | |
2 | + self.table_name = :custom_forms_plugin_answers | |
3 | 3 | belongs_to :field, :class_name => 'CustomFormsPlugin::Field' |
4 | 4 | belongs_to :submission, :class_name => 'CustomFormsPlugin::Submission' |
5 | 5 | ... | ... |
plugins/custom_forms/lib/custom_forms_plugin/field.rb
plugins/custom_forms/lib/custom_forms_plugin/numeric.rb
plugins/custom_forms/lib/custom_forms_plugin/select_field.rb
1 | 1 | class CustomFormsPlugin::SelectField < CustomFormsPlugin::Field |
2 | - set_table_name :custom_forms_plugin_fields | |
2 | + self.table_name = :custom_forms_plugin_fields | |
3 | 3 | validates_inclusion_of :select_field_type, :in => %w(radio check_box select multiple_select) |
4 | 4 | validates_length_of :alternatives, :minimum => 1, :message => 'can\'t be empty' |
5 | 5 | end | ... | ... |
plugins/custom_forms/lib/custom_forms_plugin/text_field.rb
plugins/mark_comment_as_read/lib/mark_comment_as_read_plugin/read_comments.rb
plugins/stoa/lib/stoa_plugin/usp_user.rb
vendor/ezcrypto/test/active_crypto_test.rb
... | ... | @@ -24,7 +24,7 @@ end |
24 | 24 | class Asset<ActiveRecord::Base |
25 | 25 | encrypt :title, :base64=>true |
26 | 26 | has_many :caps,:dependent=>:destroy |
27 | - | |
27 | + | |
28 | 28 | def self.create(title,email) |
29 | 29 | asset=Asset.new |
30 | 30 | asset.set_session_key(EzCrypto::Key.generate) |
... | ... | @@ -39,17 +39,17 @@ class Asset<ActiveRecord::Base |
39 | 39 | def share(email=nil) |
40 | 40 | Cap.create_for_asset(self,email) |
41 | 41 | end |
42 | - | |
42 | + | |
43 | 43 | end |
44 | 44 | |
45 | 45 | class AssetRaw<ActiveRecord::Base |
46 | - set_table_name "assets" | |
46 | + self.table_name = "assets" | |
47 | 47 | end |
48 | 48 | |
49 | 49 | class Cap < ActiveRecord::Base |
50 | 50 | belongs_to :asset |
51 | 51 | encrypt :shared_key, :base64=>true |
52 | - | |
52 | + | |
53 | 53 | def self.find_by_key(cap_key) |
54 | 54 | cap_key.chop |
55 | 55 | hash=Digest::SHA1.hexdigest(cap_key) |
... | ... | @@ -64,7 +64,7 @@ class Cap < ActiveRecord::Base |
64 | 64 | nil |
65 | 65 | end |
66 | 66 | end |
67 | - | |
67 | + | |
68 | 68 | def self.create_for_asset(asset,email=nil) |
69 | 69 | cap=Cap.new |
70 | 70 | cap.email=email if email |
... | ... | @@ -80,28 +80,28 @@ class Cap < ActiveRecord::Base |
80 | 80 | nil |
81 | 81 | end |
82 | 82 | end |
83 | - | |
83 | + | |
84 | 84 | end |
85 | 85 | |
86 | 86 | class Group < ActiveRecord::Base |
87 | 87 | belongs_to :user |
88 | 88 | has_many :group_secrets |
89 | - | |
89 | + | |
90 | 90 | encrypt :name,:group_key, :key=>:user , :base64=>true |
91 | 91 | end |
92 | 92 | |
93 | 93 | class GroupSecret < ActiveRecord::Base |
94 | 94 | belongs_to :group |
95 | - | |
95 | + | |
96 | 96 | encrypt :title,:body, :key=>:group, :base64=>true |
97 | - | |
97 | + | |
98 | 98 | end |
99 | 99 | |
100 | 100 | class ActiveCryptoTest < Test::Unit::TestCase |
101 | - | |
101 | + | |
102 | 102 | def setup |
103 | 103 | end |
104 | - | |
104 | + | |
105 | 105 | def test_key_holder_in_record |
106 | 106 | user=User.new |
107 | 107 | user.name="bob" |
... | ... | @@ -112,9 +112,9 @@ class ActiveCryptoTest < Test::Unit::TestCase |
112 | 112 | assert_nil user.session_key |
113 | 113 | user.enter_password "shhcccc" |
114 | 114 | assert_not_nil user.session_key |
115 | - assert_not_nil user.session_key.encrypt("test") | |
115 | + assert_not_nil user.session_key.encrypt("test") | |
116 | 116 | end |
117 | - | |
117 | + | |
118 | 118 | def test_encrypted_child |
119 | 119 | user=User.new |
120 | 120 | user.save |
... | ... | @@ -124,22 +124,22 @@ class ActiveCryptoTest < Test::Unit::TestCase |
124 | 124 | assert user.kind_of?(ActiveCrypto::KeyHolder) |
125 | 125 | assert user.kind_of?(ActiveRecord::Base) |
126 | 126 | assert user.kind_of?(User) |
127 | - | |
127 | + | |
128 | 128 | jill=user.secrets.create |
129 | - | |
129 | + | |
130 | 130 | assert_not_nil jill |
131 | 131 | assert jill.kind_of?(ActiveCrypto::AssociationKeyHolder) |
132 | 132 | assert jill.kind_of?(ActiveCrypto::KeyHolder) |
133 | 133 | assert jill.kind_of?(ActiveCrypto::Encrypted) |
134 | 134 | assert jill.kind_of?(ActiveRecord::Base) |
135 | 135 | assert jill.kind_of?(Secret) |
136 | - | |
136 | + | |
137 | 137 | assert jill.respond_to?(:session_key) |
138 | - | |
138 | + | |
139 | 139 | assert_not_nil jill.user |
140 | 140 | assert_not_nil jill.user.session_key |
141 | - | |
142 | - | |
141 | + | |
142 | + | |
143 | 143 | assert_not_nil jill.session_key |
144 | 144 | assert_equal user.session_key,jill.session_key |
145 | 145 | |
... | ... | @@ -148,12 +148,12 @@ class ActiveCryptoTest < Test::Unit::TestCase |
148 | 148 | |
149 | 149 | |
150 | 150 | assert_equal "jill",jill.name |
151 | - | |
151 | + | |
152 | 152 | jill=user.secrets.first |
153 | 153 | assert_not_nil jill.session_key |
154 | 154 | assert_equal user.session_key,jill.session_key |
155 | 155 | assert_equal "jill",jill.name |
156 | - | |
156 | + | |
157 | 157 | child=jill.children.create |
158 | 158 | child.email="pelle@neubia.com" |
159 | 159 | child.save |
... | ... | @@ -186,20 +186,20 @@ class ActiveCryptoTest < Test::Unit::TestCase |
186 | 186 | cap=Cap.find_by_key key |
187 | 187 | assert_not_nil cap |
188 | 188 | assert_not_nil cap.asset |
189 | - | |
189 | + | |
190 | 190 | assert_equal "title",cap.asset.title |
191 | 191 | assert_equal "title",cap.asset["title"] |
192 | 192 | assert_equal "pelle@neubia.com",cap.email |
193 | 193 | assert_equal "pelle@neubia.com",cap["email"] |
194 | - | |
194 | + | |
195 | 195 | # Non decrypting version |
196 | 196 | raw=AssetRaw.find cap.asset.id |
197 | 197 | assert_not_equal "title",raw.title |
198 | 198 | assert_not_equal "title",raw["title"] |
199 | - | |
199 | + | |
200 | 200 | bob_key=cap.asset.share("bob@bob.com") |
201 | 201 | bob_cap=Cap.find_by_key bob_key |
202 | - | |
202 | + | |
203 | 203 | assert_not_equal key,bob_key |
204 | 204 | assert_not_nil bob_cap |
205 | 205 | assert_not_nil bob_cap.asset | ... | ... |
vendor/ezcrypto/test/encrypt_test.rb
1 | 1 | require 'association_key_holder_test' |
2 | 2 | |
3 | 3 | class EncUser < ActiveRecord::Base |
4 | - set_table_name "users" | |
4 | + self.table_name = "users" | |
5 | 5 | encrypt :name, :base64=>true |
6 | 6 | end |
7 | 7 | |
8 | 8 | class RawUser < ActiveRecord::Base |
9 | - set_table_name "users" | |
9 | + self.table_name = "users" | |
10 | 10 | end |
11 | 11 | |
12 | 12 | class EncryptTest < AssociationKeyHolderTest |
13 | 13 | def setup |
14 | - @key_holder=EncUser.create | |
14 | + @key_holder=EncUser.create | |
15 | 15 | end |
16 | - | |
16 | + | |
17 | 17 | def test_should_be_base64 |
18 | 18 | assert EncUser.ezcrypto_base64? |
19 | 19 | end |
20 | - | |
20 | + | |
21 | 21 | def test_should_retain_session_key_on_reload |
22 | 22 | key=EzCrypto::Key.generate |
23 | 23 | key_holder.set_session_key key |
24 | 24 | assert_not_nil key_holder.session_key |
25 | 25 | assert_equal key.raw,key_holder.session_key.raw |
26 | - | |
26 | + | |
27 | 27 | key_holder.name="bob" |
28 | 28 | key_holder.save |
29 | - | |
29 | + | |
30 | 30 | assert_equal "bob",key_holder.name |
31 | - | |
31 | + | |
32 | 32 | found=EncUser.find key_holder.id |
33 | 33 | assert_equal key_holder.name,found.name |
34 | - | |
34 | + | |
35 | 35 | raw=RawUser.find key_holder.id |
36 | 36 | assert_not_nil raw.name |
37 | 37 | assert_not_equal key_holder.name,raw.name |
38 | - | |
38 | + | |
39 | 39 | end |
40 | - | |
40 | + | |
41 | 41 | end | ... | ... |
vendor/plugins/access_control/test/test_helper.rb
1 | 1 | ENV["RAILS_ENV"] = "test" |
2 | 2 | require File.expand_path(File.dirname(__FILE__) + "/../../../../config/environment") |
3 | - | |
3 | + | |
4 | 4 | require 'test/unit' |
5 | 5 | require 'mocha' |
6 | 6 | |
... | ... | @@ -11,12 +11,12 @@ require 'rails/test_help' |
11 | 11 | ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log") |
12 | 12 | load(File.dirname(__FILE__) + '/schema.rb') |
13 | 13 | # change the table names for the tests to not touch |
14 | -Role.set_table_name 'access_control_test_roles' | |
15 | -RoleAssignment.set_table_name 'access_control_test_role_assignments' | |
14 | +Role.table_name = 'access_control_test_roles' | |
15 | +RoleAssignment.table_name = 'access_control_test_role_assignments' | |
16 | 16 | |
17 | 17 | # accessor example class to access some resources |
18 | 18 | class AccessControlTestAccessor < ActiveRecord::Base |
19 | - set_table_name 'access_control_test_accessors' | |
19 | + self.table_name = 'access_control_test_accessors' | |
20 | 20 | acts_as_accessor |
21 | 21 | attr_accessible :name |
22 | 22 | def cache_keys(arg) |
... | ... | @@ -29,8 +29,8 @@ end |
29 | 29 | |
30 | 30 | # resource example class to be accessed by some accessor |
31 | 31 | class AccessControlTestResource < ActiveRecord::Base |
32 | - set_table_name 'access_control_test_resources' | |
33 | - acts_as_accessible | |
32 | + self.table_name = 'access_control_test_resources' | |
33 | + acts_as_accessible | |
34 | 34 | PERMISSIONS[self.class.name] = {'bla' => N_('Bla')} |
35 | 35 | |
36 | 36 | attr_accessible :name | ... | ... |
vendor/plugins/action_tracker/test/action_tracker_model_test.rb
... | ... | @@ -19,7 +19,7 @@ ActiveRecord::Schema.define do |
19 | 19 | end |
20 | 20 | |
21 | 21 | class SomeModel < ActiveRecord::Base |
22 | - set_table_name :some_table | |
22 | + self.table_name = :some_table | |
23 | 23 | acts_as_trackable |
24 | 24 | end |
25 | 25 | |
... | ... | @@ -37,7 +37,7 @@ class ActionTrackerModelTest < ActiveSupport::TestCase |
37 | 37 | end |
38 | 38 | |
39 | 39 | def test_params_is_a_hash |
40 | - assert_kind_of Hash, @tracked_action.params | |
40 | + assert_kind_of Hash, @tracked_action.params | |
41 | 41 | end |
42 | 42 | |
43 | 43 | def test_has_a_polymorphic_relation_with_user |
... | ... | @@ -57,7 +57,7 @@ class ActionTrackerModelTest < ActiveSupport::TestCase |
57 | 57 | ta = ActionTracker::Record.create! :user => SomeModel.create!, :verb => :some_verb |
58 | 58 | assert_equal "some_verb", ta.verb |
59 | 59 | end |
60 | - | |
60 | + | |
61 | 61 | def test_verb_is_mandatory |
62 | 62 | ta = ActionTracker::Record.new |
63 | 63 | ta.valid? | ... | ... |
vendor/plugins/action_tracker/test/action_tracker_test.rb
... | ... | @@ -23,12 +23,12 @@ ActiveRecord::Schema.define do |
23 | 23 | end |
24 | 24 | |
25 | 25 | class SomeModel < ActiveRecord::Base |
26 | - set_table_name :some_table | |
26 | + self.table_name = :some_table | |
27 | 27 | acts_as_trackable |
28 | 28 | end |
29 | 29 | |
30 | 30 | class OtherModel < ActiveRecord::Base |
31 | - set_table_name :other_table | |
31 | + self.table_name = :other_table | |
32 | 32 | acts_as_trackable |
33 | 33 | end |
34 | 34 | |
... | ... | @@ -108,7 +108,7 @@ class ActionTrackerTest < ActiveSupport::TestCase |
108 | 108 | end |
109 | 109 | |
110 | 110 | def test_track_actions_executes_block |
111 | - @controller = create_controller do | |
111 | + @controller = create_controller do | |
112 | 112 | track_actions :some_verb do |
113 | 113 | throw :some_symbol |
114 | 114 | end |
... | ... | @@ -162,7 +162,7 @@ class ActionTrackerTest < ActiveSupport::TestCase |
162 | 162 | assert_difference 'ActionTracker::Record.count' do |
163 | 163 | get :index, :foo => 5 |
164 | 164 | end |
165 | - assert_equal({"action"=>"index", "foo"=>"5", "controller"=>"things"}, ActionTracker::Record.first.params) | |
165 | + assert_equal({"action"=>"index", "foo"=>"5", "controller"=>"things"}, ActionTracker::Record.first.params) | |
166 | 166 | end |
167 | 167 | |
168 | 168 | def test_keep_params_not_set_should_store_all_params |
... | ... | @@ -237,7 +237,7 @@ class ActionTrackerTest < ActiveSupport::TestCase |
237 | 237 | end |
238 | 238 | assert_equal "test", ActionTracker::Record.last.user.some_column |
239 | 239 | end |
240 | - | |
240 | + | |
241 | 241 | def test_should_update_when_verb_is_updatable_and_no_timeout |
242 | 242 | ActionTrackerConfig.verbs = { :some_verb => { :description => "Did something", :type => :updatable } } |
243 | 243 | ActionTrackerConfig.timeout = 5.minutes |
... | ... | @@ -252,7 +252,7 @@ class ActionTrackerTest < ActiveSupport::TestCase |
252 | 252 | assert_no_difference 'ActionTracker::Record.count' do |
253 | 253 | get :test |
254 | 254 | end |
255 | - end | |
255 | + end | |
256 | 256 | |
257 | 257 | def test_should_create_when_verb_is_updatable_and_timeout |
258 | 258 | ActionTrackerConfig.verbs = { :some_verb => { :description => "Did something", :type => :updatable } } |
... | ... | @@ -268,7 +268,7 @@ class ActionTrackerTest < ActiveSupport::TestCase |
268 | 268 | assert_difference 'ActionTracker::Record.count' do |
269 | 269 | get :test |
270 | 270 | end |
271 | - end | |
271 | + end | |
272 | 272 | |
273 | 273 | def test_should_update_when_verb_is_groupable_and_no_timeout |
274 | 274 | ActionTrackerConfig.verbs = { :some_verb => { :description => "Did something", :type => :groupable } } |
... | ... | @@ -284,7 +284,7 @@ class ActionTrackerTest < ActiveSupport::TestCase |
284 | 284 | assert_no_difference 'ActionTracker::Record.count' do |
285 | 285 | get :test, :foo => "test" |
286 | 286 | end |
287 | - end | |
287 | + end | |
288 | 288 | |
289 | 289 | def test_should_create_when_verb_is_groupable_and_timeout |
290 | 290 | ActionTrackerConfig.verbs = { :some_verb => { :description => "Did something", :type => :groupable } } |
... | ... | @@ -330,7 +330,7 @@ class ActionTrackerTest < ActiveSupport::TestCase |
330 | 330 | def test_should_get_time_spent_doing_something |
331 | 331 | ActionTrackerConfig.verbs = { :some_verb => { :type => :updatable }, :other_verb => { :type => :updatable } } |
332 | 332 | m = SomeModel.create! |
333 | - @controller = create_controller do | |
333 | + @controller = create_controller do | |
334 | 334 | track_actions :some_verb |
335 | 335 | end |
336 | 336 | @controller.stubs(:current_user).returns(m) |
... | ... | @@ -394,7 +394,7 @@ class ActionTrackerTest < ActiveSupport::TestCase |
394 | 394 | assert_equal "foo", ActionTracker::Record.last.params["other_column"] |
395 | 395 | assert_nil ActionTracker::Record.last.params["another_column"] |
396 | 396 | end |
397 | - | |
397 | + | |
398 | 398 | def test_replace_dots_by_underline_in_param_name |
399 | 399 | ActionTrackerConfig.verbs = { :test => { :description => "Some" } } |
400 | 400 | model = create_model do |
... | ... | @@ -407,7 +407,7 @@ class ActionTrackerTest < ActiveSupport::TestCase |
407 | 407 | assert_equal 3, ActionTracker::Record.last.params["other_column_size"] |
408 | 408 | assert_equal 5, ActionTracker::Record.last.params["another_column"] |
409 | 409 | end |
410 | - | |
410 | + | |
411 | 411 | def test_track_actions_store_all_params |
412 | 412 | ActionTrackerConfig.verbs = { :test => { :description => "Some" } } |
413 | 413 | model = create_model do |
... | ... | @@ -452,7 +452,7 @@ class ActionTrackerTest < ActiveSupport::TestCase |
452 | 452 | model = create_model { track_actions :test, :after_create, :keep_params => :all, :if => Proc.new { 2 > 1 } } |
453 | 453 | @controller = create_controller_for_model(model) |
454 | 454 | assert_difference('ActionTracker::Record.count') { get :test } |
455 | - | |
455 | + | |
456 | 456 | model = create_model { track_actions :test, :after_create, :keep_params => :all, :if => Proc.new { 2 < 1 } } |
457 | 457 | @controller = create_controller_for_model(model) |
458 | 458 | assert_no_difference('ActionTracker::Record.count') { get :test } |
... | ... | @@ -460,7 +460,7 @@ class ActionTrackerTest < ActiveSupport::TestCase |
460 | 460 | model = create_model { track_actions :test, :after_create, :keep_params => :all, :unless => Proc.new { 2 > 1 } } |
461 | 461 | @controller = create_controller_for_model(model) |
462 | 462 | assert_no_difference('ActionTracker::Record.count') { get :test } |
463 | - | |
463 | + | |
464 | 464 | model = create_model { track_actions :test, :after_create, :keep_params => :all, :unless => Proc.new { 2 < 1 } } |
465 | 465 | @controller = create_controller_for_model(model) |
466 | 466 | assert_difference('ActionTracker::Record.count') { get :test } | ... | ... |
vendor/plugins/validates_as_cnpj/test/cnpj_test.rb
... | ... | @@ -4,7 +4,7 @@ require '../lib/validates_as_cnpj' |
4 | 4 | |
5 | 5 | # Modelo |
6 | 6 | class CNPJData < ActiveRecord::Base |
7 | - set_table_name "cnpjs" | |
7 | + self.table_name = "cnpjs" | |
8 | 8 | |
9 | 9 | validates_as_cnpj :cnpj |
10 | 10 | end |
... | ... | @@ -16,37 +16,37 @@ class CNPJsTest < Test::Unit::TestCase |
16 | 16 | |
17 | 17 | assert cnpj_valido.save, "Nao salvou CNPJ nulo." |
18 | 18 | end |
19 | - | |
19 | + | |
20 | 20 | def test_aceita_cnpj_vazio_por_que_deve_ser_barrado_por_validates_presence_of |
21 | 21 | cnpj_valido = CNPJData.new(:id => 1, :cnpj => "") |
22 | 22 | |
23 | 23 | assert cnpj_valido.save, "Nao salvou CNPJ vazio." |
24 | 24 | end |
25 | - | |
25 | + | |
26 | 26 | def test_cnpj_incompleto |
27 | 27 | cnpj_invalido = CNPJData.new(:id => 1, :cnpj => "123") |
28 | 28 | |
29 | 29 | assert ( not cnpj_invalido.save ), "Salvou CNPJ incompleto." |
30 | 30 | end |
31 | - | |
31 | + | |
32 | 32 | def test_cnpj_invalido_sem_pontuacao |
33 | 33 | cnpj_invalido = CNPJData.new(:id => 1, :cnpj => "00000000000000") |
34 | 34 | |
35 | 35 | assert ( not cnpj_invalido.save ), "Salvou CNPJ invalido." |
36 | 36 | end |
37 | - | |
37 | + | |
38 | 38 | def test_cnpj_valido_sem_pontuacao |
39 | 39 | cnpj_valido = CNPJData.new(:id => 1, :cnpj => "04613251000100") |
40 | 40 | |
41 | 41 | assert cnpj_valido.save, "Nao salvou CNPJ valido." |
42 | 42 | end |
43 | - | |
43 | + | |
44 | 44 | def test_cnpj_invalido_sem_pontuacao_com_digitos_verificadores_invertidos |
45 | 45 | cnpj_invalido = CNPJData.new(:id => 1, :cnpj => "10002574000125") |
46 | 46 | |
47 | 47 | assert ( not cnpj_invalido.save ), "Salvou CNPJ invalido." |
48 | 48 | end |
49 | - | |
49 | + | |
50 | 50 | def test_cnpj_invalido_com_pontuacao |
51 | 51 | cnpj_invalido = CNPJData.new(:id => 1, :cnpj => "51.357.999/1110-98") |
52 | 52 | ... | ... |