diff --git a/test/controllers/payment_schedules_controller_test.rb b/test/controllers/payment_schedules_controller_test.rb new file mode 100644 index 000000000..446e5a558 --- /dev/null +++ b/test/controllers/payment_schedules_controller_test.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +require 'test_helper' + +class PaymentSchedulesControllerTest < ActionDispatch::IntegrationTest + def setup + @user = User.friendly.find('pjproudhon') + login_as(@user, scope: :user) + end + + test "should get user's schedules" do + get payment_schedules_url + assert_response :success + + assert_equal @user.invoicing_profile.payment_schedules.count, json_response(response.body).length + end +end diff --git a/test/fixtures/invoicing_profiles.yml b/test/fixtures/invoicing_profiles.yml index 3d2a4e206..626c047bb 100644 --- a/test/fixtures/invoicing_profiles.yml +++ b/test/fixtures/invoicing_profiles.yml @@ -53,3 +53,10 @@ atiermoulin: first_name: Amandine last_name: Tiermoulin email: a.tiermoulin@mail.fr + +proudhon: + id: 9 + user_id: 9 + first_name: Pierre-Joseph + last_name: Proudhon + email: pj.proudhon@la-propriete.org diff --git a/test/fixtures/payment_gateway_objects.yml b/test/fixtures/payment_gateway_objects.yml index d15d2624b..3dd7fbc88 100644 --- a/test/fixtures/payment_gateway_objects.yml +++ b/test/fixtures/payment_gateway_objects.yml @@ -1,161 +1,210 @@ -pgo_1: +pgo1: + id: 1 item_type: 'InvoiceItem' item_id: 1 gateway_object_type: 'Stripe::Subscription' gateway_object_id: 'sub_8DGB4ErIc2asOv' pgo2: + id: 2 item_type: 'Subscription' item_id: 1 gateway_object_type: 'Stripe::Subscription' gateway_object_id: 'sub_8DGB4ErIc2asOv' pgo3: + id: 3 item_type: 'Invoice' item_id: 1 gateway_object_type: 'Stripe::Invoice' gateway_object_id: 'in_17wpf92sOmf47Nz9itj6vmJw' pgo4: + id: 4 item_type: 'Plan' item_id: 1 gateway_object_type: 'Stripe::Product' gateway_object_id: 'prod_IZPyXhfyNiGkWR' pgo5: + id: 5 item_type: 'Plan' item_id: 2 gateway_object_type: 'Stripe::Product' gateway_object_id: 'prod_IZPykam7a4satn' pgo6: + id: 6 item_type: 'Plan' item_id: 3 gateway_object_type: 'Stripe::Product' gateway_object_id: 'prod_IZPyM4N36h86G0' pgo7: + id: 7 item_type: 'Plan' item_id: 4 gateway_object_type: 'Stripe::Product' gateway_object_id: 'prod_IZQAhb9nLu4jfN' pgo8: + id: 8 item_type: 'Machine' item_id: 1 gateway_object_type: 'Stripe::Product' gateway_object_id: 'prod_IZPyHpMCl38iQl' pgo9: + id: 9 item_type: 'Machine' item_id: 2 gateway_object_type: 'Stripe::Product' gateway_object_id: 'prod_IZPyPShaaRgSML' pgo10: + id: 10 item_type: 'Machine' item_id: 3 gateway_object_type: 'Stripe::Product' gateway_object_id: 'prod_IZPyEjmdfMowhY' pgo11: + id: 11 item_type: 'Machine' item_id: 4 gateway_object_type: 'Stripe::Product' gateway_object_id: 'prod_IZPy85vZOQpAo5' pgo12: + id: 12 item_type: 'Machine' item_id: 5 gateway_object_type: 'Stripe::Product' gateway_object_id: 'prod_IZPyBJEgbcpWMC' pgo13: + id: 13 item_type: 'Machine' item_id: 6 gateway_object_type: 'Stripe::Product' gateway_object_id: 'prod_IZPyjCzvLmLWAz' pgo14: + id: 14 item_type: 'Space' item_id: 1 gateway_object_type: 'Stripe::Product' gateway_object_id: 'prod_IZPyHjIb2owoB8' pgo15: + id: 15 item_type: 'Training' item_id: 1 gateway_object_type: 'Stripe::Product' gateway_object_id: 'prod_IZPyXw6BDBBFOg' pgo16: + id: 16 item_type: 'Training' item_id: 2 gateway_object_type: 'Stripe::Product' gateway_object_id: 'prod_IZPytTl1wSB5jH' pgo17: + id: 17 item_type: 'Training' item_id: 3 gateway_object_type: 'Stripe::Product' gateway_object_id: 'prod_IZPyAA1A4QfEyL' pgo18: + id: 18 item_type: 'Training' item_id: 4 gateway_object_type: 'Stripe::Product' gateway_object_id: 'prod_IZPyU27NjDSmqB' pgo19: + id: 19 item_type: 'Training' item_id: 5 gateway_object_type: 'Stripe::Product' gateway_object_id: 'prod_IZPyvdgQHMByB3' pgo20: + id: 20 item_type: 'User' item_id: 1 gateway_object_type: 'Stripe::Customer' gateway_object_id: 'cus_8CyNk3UTi8lvCc' pgo21: + id: 21 item_type: 'User' item_id: 2 gateway_object_type: 'Stripe::Customer' gateway_object_id: 'cus_8Di1wjdVktv5kt' pgo22: + id: 22 item_type: 'User' item_id: 3 gateway_object_type: 'Stripe::Customer' gateway_object_id: 'cus_8CzHcwBJtlA3IL' pgo23: + id: 23 item_type: 'User' item_id: 4 gateway_object_type: 'Stripe::Customer' gateway_object_id: 'cus_8CzKe50I0J1gaI' pgo24: + id: 24 item_type: 'User' item_id: 5 gateway_object_type: 'Stripe::Customer' gateway_object_id: 'cus_8CzNtM08NVlSGN' pgo25: + id: 25 item_type: 'User' item_id: 6 gateway_object_type: 'Stripe::Customer' gateway_object_id: 'cus_8CzQK5uXPeyh4K' pgo26: + id: 26 item_type: 'User' item_id: 7 gateway_object_type: 'Stripe::Customer' gateway_object_id: 'cus_8E2ys9zDZgetWX' pgo27: + id: 27 item_type: 'User' item_id: 8 gateway_object_type: 'Stripe::Customer' gateway_object_id: 'cus_IhIynmoJbzLpwX' + +pgo28: + id: 28 + gateway_object_id: b28adca1f5805ecfae87ecea + gateway_object_type: PayZen::Order + item_type: PaymentSchedule + item_id: 12 + +pgo29: + id: 29 + gateway_object_id: 5f02e6573ff844f391238e5185644929 + gateway_object_type: PayZen::Token + item_type: PaymentSchedule + item_id: 12 + +pgo30: + id: 30 + gateway_object_id: 20210614KPWlKu + gateway_object_type: PayZen::Subscription + item_type: PaymentSchedule + item_id: 12 + payment_gateway_object_id: 29 diff --git a/test/fixtures/payment_schedule_items.yml b/test/fixtures/payment_schedule_items.yml index e69de29bb..e689becc7 100644 --- a/test/fixtures/payment_schedule_items.yml +++ b/test/fixtures/payment_schedule_items.yml @@ -0,0 +1,168 @@ +payment_schedule_item_105: + id: 105 + amount: 9474 + due_date: '2021-06-14 12:24:45.836045' + state: paid + details: '{"recurring": 9466, "adjustment": 8, "other_items": 0}' + payment_method: card + client_secret: + payment_schedule_id: 12 + invoice_id: + footprint: 6168dcf85b00be2b45a36bbb3217e8b965a179c37922962978960062eac4bec6 + created_at: '2021-06-14 12:24:45.847551' + updated_at: '2021-06-14 13:00:41.302605' + +payment_schedule_item_106: + id: 106 + amount: 9466 + due_date: '2021-07-14 12:24:45.836332' + state: new + details: '{"recurring": 9466}' + payment_method: + client_secret: + payment_schedule_id: 12 + invoice_id: + footprint: ada6f6afe6489919d193ff6030923c0d524294529f13374f9a57d5691e9669fd + created_at: '2021-06-14 12:24:45.855717' + updated_at: '2021-06-14 12:24:45.858475' + + +payment_schedule_item_107: + id: 107 + amount: 9466 + due_date: '2021-08-14 12:24:45.836606' + state: new + details: '{"recurring": 9466}' + payment_method: + client_secret: + payment_schedule_id: 12 + invoice_id: + footprint: 7ca8bf5648235c8a706a01c5e788939ad5cfcc66c26782127ed1ed766379b005 + created_at: '2021-06-14 12:24:45.863237' + updated_at: '2021-06-14 12:24:45.865874' + +payment_schedule_item_108: + id: 108 + amount: 9466 + due_date: '2021-09-14 12:24:45.836767' + state: new + details: '{"recurring": 9466}' + payment_method: + client_secret: + payment_schedule_id: 12 + invoice_id: + footprint: 9d4925443f1537e07258140930489565542e48c39e3f9e48dd982bfae64cb759 + created_at: '2021-06-14 12:24:45.869357' + updated_at: '2021-06-14 12:24:45.872088' + +payment_schedule_item_109: + id: 109 + amount: 9466 + due_date: '2021-10-14 12:24:45.836900' + state: new + details: '{"recurring": 9466}' + payment_method: + client_secret: + payment_schedule_id: 12 + invoice_id: + footprint: 157ff90f880ebc5532be14898da65dcfc227fa54aaadc37a1f123dbeefa32640 + created_at: '2021-06-14 12:24:45.875500' + updated_at: '2021-06-14 12:24:45.879057' + +payment_schedule_item_110: + id: 110 + amount: 9466 + due_date: '2021-11-14 12:24:45.837025' + state: new + details: '{"recurring": 9466}' + payment_method: + client_secret: + payment_schedule_id: 12 + invoice_id: + footprint: 9b162c2b342d8c82e9163202a22a405b879d4b2ad2409a61ad10942f743bc576 + created_at: '2021-06-14 12:24:45.882343' + updated_at: '2021-06-14 12:24:45.884709' + +payment_schedule_item_111: + id: 111 + amount: 9466 + due_date: '2021-12-14 12:24:45.837025' + state: new + details: '{"recurring": 9466}' + payment_method: + client_secret: + payment_schedule_id: 12 + invoice_id: + footprint: 9b162c2b342d8c82e9163202a22a405b879d4b2ad2409a61ad10942f743bc576 + created_at: '2021-06-14 12:24:45.882343' + updated_at: '2021-06-14 12:24:45.884709' + +payment_schedule_item_112: + id: 112 + amount: 9466 + due_date: '2022-01-14 12:24:45.837025' + state: new + details: '{"recurring": 9466}' + payment_method: + client_secret: + payment_schedule_id: 12 + invoice_id: + footprint: 9b162c2b342d8c82e9163202a22a405b879d4b2ad2409a61ad10942f743bc576 + created_at: '2021-06-14 12:24:45.882343' + updated_at: '2021-06-14 12:24:45.884709' + +payment_schedule_item_113: + id: 113 + amount: 9466 + due_date: '2022-02-14 12:24:45.837025' + state: new + details: '{"recurring": 9466}' + payment_method: + client_secret: + payment_schedule_id: 12 + invoice_id: + footprint: 9b162c2b342d8c82e9163202a22a405b879d4b2ad2409a61ad10942f743bc576 + created_at: '2021-06-14 12:24:45.882343' + updated_at: '2021-06-14 12:24:45.884709' + +payment_schedule_item_114: + id: 114 + amount: 9466 + due_date: '2022-03-14 12:24:45.837025' + state: new + details: '{"recurring": 9466}' + payment_method: + client_secret: + payment_schedule_id: 12 + invoice_id: + footprint: 9b162c2b342d8c82e9163202a22a405b879d4b2ad2409a61ad10942f743bc576 + created_at: '2021-06-14 12:24:45.882343' + updated_at: '2021-06-14 12:24:45.884709' + +payment_schedule_item_115: + id: 115 + amount: 9466 + due_date: '2022-04-14 12:24:45.837025' + state: new + details: '{"recurring": 9466}' + payment_method: + client_secret: + payment_schedule_id: 12 + invoice_id: + footprint: 9b162c2b342d8c82e9163202a22a405b879d4b2ad2409a61ad10942f743bc576 + created_at: '2021-06-14 12:24:45.882343' + updated_at: '2021-06-14 12:24:45.884709' + +payment_schedule_item_116: + id: 116 + amount: 9466 + due_date: '2022-05-14 12:24:45.837025' + state: new + details: '{"recurring": 9466}' + payment_method: + client_secret: + payment_schedule_id: 12 + invoice_id: + footprint: 9b162c2b342d8c82e9163202a22a405b879d4b2ad2409a61ad10942f743bc576 + created_at: '2021-06-14 12:24:45.882343' + updated_at: '2021-06-14 12:24:45.884709' diff --git a/test/fixtures/payment_schedule_objects.yml b/test/fixtures/payment_schedule_objects.yml index e69de29bb..4a366c042 100644 --- a/test/fixtures/payment_schedule_objects.yml +++ b/test/fixtures/payment_schedule_objects.yml @@ -0,0 +1,9 @@ +payment_schedule_oject_10: + id: 10 + object_type: Subscription + object_id: 5 + payment_schedule_id: 12 + main: true + footprint: a1ef3a0c3abac7e02bc11193458c0d1e90a5acf290c9e3b4e7c049a7efcbeb30 + created_at: '2021-06-14 12:24:45.890373' + updated_at: '2021-06-14 12:24:45.894701' diff --git a/test/fixtures/payment_schedules.yml b/test/fixtures/payment_schedules.yml index e69de29bb..7ccecb8b6 100644 --- a/test/fixtures/payment_schedules.yml +++ b/test/fixtures/payment_schedules.yml @@ -0,0 +1,15 @@ +payment_schedule_12: + id: 12 + total: 180000 + reference: 210600309/E + payment_method: card + wallet_amount: + wallet_transaction_id: + coupon_id: + footprint: d4b66236895cdf18e21f64429a388050407f29bc228141ed95c89686b7daa716 + environment: development + invoicing_profile_id: 9 + statistic_profile_id: 9 + operator_profile_id: 1 + created_at: '2021-06-14 12:24:45.843714' + updated_at: '2021-06-14 12:24:45.908386' diff --git a/test/fixtures/profiles.yml b/test/fixtures/profiles.yml index 0daf95b3b..439ba2875 100644 --- a/test/fixtures/profiles.yml +++ b/test/fixtures/profiles.yml @@ -86,3 +86,14 @@ profile_8: software_mastered: freecad created_at: 2018-05-10 09:22:42.427521000 Z updated_at: 2021-01-04 14:36:39.729052932 Z + +profile_9: + id: 9 + user_id: 9 + first_name: Pierre-Joseph + last_name: Proudhon + phone: '0324121478' + interest: anarchisme, philosophie + software_mastered: + created_at: 2020-06-15 18:03:06.553623000 Z + updated_at: 2021-06-14 15:51:39.729052000 Z diff --git a/test/fixtures/statistic_profiles.yml b/test/fixtures/statistic_profiles.yml index 0acc8c1a6..3ecf17ddd 100644 --- a/test/fixtures/statistic_profiles.yml +++ b/test/fixtures/statistic_profiles.yml @@ -53,3 +53,10 @@ atiermoulin: gender: false birthday: 1985-09-01 group_id: 1 + +proudhon: + id: 9 + user_id: 9 + gender: true + birthday: 1809-01-15 + group_id: 1 diff --git a/test/fixtures/subscriptions.yml b/test/fixtures/subscriptions.yml index 49cac741d..87b4fdcd4 100644 --- a/test/fixtures/subscriptions.yml +++ b/test/fixtures/subscriptions.yml @@ -36,3 +36,12 @@ subscription_4: updated_at: 2018-06-11 14:27:12.427521000 Z expiration_date: 2018-07-11 14:27:12.427521000 Z canceled_at: + +subscription_5: + id: 5 + plan_id: 4 + statistic_profile_id: 9 + created_at: 2021-06-14 12:24:45.836045000 Z + updated_at: 2021-06-14 12:24:45.836045000 Z + expiration_date: 2022-06-14 12:24:45.836045000 Z + canceled_at: diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml index 7d80696f7..94b49105a 100644 --- a/test/fixtures/users.yml +++ b/test/fixtures/users.yml @@ -253,3 +253,35 @@ user_8: auth_token: merged_at: is_allow_newsletter: false + +user_9: + id: 9 + username: pjproudhon + email: pj.proudhon@la-propriete.org + encrypted_password: $2a$10$OJpiDDU/4WALJglRv0eS/eNeN6csXqhiMegn3pdciw6U.ELyCw53u + reset_password_token: + reset_password_sent_at: + remember_created_at: + sign_in_count: 1 + current_sign_in_at: 2020-06-29 13:34:36.725287 + last_sign_in_at: 2020-06-29 13:34:36.725287 + current_sign_in_ip: 162.21.14.7 + last_sign_in_ip: 162.21.14.7 + confirmation_token: + confirmed_at: 2020-10-23 07:55:32.355523 + confirmation_sent_at: 2020-06-15 18:03:06.728856 + unconfirmed_email: + failed_attempts: 0 + unlock_token: + locked_at: + created_at: 2020-06-15 18:03:06.553623 + updated_at: 2020-06-15 18:03:06.730140 + is_allow_contact: true + group_id: 1 + slug: pjproudhon + is_active: true + provider: + uid: + auth_token: + merged_at: + is_allow_newsletter: true diff --git a/test/fixtures/wallets.yml b/test/fixtures/wallets.yml index d810a3ce3..77ca99305 100644 --- a/test/fixtures/wallets.yml +++ b/test/fixtures/wallets.yml @@ -29,3 +29,7 @@ wallet_7: wallet_8: invoicing_profile_id: 8 amount: 0 + +wallet_9: + invoicing_profile_id: 9 + amount: 0