0

ネストされた要素を持ち、別のクラスと HMABT 関係を持つクラスを作成しようとしています。ここに私のクラスがあります

class Quote

  has_and_belongs_to_many :providers
  belongs_to :user 

class Provider

  has_and_belongs_to_many :quotes 
  belongs_to :user
  embeds_many :workdones


class Workdone
  embedded_in :provider  
  embeds_many :prices

class Price
  embedded_in :workdone

これらは私の製作者です

Fabricator(:price) do 
  workdone
  variation_id {Fabricate(:variation)._id}
  price {12}
  discount {5} 
end 

usern = Faker::Name.last_name
uidn = Faker::Number.number(10) 
Fabricator(:user) do
    uid 123456
    username {usern }
    email {Faker::Internet.email}
    username_or_uid { [ usern , uidn] }
    provider {'facebook'}
    name {Faker::Name.name }
    gender {'male'}
    birthday { Time.at(rand * (18.years.ago.to_f - 50.years.ago.to_f) + 50.years.ago.to_f).to_date } 
end

Fabricator(:workdone) do 
    provider 
    workdonecount {1}
    quotegivencount {1}
    rating {5}
    active {true}
    give_price {true}
end


Fabricator(:provider) do
  user 
  business_address {"Bostanlı Mh., 6352. Sokak No:15, 35480 İzmir, Türkiye"}
  business_description {"Biz de sadece epilasyon işleriyle uğraşıyoruz ve bu işlerin  
  quote(count: 1)

 Fabricator(:quote) do 
    user  
    providers(count: 3) { Fabricate(:price).workdone.provider } 
    share_on_facebook_timeline {false} 
    customer_address {"Bostanlı Mh., 6352. Sokak No:15, 35480 İzmir, Türkiye"}
    description {"dasdsadasdsad sadadsssssdsadsasdas"}
    location {[27.094637499999976,38.4621336 ] }
    variation_id { Fabricate(:variation)._id}
end

Fabricate(:quote) で引用符を作成する場合

このエラーメッセージが表示されます

   Quote#give_quote works
     Failure/Error: Unable to find matching line from backtrace
     SystemStackError:
       stack level too deep

プロバイダー ファブリケーターから quote(count: 1) を削除すると、このエラーが発生します。ちなみに、これはレールコンソールで機能します-プロバイダーが作成されます。

Failure/Error: quote = Fabricate(:quote)
     TypeError:
       no implicit conversion of nil into String
     # ./spec/fabricators/quote_fabricator.rb:4:in `block (2 levels) in <top (required)>'
     # ./spec/models/quote_spec.rb:51:in `block (3 levels) in <top (required)>'

providers(count: 3) { Fabricate(:price).workdone.provider } 関連付けを引用ファブリケーターから完全に削除すると、テストはパスしますが、もちろんプロバイダーは作成されません

プロバイダーを作成する方法を知っている人はいますか?

4

1 に答える 1