spec/relaxo/model/model_context.rb in relaxo-model-0.11.0 vs spec/relaxo/model/model_context.rb in relaxo-model-0.12.0
- old
+ new
@@ -10,11 +10,11 @@
property :number
property :name
property :date, Attribute[Date]
- view :all, [:type], index: [:id]
+ view :all, :type, index: :id
def transactions
Invoice::Transaction.by_invoice(@dataset, invoice: self)
end
end
@@ -26,24 +26,24 @@
property :id, UUID
property :invoice, BelongsTo[Invoice]
property :date, Attribute[Date]
- view :all, [:type], index: [:id]
+ view :all, :type, index: :id
- view :by_invoice, [:type, 'by_invoice', :invoice], index: [[:date, :id]]
+ view :by_invoice, index: unique(:date, :id)
end
class User
include Relaxo::Model
property :email, Attribute[String]
property :name
property :intro
- view :all, [:type], index: [:email]
+ view :all, :type, index: unique(:email)
- view :by_name, [:type, 'by_name'], index: [:name]
+ view :by_name, :type, 'by_name', index: unique(:name)
end
RSpec.shared_context "model" do
let(:database_path) {File.join(__dir__, 'test')}
let(:database) {Relaxo.connect(database_path)}