diff --git a/models/payment.rb b/models/payment.rb index 9494e19..f943b3f 100644 --- a/models/payment.rb +++ b/models/payment.rb @@ -15,7 +15,7 @@ def self.sorted(year=2007,limit=20) limit(limit). all end - + def date self.year.year end diff --git a/spec/payment_spec.rb b/spec/payment_spec.rb index b67718a..ebfd824 100644 --- a/spec/payment_spec.rb +++ b/spec/payment_spec.rb @@ -1,12 +1,18 @@ require 'spec_helper' describe "test the payment methods" do - # before(:each) do - # @payment = Payment.new(:year_id => "1") - # end - # it "get the date for the payment" do - # expect(Payment.where(year_id(1)).first.date).to eq(2004) - # end + it "get the date for the payment" do + expect(Payment.find(:year_id => 7 ).date).to eq(2010) + end + it "get the amount of payment" do + expect(Payment.number).to eq(9) + end + + it "get sorted payment of a year" do + expect(Payment.sorted(2010, 5).count).to eq(5) + expect(Payment.sorted(2010, 5).first.year_id).to eq(7) + expect(Payment.sorted(2010, 5)[0].amount_euro).to be > Payment.sorted(2010, 5)[1].amount_euro + end end \ No newline at end of file diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 1b63e92..445908c 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -80,7 +80,6 @@ def self.populate_payment_table year_id: year_id, recipient_id: recipient_id ) - p "#{row['amountEuro']}" end end i += 1 @@ -97,3 +96,4 @@ def self.populate_payment_table require "models/year" require "models/recipient" +require "models/payment"