composite_primary_keys 11.3.1 → 12.0.0.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/History.rdoc +17 -7
  3. data/README.rdoc +1 -0
  4. data/lib/composite_primary_keys.rb +1 -6
  5. data/lib/composite_primary_keys/arel/to_sql.rb +13 -13
  6. data/lib/composite_primary_keys/associations/association_scope.rb +4 -4
  7. data/lib/composite_primary_keys/associations/has_many_association.rb +2 -1
  8. data/lib/composite_primary_keys/associations/has_many_through_association.rb +0 -2
  9. data/lib/composite_primary_keys/associations/join_dependency.rb +9 -8
  10. data/lib/composite_primary_keys/associations/preloader/association.rb +28 -36
  11. data/lib/composite_primary_keys/attribute_methods.rb +2 -2
  12. data/lib/composite_primary_keys/attribute_methods/read.rb +11 -14
  13. data/lib/composite_primary_keys/attribute_methods/write.rb +8 -11
  14. data/lib/composite_primary_keys/base.rb +2 -2
  15. data/lib/composite_primary_keys/composite_arrays.rb +7 -50
  16. data/lib/composite_primary_keys/connection_adapters/abstract_adapter.rb +1 -1
  17. data/lib/composite_primary_keys/connection_adapters/postgresql/database_statements.rb +1 -1
  18. data/lib/composite_primary_keys/core.rb +10 -14
  19. data/lib/composite_primary_keys/counter_cache.rb +4 -22
  20. data/lib/composite_primary_keys/fixtures.rb +5 -10
  21. data/lib/composite_primary_keys/nested_attributes.rb +6 -6
  22. data/lib/composite_primary_keys/persistence.rb +8 -8
  23. data/lib/composite_primary_keys/reflection.rb +3 -3
  24. data/lib/composite_primary_keys/relation.rb +39 -27
  25. data/lib/composite_primary_keys/relation/calculations.rb +15 -18
  26. data/lib/composite_primary_keys/relation/finder_methods.rb +56 -58
  27. data/lib/composite_primary_keys/relation/query_methods.rb +4 -3
  28. data/lib/composite_primary_keys/relation/where_clause.rb +2 -2
  29. data/lib/composite_primary_keys/sanitization.rb +37 -37
  30. data/lib/composite_primary_keys/validations/uniqueness.rb +2 -2
  31. data/lib/composite_primary_keys/version.rb +4 -4
  32. data/tasks/databases/mysql.rake +1 -1
  33. data/test/abstract_unit.rb +1 -5
  34. data/test/connections/databases.ci.yml +3 -0
  35. data/test/db_test.rb +53 -0
  36. data/test/fixtures/db_definitions/mysql.sql +1 -7
  37. data/test/fixtures/db_definitions/oracle.drop.sql +1 -3
  38. data/test/fixtures/db_definitions/oracle.sql +0 -8
  39. data/test/fixtures/db_definitions/postgresql.sql +0 -6
  40. data/test/fixtures/db_definitions/sqlite.sql +0 -6
  41. data/test/fixtures/db_definitions/sqlserver.sql +1 -8
  42. data/test/test_associations.rb +1 -1
  43. data/test/test_composite_arrays.rb +0 -14
  44. data/test/test_create.rb +12 -26
  45. data/test/test_find.rb +0 -8
  46. data/test/test_ids.rb +0 -3
  47. data/test/test_nested_attributes.rb +10 -10
  48. data/test/test_update.rb +1 -1
  49. metadata +9 -11
  50. data/lib/composite_primary_keys/connection_adapters/abstract_mysql_adapter.rb +0 -20
  51. data/lib/composite_primary_keys/connection_adapters/sqlite3_adapter.rb +0 -23
  52. data/test/fixtures/cpk_with_default_value.rb +0 -3
  53. data/test/fixtures/cpk_with_default_values.yml +0 -7
@@ -18,7 +18,8 @@ module CompositePrimaryKeys
18
18
  end
19
19
 
20
20
  order_query.flat_map do |o|
21
- case o
21
+ order_query.flat_map do |o|
22
+ case o
22
23
  when Arel::Attribute
23
24
  o.desc
24
25
  when Arel::Nodes::Ordering
@@ -33,10 +34,10 @@ module CompositePrimaryKeys
33
34
  end
34
35
  else
35
36
  o
37
+ end
36
38
  end
37
39
  end
38
40
  end
39
41
  end
40
42
  end
41
- end
42
-
43
+ end
@@ -2,7 +2,7 @@ module ActiveRecord
2
2
  class Relation
