aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/models/referential.rb10
-rw-r--r--spec/models/referential_spec.rb10
2 files changed, 17 insertions, 3 deletions
diff --git a/app/models/referential.rb b/app/models/referential.rb
index 3b770603a..91a88d02d 100644
--- a/app/models/referential.rb
+++ b/app/models/referential.rb
@@ -408,6 +408,7 @@ class Referential < ActiveRecord::Base
end
check_migration_count(report)
+ # raise "Wrong migration count: #{migration_count}" if migration_count < 300
end
end
@@ -417,9 +418,12 @@ class Referential < ActiveRecord::Base
end
def migration_count
- if self.class.connection.table_exists?("#{slug}.schema_migrations")
- self.class.connection.select_value("select count(*) from #{slug}.schema_migrations;")
- end
+ raw_value =
+ if self.class.connection.table_exists?("#{slug}.schema_migrations")
+ self.class.connection.select_value("select count(*) from #{slug}.schema_migrations;")
+ end
+
+ raw_value.to_i
end
def assign_slug(time_reference = Time)
diff --git a/spec/models/referential_spec.rb b/spec/models/referential_spec.rb
index 2d4649b87..025ad80f9 100644
--- a/spec/models/referential_spec.rb
+++ b/spec/models/referential_spec.rb
@@ -43,6 +43,16 @@ describe Referential, :type => :model do
end
end
+ context "schema creation" do
+
+ it "should create a schema named as the slug" do
+ referential = FactoryGirl.create :referential
+ expect(referential.migration_count).to be ActiveRecord::Migrator.get_all_versions.count
+ expect(referential.migration_count).to be > 300
+ end
+
+ end
+
context "Cloning referential" do
let(:clone) do
Referential.new_from(ref, [])