Sha256: e2f664148c727e7ca8071be08b8c138acd02c44f120b8da1adbe51ce4634c705

Contents?: true

Size: 984 Bytes

Versions: 21

Compression:

Stored size: 984 Bytes

Contents

require "spec_helper"

describe ActsAsAssets::UniqueAsset do
  let(:book) { Book.create!(:title => "my new book") }

  context "creating 2 assets of the same type related to the same resource" do
    context "and asset include the model UniqAsset" do

      it "should fail on the creation of the second asset" do
        Books::Assets::UniqueTestDoc.create! :book => book
        asset2 = Books::Assets::UniqueTestDoc.new :book => book
        asset2.save

        asset2.should_not be_valid
        asset2.should have(1).error_on("Books::Assets::UniqueTestDoc")
      end

    end

    context "and asset does not include the model UniqAsset" do

      it "should fail on the creation of the second asset" do
        asset1 = Books::Assets::TestDoc.create! :book => book
        asset2 = Books::Assets::TestDoc.new :book => book
        asset2.save

        asset2.should be_valid
        asset2.should have(0).error_on("Books::Assets::UniqueTestDoc")
      end

    end

  end

end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
acts_as_assets-0.4.1 spec/unique_asset_spec.rb
acts_as_assets-0.4.0.3 spec/unique_asset_spec.rb
acts_as_assets-0.4.0.2 spec/unique_asset_spec.rb
acts_as_assets-0.4.0.1 spec/unique_asset_spec.rb
acts_as_assets-0.4.0 spec/unique_asset_spec.rb
acts_as_assets-0.3.8 spec/unique_asset_spec.rb
acts_as_assets-0.3.7 spec/unique_asset_spec.rb
acts_as_assets-0.3.6 spec/unique_asset_spec.rb
acts_as_assets-0.3.5 spec/unique_asset_spec.rb
acts_as_assets-0.3.4 spec/unique_asset_spec.rb
acts_as_assets-0.3.3 spec/unique_asset_spec.rb
acts_as_assets-0.3.2 spec/unique_asset_spec.rb
acts_as_assets-0.3.1 spec/unique_asset_spec.rb
acts_as_assets-0.3.0 spec/unique_asset_spec.rb
acts_as_assets-0.2.6 spec/unique_asset_spec.rb
acts_as_assets-0.2.5 spec/unique_asset_spec.rb
acts_as_assets-0.2.4 spec/unique_asset_spec.rb
acts_as_assets-0.2.3 spec/unique_asset_spec.rb
acts_as_assets-0.2.2 spec/unique_asset_spec.rb
acts_as_assets-0.2.1 spec/unique_asset_spec.rb