3
3
  class WhereClause
4
4
  def to_h(table_name = nil)
5
- equalities = predicates.grep(Arel::Nodes::Equality)
5
+ equalities = equalities(predicates)
6
6
 
7
7
  # CPK Adds this line, because ours are coming in with AND->{EQUALITY, EQUALITY}
8
8
  equalities = predicates.grep(Arel::Nodes::And).map(&:children).flatten.grep(Arel::Nodes::Equality) if equalities.empty?
@@ -21,4 +21,4 @@ module ActiveRecord
21
21
  end
22
22
  end
23
23
  end
24
- end
24
+ end
@@ -1,43 +1,43 @@
1
1
  module ActiveRecord
2
2
  module Sanitization
3
3
  module ClassMethods
4
- def expand_hash_conditions_for_aggregates(attrs)
5
- expanded_attrs = {}
6
- attrs.each do |attr, value|
7
- # CPK
8
- # if aggregation = reflect_on_aggregation(attr.to_sym)
9
- if attr.is_a?(CompositePrimaryKeys::CompositeKeys)
10
- value = value.split('/') if value.is_a?(String)
11
- attr.each_with_index do |key,i|
12
- expanded_attrs[key] = value.respond_to?(:flatten) ? value.flatten[i] : value
13
- end
14
- elsif aggregation = reflect_on_aggregation(attr.to_sym)
15
- mapping = aggregation.mapping
16
- mapping.each do |field_attr, aggregate_attr|
17
- if mapping.size == 1 && !value.respond_to?(aggregate_attr)
18
- expanded_attrs[field_attr] = value
19
- else
20
- expanded_attrs[field_attr] = value.send(aggregate_attr)
21
- end
22
- end
23
- else
24
- expanded_attrs[attr] = value
25
- end
26
- end
27
- expanded_attrs
28
- end
29
-
30
- def quoted_id
31
- # CPK
32
- # self.class.quote_value(@attributes[self.class.primary_key].value_for_database)
33
- if self.composite?
34
- [self.class.primary_keys, ids].transpose.map { |attr_name,id|
35
- self.class.quote_value(@attributes[attr_name].value_for_database)
36
- }
37
- else
38
- self.class.quote_value(@attributes[self.class.primary_key].value_for_database)
39
- end
40
- end
4
+ # def expand_hash_conditions_for_aggregates(attrs)
5
+ # expanded_attrs = {}
6
+ # attrs.each do |attr, value|
7
+ # # CPK
8
+ # # if aggregation = reflect_on_aggregation(attr.to_sym)
9
+ # if attr.is_a?(CompositePrimaryKeys::CompositeKeys)
10
+ # value = value.split('/') if value.is_a?(String)
11
+ # attr.each_with_index do |key,i|
12
+ # expanded_attrs[key] = value.respond_to?(:flatten) ? value.flatten[i] : value
13
+ # end
14
+ # elsif aggregation = reflect_on_aggregation(attr.to_sym)
15
+ # mapping = aggregation.mapping
16
+ # mapping.each do |field_attr, aggregate_attr|
17
+ # if mapping.size == 1 && !value.respond_to?(aggregate_attr)
18
+ # expanded_attrs[field_attr] = value
19
+ # else
20
+ # expanded_attrs[field_attr] = value.send(aggregate_attr)
21
+ # end
22
+ # end
23
+ # else
24
+ # expanded_attrs[attr] = value
25
+ # end
26
+ # end
27
+ # expanded_attrs
28
+ # end
29
+ #
30
+ # def quoted_id
31
+ # # CPK
32
+ # # self.class.quote_value(@attributes[self.class.primary_key].value_for_database)
33
+ # if self.composite?
34
+ # [self.class.primary_keys, ids].transpose.map { |attr_name,id|
35
+ # self.class.quote_value(@attributes[attr_name].value_for_database)
36
+ # }
37
+ # else
38
+ # self.class.quote_value(@attributes[self.class.primary_key].value_for_database)
39
+ # end
40
+ # end
41
41
  end
42
42
  end
43
43
  end
@@ -12,7 +12,7 @@ module ActiveRecord
12
12
  predicate = finder_class.cpk_id_predicate(finder_class.arel_table, finder_class.primary_key, record.id_in_database || record.id)
13
13
  relation = relation.where.not(predicate)
14
14
  elsif finder_class.primary_key
