Sha256: 75e262b0870a1c6db6316c73eef0e98d37acfadae71c7b775eb31933494aa4ef
Contents?: true
Size: 717 Bytes
Versions: 2
Compression:
Stored size: 717 Bytes
Contents
describe "modelling relation" do before do class Test::Order extend Dry::Initializer param :user, model: "User.where(name: 'Dude')" option :product, model: Item.where(name: "The thing") end end let!(:user) { User.create id: 9, name: "Dude" } let!(:item) { Item.create id: 1, name: "The thing" } let!(:other) { Item.create id: 2, name: "Another thing" } it "uses relation" do subject = Test::Order.new(9, product: 1) expect(subject.user).to eq user expect(subject.product).to eq item end it "raises when record not found for the relation" do expect { Test::Order.new(9, product: 2) } .to raise_error(ActiveRecord::RecordNotFound) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dry-initializer-rails-3.1.1 | spec/dry/initializer/modelling_relation_spec.rb |
dry-initializer-rails-3.1.0 | spec/dry/initializer/modelling_relation_spec.rb |