Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build_stubbed broke when i upgrade to Rails 7.1.3 #1634

Open
dev-Gois opened this issue Apr 4, 2024 · 0 comments
Open

build_stubbed broke when i upgrade to Rails 7.1.3 #1634

dev-Gois opened this issue Apr 4, 2024 · 0 comments
Labels

Comments

@dev-Gois
Copy link

dev-Gois commented Apr 4, 2024

Description

When i try to upgrade to Rails 7.1 from Rails 6.0, i get some errors in my specs, i found for some reason when i use build_stubbed in validations, it don't work properly.

Reproduction Steps

I just runned my specs and for some reason this broke:

  context "validations" do
    it { is_expected.to(validate_presence_of(:product_id)) }

    it "validate uniqueness of product_id" do
      valid_seasonality_item = create(:seasonality_item)
      invalid_seasonality_item = build_stubbed(:seasonality_item,
        product: valid_seasonality_item.product,
        seasonality: valid_seasonality_item.seasonality,
      )
      invalid_seasonality_item.valid?
      expect(invalid_seasonality_item.errors&.first&.attribute).to(eq(:product_id))
    end
  end

idk, for some reason this dont work, is expected to the invalid_seasonality_item to be invalid, but, its valid in this tests, so, i just changed the build_stubbed for build and thats works

Expected behavior

I want some response about what happened with build_stubbed and a solution for that

Actual behavior

At the moment, my specs with build_stubbed are broke.

System configuration

factory_bot version: "factory_bot_rails", "~> 6.4.0"
rails version: "rails", "~> 7.1.3"
ruby version: ruby 3.3.0

@dev-Gois dev-Gois added the bug label Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant