Sha256: 7aa64ca3c9267f533eb902df1940eba5e20e47d7defc3fbeb8fdac3dd99ae645

Contents?: true

Size: 1.03 KB

Versions: 7

Compression:

Stored size: 1.03 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)
        AllowMassAssignmentOfMatcher.new(*attributes).spec(self)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
remarkable_activerecord-3.0.2 lib/remarkable_activerecord/matchers/allow_mass_assignment_of_matcher.rb
remarkable_activerecord-3.0.4 lib/remarkable_activerecord/matchers/allow_mass_assignment_of_matcher.rb
remarkable_activerecord-3.0.6 lib/remarkable_activerecord/matchers/allow_mass_assignment_of_matcher.rb
remarkable_activerecord-3.0.3 lib/remarkable_activerecord/matchers/allow_mass_assignment_of_matcher.rb
remarkable_activerecord-3.0.5 lib/remarkable_activerecord/matchers/allow_mass_assignment_of_matcher.rb
remarkable_activerecord-3.0.7 lib/remarkable_activerecord/matchers/allow_mass_assignment_of_matcher.rb
remarkable_activerecord-3.0.8 lib/remarkable_activerecord/matchers/allow_mass_assignment_of_matcher.rb