diff options
| author | Alban Peignier | 2018-02-22 19:18:26 +0100 | 
|---|---|---|
| committer | Alban Peignier | 2018-02-22 19:18:26 +0100 | 
| commit | 02cd9a9e5d05ab9858e6de27e38cd6b56b919d69 (patch) | |
| tree | 2537cfa43a2d1d99008f86bbd7756bb37a772e5e | |
| parent | 81ad0ea87ad2986cbad2a4ba98f2c2be194e0cee (diff) | |
| download | chouette-core-02cd9a9e5d05ab9858e6de27e38cd6b56b919d69.tar.bz2 | |
Add a spec to verify to Referential migration count after creation. Refs #6010
| -rw-r--r-- | app/models/referential.rb | 10 | ||||
| -rw-r--r-- | spec/models/referential_spec.rb | 10 | 
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, []) | 
