Sha256: 1d9158fb3a94618859b10819eb8c3805fce5496fe9547af8ed6c0fbb73fd8ecf

Contents?: true

Size: 1.05 KB

Versions: 5

Compression:

Stored size: 1.05 KB

Contents

module Remarkable
  module ActiveRecord
    module Matchers
      class AllowMassAssignmentOfMatcher < Remarkable::ActiveRecord::Base #:nodoc:
        arguments :collection => :attributes, :as => :attribute

        collection_assertions :is_protected?, :is_accessible?

        protected

          def is_protected?
            protected = subject_class.protected_attributes || []
            protected.empty? || !protected.include?(@attribute.to_s)
          end

          def is_accessible?
            accessible = subject_class.accessible_attributes || []
            accessible.empty? || accessible.include?(@attribute.to_s)
          end
      end

      # Ensures that the attribute can be set on mass update.
      #
      # == Examples
      #
      #   should_allow_mass_assignment_of :email, :name
      #   it { should allow_mass_assignment_of(:email, :name) }
      #
      def allow_mass_assignment_of(*attributes, &block)
        AllowMassAssignmentOfMatcher.new(*attributes, &block).spec(self)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
remarkable_activerecord-3.0.10 lib/remarkable_activerecord/matchers/allow_mass_assignment_of_matcher.rb
remarkable_activerecord-3.0.9 lib/remarkable_activerecord/matchers/allow_mass_assignment_of_matcher.rb
remarkable_activerecord-3.1.1 lib/remarkable_activerecord/matchers/allow_mass_assignment_of_matcher.rb
remarkable_activerecord-3.1.2 lib/remarkable_activerecord/matchers/allow_mass_assignment_of_matcher.rb
remarkable_activerecord-3.1.0 lib/remarkable_activerecord/matchers/allow_mass_assignment_of_matcher.rb