15
- relation = relation.where.not(finder_class.primary_key => record.id_in_database || record.id)
15
+ relation = relation.where.not(finder_class.primary_key => record.id_in_database)
16
16
  else
17
17
  raise UnknownPrimaryKey.new(finder_class, "Can not validate uniqueness for persisted record without primary key.")
18
18
  end
@@ -29,4 +29,4 @@ module ActiveRecord
29
29
  end
30
30
  end
31
31
  end
32
- end
32
+ end
@@ -1,8 +1,8 @@
1
1
  module CompositePrimaryKeys
2
2
  module VERSION
3
- MAJOR = 11
4
- MINOR = 3
5
- TINY = 1
6
- STRING = [MAJOR, MINOR, TINY].join('.')
3
+ MAJOR = 12
4
+ MINOR = 0
5
+ TINY = 0
6
+ STRING = [MAJOR, MINOR, TINY, 'rc1'].join('.')
7
7
  end
8
8
  end
@@ -10,7 +10,7 @@ namespace :mysql do
10
10
  new_spec = spec.dup
11
11
  new_spec.delete('database')
12
12
  connection = ActiveRecord::Base.establish_connection(new_spec)
13
- ActiveRecord::Base.connection.create_database(spec['database'])
13
+ ActiveRecord::Base.connection.create_database(spec['database'], charset: spec['charset'] || 'utf8mb4')
14
14
  ActiveRecord::Base.clear_all_connections!
15
15
  end
16
16
 
@@ -18,12 +18,8 @@ puts "Loaded #{spec_name}"
18
18
  # And now connect to the database
19
19
  ActiveRecord::Base.establish_connection(spec)
20
20
 
21
- if defined?(ActiveRecord::ConnectionAdapters::SQLite3Adapter)
22
- require 'composite_primary_keys/connection_adapters/sqlite3_adapter'
23
- end
24
-
25
21
  # Tell active record about the configuration
26
- ActiveRecord::Base.configurations[:test] = spec
22
+ ActiveRecord::Base.configurations = {test: spec}
27
23
 
28
24
  # Tell ActiveRecord where to find models
29
25
  ActiveSupport::Dependencies.autoload_paths << File.join(PROJECT_ROOT, 'test', 'fixtures')
@@ -2,6 +2,9 @@ mysql:
2
2
  adapter: mysql2
3
3
  username: travis
4
4
  password: ""
5
+ encoding: utf8mb4
6
+ charset: utf8mb4
7
+ collation: utf8mb4_bin
5
8
  database: composite_primary_keys_unittest
6
9
 
7
10
  postgresql:
@@ -0,0 +1,53 @@
1
+ # assoc_test.rb
2
+
3
+ path = File.expand_path(File.join(File.basename(__FILE__), "..", "lib", "composite_primary_keys"))
4
+ puts path
5
+
6
+ require File.join(path)
7
+ require 'active_record'
8
+
9
+ $configuration = {
10
+ :adapter => 'postgresql',
11
+ :database => 'cpk_test',
12
+ :username => 'postgres'
13
+ }
14
+
15
+ ActiveRecord::Base.establish_connection($configuration) unless ActiveRecord::Base.connected?
16
+
17
+ module GlobePG
18
+ class PGBase < ActiveRecord::Base
19
+ self.abstract_class = true
20
+ # establish_connection($configuration) unless connected?
21
+ end
22
+ end
23
+
24
+ module GlobePG
25
+ class TeacherToSchool < PGBase
26
+ set_table_name 'teacher_to_school'
27
+ self.primary_keys = ['teacherid', 'schoolid']
28
+
29
+ belongs_to :globe_teacher, :foreign_key => 'teacherid'
30
+ belongs_to :globe_school, :foreign_key => 'schoolid'
31
+ end
32
+ end
33
+
34
+ module GlobePG
35
+ class GlobeSchool < PGBase
36
+ set_table_name 'globe_school'
37
+ self.primary_key = 'schoolid'
38
+ has_many :teacher_to_schools, :foreign_key => :schoolid
39
+ has_many :globe_teachers, :through => :teacher_to_schools
40
+ end
41
+ end
42
+
43
+ module GlobePG
44
+ class GlobeTeacher < PGBase
45
+ set_table_name 'globe_teacher'
46
+ self.primary_key = 'teacherid'
47
+ has_many :teacher_to_schools, :foreign_key => :teacherid
48
+ has_many :globe_schools, :through => :teacher_to_schools
49
+ end
50
+ end
51
+
52
+ teacher = GlobePG::GlobeTeacher.find_by_teacherid('ZZGLOBEY')
53
+ p teacher.globe_schools
@@ -215,10 +215,4 @@ create table pk_called_ids (
215
215
  abbreviation varchar(50) default null,
216
216
  description varchar(50) default null,
217
217
  primary key (id, reference_code)
218
- );
219
-
220
- create table cpk_with_default_values (
221
- record_id integer not null,
222
- record_version varchar(50) default '' not null,
223
- primary key (record_id, record_version)
224
- );
218
+ );
@@ -45,6 +45,4 @@ drop table capitols;
45
45
  drop table products_restaurants;
