Last active
December 20, 2015 05:49
-
-
Save bsylvain/6081584 to your computer and use it in GitHub Desktop.
Is it the same thing?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
factory :user do | |
email { Faker::Internet.email} | |
#Lots of declarations | |
#.... | |
adresse | |
factory :user_with_recurring_order_to_generate do | |
after(:build) do |u| | |
u.contrats << build(:contrat_with_active_product) | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
factory :user do | |
email { Faker::Internet.email} | |
#Lots of declarations | |
#.... | |
adresse | |
end | |
factory :user_with_recurring_order_to_generate, parent: :user do | |
#here is the deprecation | |
after(:build) {|u| FactoryGirl.create(:contrat_with_active_product, :user=>u)} | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe "Can the suer" do | |
let(:option) { FactoryGirl.build(:option)} | |
let(:user) { FactoryGirl.build(:user)} | |
let(:produit) { FactoryGirl.build(:produit)} | |
it "buy this option when it's in the basket?" do | |
assert !user.option_can_be_purchased?(option) | |
assert user.get_contrat.add(produit.id,produit.pricings.first) | |
option.produit=produit | |
pp user.contrats[0] | |
pp user.contrats.count | |
pp user.contrats | |
assert user.contrats.count == 1 | |
assert user.option_can_be_purchased?(option) | |
end | |
end | |
describe "Un utilisateur est abonné a un produit" do | |
let(:user) { FactoryGirl.create(:user_with_recurring_order_to_generate)} | |
it "génère les factures anciennes" do | |
assert user.contrats.count==1 | |
Timecop.travel(Timecop.travel(Time.new(2013,02,28,20,15,1))) | |
user.create_recurring_billing | |
assert user.get_active_goods(Time.now.to_date.prev_month).count == 1 | |
assert user.get_active_goods.count == 1 | |
assert user.contrats.count==3 | |
Timecop.return | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment