I have set up the following models for a contacts directory
class Contact < ActiveRecord::Base
acts_as_citier
end
class Company < Contact
acts_as_citier
end
class Operator < Company
acts_as_citier
end
The thing is that a Contact can be a company and operator is a kind of company with added different attributes.
Since single table inheritance wasnt working for this particular application I decided to use the citier gem.
In the end I have three tables for each model. So when I add a Company object I get two entries made i.e one in Contact with just the name attribuet and the other attributes in the Company table sharing the same id across both tables with the type field of both tables set to Company. If I add an Operator three entires are made i.e one in each table sharing the same id with the Type field of the first two tables set to Operator.
My application works fine apparently, however all of my tests are broken i.e those concerning these models - plus the worst part is that the stack level is too deep as I get the following error message for all broken tests.
Failure/Error: Unable to find matching line from backtrace
SystemStackError:
stack level too deep
# /home/ali/.rvm/gems/ruby-1.9.2-p318/bundler/gems/rails_sql_views-0cf1af369a5f/lib/rails_sql_views/connection_adapters/abstract_adapter.rb:23
I did a check of the rails_sql_views/connection_adapters/abstract_adapter.rb
file atleast for the line number in the above error and it just has this line:
self.class.send(:alias_method, :tables, :original_tables_method)
I'm using a postgresql database here.
Thats around 300 tests all broken with the same message :(
Note all the broken tests are those which involve any kind of change to these models.
I did a bit of fiddling around and ended up changing the git cource of the rails_sql_views gem in my gemfile to read from git://github.com/flwyd/rails_sql_views.git
That got rid of the stack level too deep thing however I'm getting a completely new error - my tests are still failing though - for some reason its treating my views as a table. I'll follow up with a new question on this
---- UPDATE -----
I got it working, I made a few alterations in my spec/spec_helper.rb file and commented out the following two lines:
#config.use_transactional_fixtures = true # because I'm not using fixtures here
#DatabaseCleaner.strategy = :truncation
For some reason Database.strategy
config was giving me issues - this is one of those cases where I fixed it but don't really know how it got fixed. I'll do some reading into it. In the meantime my tests are running fine now!