46
46
  drop table employees_groups;
47
47
  drop table pk_called_ids;
48
- drop sequence pk_called_ids_seq;
49
- drop table cpk_with_default_values;
50
- drop sequence cpk_with_default_values_seq;
48
+ drop sequence pk_called_ids_seq;
@@ -234,11 +234,3 @@ create table pk_called_ids (
234
234
  description varchar(50) default null,
235
235
  constraint pk_called_ids_pk primary key (id, reference_code)
236
236
  );
237
-
238
- create sequence cpk_with_default_values_seq start with 1000;
239
-
240
- create table cpk_with_default_values (
241
- record_id int not null,
242
- record_version varchar(50) default '' not null,
243
- constraint cpk_with_default_values_pk primary key (record_id, record_version)
244
- );
@@ -218,9 +218,3 @@ create table pk_called_ids (
218
218
  description varchar(50) default null,
219
219
  primary key (id, reference_code)
220
220
  );
221
-
222
- create table cpk_with_default_values (
223
- record_id serial not null,
224
- record_version varchar(50) default '' not null,
225
- primary key (record_id, record_version)
226
- );
@@ -204,9 +204,3 @@ create table pk_called_ids (
204
204
  description varchar(50) default null,
205
205
  primary key (id, reference_code)
206
206
  );
207
-
208
- create table cpk_with_default_values (
209
- record_id integer not null,
210
- record_version varchar(50) default '' not null,
211
- primary key (record_id, record_version)
212
- );
@@ -210,11 +210,4 @@ CREATE TABLE pk_called_ids (
210
210
  description [varchar](50) default null
211
211
  CONSTRAINT [pk_called_ids_pk] PRIMARY KEY
212
212
  ( [id], [reference_code] )
213
- );
214
-
215
- CREATE TABLE cpk_with_default_values (
216
- record_id [int] IDENTITY(1000,1) NOT NULL,
217
- record_version [varchar](50) default '' NOT NULL
218
- CONSTRAINT [cpk_with_default_values_pk] PRIMARY KEY
219
- ( [record_id], [record_version] )
220
- );
213
+ );
@@ -135,7 +135,7 @@ class TestAssociations < ActiveSupport::TestCase
135
135
  assert_equal('Steve', department.employees[0].name)
136
136
  assert_equal('Jill', department.employees[1].name)
137
137
 
138
- head = department.employees.create(name: 'Rick')
138
+ department.employees.create(name: 'Rick')
139
139
 
140
140
  department.reload
141
141
  assert_equal(3, department.employees.count)
@@ -21,18 +21,4 @@ class CompositeArraysTest < ActiveSupport::TestCase
21
21
  assert_equal CompositePrimaryKeys::CompositeKeys, keys.class
22
22
  assert_equal '1,2,3', keys.to_s
23
23
  end
24
-
25
- def test_parse
26
- assert_equal ['1', '2'], CompositePrimaryKeys::CompositeKeys.parse('1,2')
27
- assert_equal ['The USA', '^Washington, D.C.'],
28
- CompositePrimaryKeys::CompositeKeys.parse('The USA,^5EWashington^2C D.C.')
29
- assert_equal ['The USA', '^Washington, D.C.'],
30
- CompositePrimaryKeys::CompositeKeys.parse(['The USA', '^Washington, D.C.'])
31
- end
32
-
33
- def test_to_s
34
- assert_equal '1,2', CompositePrimaryKeys::CompositeKeys.new([1, 2]).to_s
35
- assert_equal 'The USA,^5EWashington^2C D.C.',
36
- CompositePrimaryKeys::CompositeKeys.new(['The USA', '^Washington, D.C.']).to_s
37
- end
38
24
  end
@@ -1,7 +1,7 @@
1
1
  require File.expand_path('../abstract_unit', __FILE__)
2
2
 
3
3
  class TestCreate < ActiveSupport::TestCase
