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

Fix error setting when using `become` to change model classes for Rails 6.1 and earlier versions

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 7.2.1, 7.1.7, 7.0.12
    • Affects Version/s: None
    • Component/s: Attributes
    • Labels:
      None
    • Fully Compatible

      Looks like there are some incompatible changes made in rails master for 6.1:

       1) ./spec/mongoid/document_spec.rb[1:27:1:8:1]
      
      Mongoid::Document#becomes when casting to a superclass when the document is invalid copies the errors
      
      RSpec::Expectations::ExpectationNotMetError: expected #<ActiveModel::Errors:0x0000000009a54b10 @base=#<Person _id: 5cc8a89b1a58882e92c65d3d, username: "art...administrated_event_ids: nil, mother_id: nil, _type: "Person", level: 1>, @errors=[], @messages=nil> to include :ssn
      Diff:
      @@ -1,2 +1,6 @@
      -[:ssn]
      +#<ActiveModel::Errors:0x0000000009a54b10
      + @base=
      +  #<Person _id: 5cc8a89b1a58882e92c65d3d, username: "arthurnn6", title: "Sir", terms: nil, pets: false, age: 100, dob: nil, employer_id: nil, lunch_time: nil, aliases: nil, map: nil, map_with_default: {}, score: nil, blood_alcohol_content: 0.0, last_drink_taken_at: 2019-04-29 00:00:00 UTC, ssn: "$$$", owner_id: nil, security_code: nil, reading: nil, bson_id: nil, pattern: nil, override_me: nil, at(aliased_timestamp): nil, t(test): nil, i(inte): nil, a(array): nil, desc: nil, test_array: nil, overridden_setter: nil, arrays: nil, range: nil, species: nil, preference_ids: nil, user_account_ids: nil, house_ids: nil, ordered_preference_ids: nil, administrated_event_ids: nil, mother_id: nil, _type: "Person", level: 1>,
      + @errors=[],
      + @messages=nil>
      

      Since allowing testing against 6.1.0 also makes gemspec compatible with rails 6.0.0 which is not yet released, testing against rails master is temporarily disabled until 6.0.0 is released.

            Assignee:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Reporter:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: