Sha256: 26da84f0470398f91b65d1d7439bea74d8498ebde432396331d6caa3a17ca824

Contents?: true

Size: 1.37 KB

Versions: 72

Compression:

Stored size: 1.37 KB

Contents

require 'test_helper'

class RailsOps::Operation::ModelTest < ActiveSupport::TestCase
  include TestHelper

  def test_always_extend_model_class_true
    cls = Class.new(RailsOps::Operation::Model) do
      def self.always_extend_model_class?
        true
      end

      model Group
    end

    refute_equal Group, cls.model
  end

  def test_always_extend_model_class_false
    cls = Class.new(RailsOps::Operation::Model) do
      def self.always_extend_model_class?
        false
      end

      model Group
    end

    assert_equal Group, cls.model
  end

  def test_model_mixins
    cls = Class.new(RailsOps::Operation::Model) do
      def self.always_extend_model_class?
        true
      end

      model Group
    end

    assert cls.model.included_modules.include?(RailsOps::ModelMixins)
  end

  def test_virtual_model_name
    cls = Class.new(RailsOps::Operation::Model) do
      model RailsOps::VirtualModel, 'Example'
    end

    assert_equal 'Example', cls.model.virtual_model_name
  end

  def test_default_model_class
    cls = Class.new(RailsOps::Operation::Model) do
      model do
        attribute :name, :string
      end
    end

    assert cls.model < ActiveType::Object
  end

  def test_no_model_class
    assert_raises_with_message RuntimeError, 'No model class has been set.' do
      Class.new(RailsOps::Operation::Model) do
        model
      end
    end
  end
end

Version data entries

72 entries across 72 versions & 1 rubygems

Version Path
rails_ops-1.4.3 test/unit/rails_ops/operation/model_test.rb
rails_ops-1.4.2 test/unit/rails_ops/operation/model_test.rb
rails_ops-1.0.17.1 test/unit/rails_ops/operation/model_test.rb
rails_ops-1.4.1 test/unit/rails_ops/operation/model_test.rb
rails_ops-1.4.0 test/unit/rails_ops/operation/model_test.rb
rails_ops-1.3.0 test/unit/rails_ops/operation/model_test.rb
rails_ops-1.2.3 test/unit/rails_ops/operation/model_test.rb
rails_ops-1.2.2 test/unit/rails_ops/operation/model_test.rb
rails_ops-1.2.1 test/unit/rails_ops/operation/model_test.rb
rails_ops-1.2.0 test/unit/rails_ops/operation/model_test.rb
rails_ops-1.1.31 test/unit/rails_ops/operation/model_test.rb
rails_ops-1.1.30 test/unit/rails_ops/operation/model_test.rb
rails_ops-1.1.29 test/unit/rails_ops/operation/model_test.rb
rails_ops-1.1.28 test/unit/rails_ops/operation/model_test.rb
rails_ops-1.1.27 test/unit/rails_ops/operation/model_test.rb
rails_ops-1.1.26 test/unit/rails_ops/operation/model_test.rb
rails_ops-1.1.25 test/unit/rails_ops/operation/model_test.rb
rails_ops-1.1.24 test/unit/rails_ops/operation/model_test.rb
rails_ops-1.1.23 test/unit/rails_ops/operation/model_test.rb
rails_ops-1.1.22 test/unit/rails_ops/operation/model_test.rb