4
- fixtures :articles, :students, :dorms, :rooms, :room_assignments, :reference_types, :reference_codes, :streets, :suburbs, :cpk_with_default_values
4
+ fixtures :articles, :students, :dorms, :rooms, :room_assignments, :reference_types, :reference_codes, :streets, :suburbs
5
5
 
6
6
  CLASSES = {
7
7
  :single => {
@@ -48,16 +48,16 @@ class TestCreate < ActiveSupport::TestCase
48
48
  end
49
49
  end
50
50
 
51
- def test_create_generated_keys
52
- # Not all databases support columns with multiple identity fields
53
- if defined?(ActiveRecord::ConnectionAdapters::PostgreSQL) ||
54
- defined?(ActiveRecord::ConnectionAdapters::SQLite3)
55
-
56
- suburb = Suburb.create!(:name => 'Capitol Hill')
57
- refute_nil(suburb.city_id)
58
- refute_nil(suburb.suburb_id)
59
- end
60
- end
51
+ # def test_create_generated_keys
52
+ # # Not all databases support columns with multiple identity fields
53
+ # if defined?(ActiveRecord::ConnectionAdapters::PostgreSQL) ||
54
+ # defined?(ActiveRecord::ConnectionAdapters::SQLite3)
55
+ #
56
+ # suburb = Suburb.create!(:name => 'Capitol Hill')
57
+ # refute_nil(suburb.city_id)
58
+ # refute_nil(suburb.suburb_id)
59
+ # end
60
+ # end
61
61
 
62
62
  def test_create_on_association
63
63
  suburb = Suburb.first
@@ -167,7 +167,7 @@ class TestCreate < ActiveSupport::TestCase
167
167
 
168
168
  def test_create_article_invalid_id
169
169
  error = assert_raises(ActiveRecord::RecordInvalid) do
170
- article = Article.create!(:id => 1)
170
+ Article.create!(:id => 1)
171
171
  end
172
172
 
173
173
  assert_equal('Validation failed: Id has already been taken', error.to_s)
@@ -180,18 +180,4 @@ class TestCreate < ActiveSupport::TestCase
180
180
  suburb = Suburb.find_or_create_by!(:name => 'New Suburb', :city_id => 3, :suburb_id => 1)
181
181
  refute_nil(suburb)
182
182
  end
183
-
184
- def test_create_when_pk_has_default_value
185
- first = CpkWithDefaultValue.create!
186
- refute_nil(first.record_id)
187
- assert_equal('', first.record_version)
188
-
189
- second = CpkWithDefaultValue.create!(record_id: first.record_id, record_version: 'Same id, different version')
190
- assert_equal(first.record_id, second.record_id)
191
- assert_equal('Same id, different version', second.record_version)
192
-
193
- third = CpkWithDefaultValue.create!(record_version: 'Created by version only')
194
- refute_nil(third.record_id)
195
- assert_equal('Created by version only', third.record_version)
196
- end
197
183
  end
@@ -41,14 +41,6 @@ class TestFind < ActiveSupport::TestCase
41
41
  assert_equal(['The Netherlands', 'Amsterdam'], capitol.id)
42
42
  end
43
43
 
44
- def test_find_with_strings_with_comma_as_composite_keys
45
- capitol = Capitol.create!(country: 'The USA', city: 'Washington, D.C.')
46
- assert_equal ['The USA', 'Washington, D.C.'], capitol.id
47
-
48
- assert_equal capitol, Capitol.find(['The USA', 'Washington, D.C.'])
49
- assert_equal capitol, Capitol.find(capitol.to_param)
50
- end
51
-
52
44
  def test_find_each
53
45
  room_assignments = []
54
46
  RoomAssignment.find_each(:batch_size => 2) do |assignment|
@@ -40,9 +40,6 @@ class TestIds < ActiveSupport::TestCase
40
40
  testing_with do
41
41
  assert_equal '1,1', @first.to_param if composite?
42
42
  end
43
-
44
- capitol = Capitol.create!(country: 'The USA', city: 'Washington, D.C.')
45
- assert_equal 'The USA,Washington^2C D.C.', capitol.to_param
46
43
  end
47
44
 
48
45
  def test_ids_to_s
@@ -8,7 +8,7 @@ class TestNestedAttributes < ActiveSupport::TestCase
8
8
  code_id = 1001
9
9
 
10
10
  reference_type = reference_types(:name_prefix)
11
- reference_type.update_attributes :reference_codes_attributes => [{
11
+ reference_type.update :reference_codes_attributes => [{
12
12
  :reference_code => code_id,
13
13
  :code_label => 'XX',
14
14
  :abbreviation => 'Xx'
@@ -20,7 +20,7 @@ class TestNestedAttributes < ActiveSupport::TestCase
20
20
  code_id = 1002
21
21
 
22
22
  reference_type = reference_types(:name_prefix)
23
- reference_type.update_attributes :reference_codes_attributes => [{
23
+ reference_type.update :reference_codes_attributes => [{
24
24
  :reference_code => code_id,
25
25
  :code_label => 'XX',
26
26
  :abbreviation => 'Xx'
@@ -28,7 +28,7 @@ class TestNestedAttributes < ActiveSupport::TestCase
28
28
 
29
29
  reference_code = ReferenceCode.find_by_reference_code(code_id)
30
30
  cpk = CompositePrimaryKeys::CompositeKeys[reference_type.reference_type_id, code_id]
31
- reference_type.update_attributes :reference_codes_attributes => [{
31
+ reference_type.update :reference_codes_attributes => [{
32
32
  :id => cpk,
33
33
  :code_label => 'AAA',
34
34
  :abbreviation => 'Aaa'
@@ -43,7 +43,7 @@ class TestNestedAttributes < ActiveSupport::TestCase
43
43
  reference_type = reference_types(:gender)
44
44
  reference_code = reference_codes(:gender_male)
45
45
 
46
- reference_type.update_attributes(:reference_codes_attributes => [{:id => reference_code.id,
46
+ reference_type.update(:reference_codes_attributes => [{:id => reference_code.id,
47
47
  :code_label => 'XX',
48
48
  :abbreviation => 'Xx'}])
49
49
 
@@ -56,7 +56,7 @@ class TestNestedAttributes < ActiveSupport::TestCase
56
56
  reference_type = reference_types(:gender)
57
57
  reference_code = reference_codes(:gender_male)
58
58
 
59
- reference_type.update_attributes(:reference_codes_attributes => [{:id => reference_code.id.to_s,
59
+ reference_type.update(:reference_codes_attributes => [{:id => reference_code.id.to_s,
60
60
  :code_label => 'XX',
61
61
  :abbreviation => 'Xx'}])
62
62
 
@@ -71,7 +71,7 @@ class TestNestedAttributes < ActiveSupport::TestCase
71
71
  platform = 'instagram'
72
72
 
73
73
  topic = topics(:music)
74
- topic.update_attributes :topic_sources_attributes => [{
74
+ topic.update :topic_sources_attributes => [{
75
75
  :platform => platform,
76
76
  :keywords => 'funk'
77
77
  }]
@@ -82,7 +82,7 @@ class TestNestedAttributes < ActiveSupport::TestCase
82
82
  platform = 'instagram'
83
83
 
84
84
  topic = topics(:music)
85
- topic.update_attributes :topic_sources_attributes => [{
85
+ topic.update :topic_sources_attributes => [{
86
86
  :platform => platform,
87
87
  :keywords => 'funk'
88
88
  }]
@@ -90,7 +90,7 @@ class TestNestedAttributes < ActiveSupport::TestCase
90
90
 
91
91
  topic_source = TopicSource.find_by_platform(platform)
92
92
  cpk = CompositePrimaryKeys::CompositeKeys[topic.id, platform]
93
- topic.update_attributes :topic_sources_attributes => [{
93
+ topic.update :topic_sources_attributes => [{
94
94
  :id => cpk,
95
95
  :keywords => 'jazz'
96
96
  }]
@@ -104,7 +104,7 @@ class TestNestedAttributes < ActiveSupport::TestCase
104
104
  topic = topics(:music)
105
105
  topic_source = topic_sources(:music_source)
106
106
 
107
- topic.update_attributes(:topic_sources_attributes => [{:id => topic_source.id,
107
+ topic.update(:topic_sources_attributes => [{:id => topic_source.id,
108
108
  :keywords => 'classical, jazz'}])
109
109
 
110
110
  topic_source.reload
@@ -115,7 +115,7 @@ class TestNestedAttributes < ActiveSupport::TestCase
115
115
  topic = topics(:music)
116
116
  topic_source = topic_sources(:music_source)
117
117
 
118
- topic.update_attributes(:topic_sources_attributes => [{:id => topic_source.id.to_s,
118
+ topic.update(:topic_sources_attributes => [{:id => topic_source.id.to_s,
119
119
  :keywords => 'classical, jazz'}])
120
120
 
121
121
  topic_source.reload