Commit 9917c631cdd26318b461b5d13d8a056e86e2cf18

Authored by Rodrigo Souto
1 parent 0db12ddd

Making sti work with namespaced models

config/environment.rb
... ... @@ -106,7 +106,7 @@ end
106 106  
107 107 # Include your application configuration below
108 108  
109   -
  109 +ActiveRecord::Base.store_full_sti_class = true
110 110  
111 111 Noosfero.locales = {
112 112 'en' => 'English',
... ...
test/unit/environment_test.rb
... ... @@ -1140,4 +1140,21 @@ class EnvironmentTest < Test::Unit::TestCase
1140 1140 end
1141 1141 end
1142 1142  
  1143 + should 'not conflict to save classes with namespace on sti' do
  1144 + class School; end;
  1145 + class Work; end;
  1146 + class School::Project < Article; end
  1147 + class Work::Project < Article; end
  1148 +
  1149 + title1 = "Sample Article1"
  1150 + title2 = "Sample Article2"
  1151 + profile = fast_create(Profile)
  1152 +
  1153 + p1 = School::Project.new(:name => title1, :profile => profile)
  1154 + p2 = Work::Project.new(:name => title2, :profile => profile)
  1155 +
  1156 + p1.save!
  1157 + p2.save!
  1158 + end
  1159 +
1143 1160 end
... ...