public
Description: FixtureReplacement rails plugin (version 2 and on)
Homepage: http://replacefixtures.rubyforge.org/
Clone URL: git://github.com/smtlaissezfaire/fixturereplacement.git
* Has and Belongs to many now works
* Forcing database creation
* Changing specs to use real sqlite database, not an in memory one 
  (which will probably be reversed in a following commit)



git-svn-id: http://thmadb.com/public_svn/plugins/fixture_replacement2@316 
6dbbdfbd-06da-443d-8068-b1bdd22a71ef
smt (author)
Sun Feb 17 23:46:16 -0800 2008
commit  ec5aa50443e9cc957c5d978123e69b143c017879
tree    b0eae96d7d028d0fdd6d158f310fce4466b8e801
parent  143b2a236bf2e6a7661a577baf3757e6bde080f5
...
44
45
46
47
48
 
 
 
 
 
 
 
 
 
 
 
 
 
49
50
51
...
44
45
46
 
 
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
0
@@ -44,8 +44,19 @@ module FixtureReplacementController
0
     end
0
 
0
     def assign_values_to_instance instance_object
0
- all_attributes.each do |key, value|
0
- value = find_value_from_delayed_evaluation_proc(value) if value.is_a? DelayedEvaluationProc
0
+ all_attributes.each do |key, value|
0
+ if value.is_a? Array
0
+ value.map! do |element|
0
+ if element.is_a?(DelayedEvaluationProc)
0
+ find_value_from_delayed_evaluation_proc(element)
0
+ else
0
+ element
0
+ end
0
+ end
0
+ elsif value.is_a? DelayedEvaluationProc
0
+ value = find_value_from_delayed_evaluation_proc(value)
0
+ end
0
+
0
         instance_object.__send__("#{key}=", value)
0
       end
0
     end
...
27
28
29
 
 
 
 
 
 
 
30
...
27
28
29
30
31
32
33
34
35
36
37
0
@@ -27,3 +27,10 @@ class Category < ActiveRecord::Base
0
   has_many :items
0
 end
0
 
0
+class Subscriber < ActiveRecord::Base
0
+ has_and_belongs_to_many :subscriptions
0
+end
0
+
0
+class Subscription < ActiveRecord::Base
0
+ has_and_belongs_to_many :subscribers
0
+end
0
\ No newline at end of file
...
25
26
27
28
 
29
30
31
32
 
33
34
35
36
37
38
39
 
40
41
42
43
44
 
45
46
47
48
 
49
50
51
52
 
53
54
55
...
57
58
59
60
 
61
62
63
64
65
66
 
67
68
 
 
 
 
 
 
 
 
 
 
 
 
 
69
70
71
...
25
26
27
 
28
29
30
31
 
32
33
34
35
36
37
38
 
39
40
41
42
43
 
44
45
46
47
 
48
49
50
51
 
52
53
54
55
...
57
58
59
 
60
61
62
63
64
65
 
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
0
@@ -25,31 +25,31 @@ module SpecHelperFunctions
0
     require 'active_record'
0
     require 'active_support'
0
     
0
- ActiveRecord::Base.establish_connection :adapter => 'sqlite3', :database => ':memory:'
0
+ ActiveRecord::Base.establish_connection :adapter => 'sqlite3', :database => 'test.db'
0
     ActiveRecord::Migration.verbose = false
0
 
0
     ActiveRecord::Schema.define do
0
- create_table :users do |t|
0
+ create_table :users, :force => true do |t|
0
         t.column :key, :string
0
         t.column :other_key, :string
0
         t.column :gender_id, :integer
0
         t.column :username, :string
0
       end
0
       
0
- create_table :players do |t|
0
+ create_table :players, :force => true do |t|
0
         t.column :username, :string
0
         t.column :key, :string
0
       end
0
 
0
- create_table :genders do |t|
0
+ create_table :genders, :force => true do |t|
0
         t.column :sex, :string
0
       end
0
 
0
- create_table :aliens do |t|
0
+ create_table :aliens, :force => true do |t|
0
         t.column :gender_id, :string
0
       end
0
 
0
- create_table :admins do |t|
0
+ create_table :admins, :force => true do |t|
0
         t.column :admin_status, :boolean
0
         t.column :name, :string
0
         t.column :username, :string
0
@@ -57,15 +57,28 @@ module SpecHelperFunctions
0
         t.column :other_key, :string
0
       end
0
 
0
- create_table :items do |t|
0
+ create_table :items, :force => true do |t|
0
         t.column :category, :integer
0
         t.column :type, :string
0
         t.column :name, :string
0
       end
0
 
0
- create_table :categories do |t|
0
+ create_table :categories, :force => true do |t|
0
         t.column :name, :string
0
       end
0
+
0
+ create_table :subscribers, :force => true do |t|
0
+ t.column :first_name, :string
0
+ end
0
+
0
+ create_table :subscriptions, :force => true do |t|
0
+ t.column :name, :string
0
+ end
0
+
0
+ create_table :subscribers_subscriptions, :force => true, :id => false do |t|
0
+ t.column :subscriber_id, :integer
0
+ t.column :subscription_id, :integer
0
+ end
0
     end
0
   end
0
 end

Comments

    No one has commented yet.