Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-5443

Tests: Ensure alias-related tests cover cases of both "alias_attribute" and "field :as"

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: Tests

      Mongoid has two ways to define field aliases:

      class Band
        include Mongoid::Document
      
        # case 1
        field :n, type: String
        alias_attribute :name, :n
      
        # case 2
        field :a, as: :age
      end
      
      Band.database_field_name(:name) #=> "n"
      Band.database_field_name(:age) #=> "a"
      

      Mongoid has several 100s of tests today which cover field alias related behavior. In most tests, only case 2 (:as) is covered. We should review all tests to ensure that both patterns are covered in all cases.

            Assignee:
            Unassigned Unassigned
            Reporter:
            johnny.shields@gmail.com Johnny Shields
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: