Sha256: d65dc68a16fb028903d98a30642cb14f27e2070f00f4ab5a1e80d99491fa5ca7

Contents?: true

Size: 1.39 KB

Versions: 3

Compression:

Stored size: 1.39 KB

Contents

require 'spec_helper'
require 'generators/adminpanel/gallery/gallery_generator'

describe Adminpanel::Generators::GalleryGenerator do
  destination File.expand_path("../../dummy/tmp", __FILE__)

  before do
    Rails::Generators.options[:rails][:orm] = :active_record
  end

  after do
    prepare_destination
  end

  describe 'with "product" as argument' do
    before do
      prepare_destination
      run_generator %w(Product)
    end

    it 'should generate the productfile migration' do
      migration_file('db/migrate/create_adminpanel_productfiles_table.rb').should
        be_a_migration
    end


    it 'should migrate the correct fields' do
      migration_file('db/migrate/create_adminpanel_productfiles_table.rb').should(
        contain(/t.integer :product_id/) &&
        contain(/create_table :adminpanel_productfiles/)
      )
    end

    it 'should generate the productfile model with uploader and attr_accessible' do
      file('app/models/adminpanel/productfile.rb').should(
        contain(/attr_accessible :product_id, :file/) &&
        contain(/mount_uploader :file, ProductfileUploader/)
      )
    end

    it 'should generate the productfile model with uploader and attr_accessible' do
      file('app/models/adminpanel/productfile.rb').should exist
    end

    it 'should the produfile uploader' do
      file('app/uploaders/adminpanel/productfile_uploader.rb').should exist
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
adminpanel-1.2.12 spec/generators/gallery_generator_spec.rb
adminpanel-1.2.11 spec/generators/gallery_generator_spec.rb
adminpanel-1.2.10 spec/generators/gallery_generator_spec.rb