From 813741890459f69d07c1b85eca988fef9bb356a6 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Wed, 24 Jun 2020 15:25:17 +0200 Subject: [PATCH] improved test for accounting periods --- app/models/accounting_period.rb | 1 + db/structure.sql | 57 ++++++------------ lib/tasks/fablab/es.rake | 3 +- test/fixtures/accounting_periods.yml | 1 + .../148622585/2015-01-01_2015-12-31.zip | Bin 0 -> 1302 bytes test/integration/accounting_period_test.rb | 20 ++++++ 6 files changed, 43 insertions(+), 39 deletions(-) create mode 100644 test/fixtures/files/accounting/148622585/2015-01-01_2015-12-31.zip diff --git a/app/models/accounting_period.rb b/app/models/accounting_period.rb index 4a5824221..f71e34921 100644 --- a/app/models/accounting_period.rb +++ b/app/models/accounting_period.rb @@ -36,6 +36,7 @@ class AccountingPeriod < ApplicationRecord def archive_folder dir = "accounting/#{id}" + dir = "test/fixtures/files/accounting/#{id}" if Rails.env.test? # create directory if it doesn't exists (accounting) FileUtils.mkdir_p dir diff --git a/db/structure.sql b/db/structure.sql index 1f21bf281..d0715be38 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -108,8 +108,8 @@ SET default_tablespace = ''; CREATE TABLE public.abuses ( id integer NOT NULL, - signaled_id integer, signaled_type character varying, + signaled_id integer, first_name character varying, last_name character varying, email character varying, @@ -187,8 +187,8 @@ CREATE TABLE public.addresses ( locality character varying, country character varying, postal_code character varying, - placeable_id integer, placeable_type character varying, + placeable_id integer, created_at timestamp without time zone, updated_at timestamp without time zone ); @@ -263,8 +263,8 @@ CREATE TABLE public.ar_internal_metadata ( CREATE TABLE public.assets ( id integer NOT NULL, - viewable_id integer, viewable_type character varying, + viewable_id integer, attachment character varying, type character varying, created_at timestamp without time zone, @@ -504,8 +504,8 @@ ALTER SEQUENCE public.coupons_id_seq OWNED BY public.coupons.id; CREATE TABLE public.credits ( id integer NOT NULL, - creditable_id integer, creditable_type character varying, + creditable_id integer, plan_id integer, hours integer, created_at timestamp without time zone, @@ -1013,8 +1013,8 @@ ALTER SEQUENCE public.invoice_items_id_seq OWNED BY public.invoice_items.id; CREATE TABLE public.invoices ( id integer NOT NULL, - invoiced_id integer, invoiced_type character varying, + invoiced_id integer, stp_invoice_id character varying, total integer, created_at timestamp without time zone, @@ -1193,15 +1193,15 @@ ALTER SEQUENCE public.machines_id_seq OWNED BY public.machines.id; CREATE TABLE public.notifications ( id integer NOT NULL, receiver_id integer, - attached_object_id integer, attached_object_type character varying, + attached_object_id integer, notification_type_id integer, is_read boolean DEFAULT false, created_at timestamp without time zone, updated_at timestamp without time zone, receiver_type character varying, is_send boolean DEFAULT false, - meta_data jsonb DEFAULT '{}'::jsonb + meta_data jsonb DEFAULT '"{}"'::jsonb ); @@ -1542,8 +1542,8 @@ CREATE TABLE public.prices ( id integer NOT NULL, group_id integer, plan_id integer, - priceable_id integer, priceable_type character varying, + priceable_id integer, amount integer, created_at timestamp without time zone NOT NULL, updated_at timestamp without time zone NOT NULL @@ -1858,8 +1858,8 @@ CREATE TABLE public.reservations ( message text, created_at timestamp without time zone, updated_at timestamp without time zone, - reservable_id integer, reservable_type character varying, + reservable_id integer, nb_reserve_places integer, statistic_profile_id integer ); @@ -1891,8 +1891,8 @@ ALTER SEQUENCE public.reservations_id_seq OWNED BY public.reservations.id; CREATE TABLE public.roles ( id integer NOT NULL, name character varying, - resource_id integer, resource_type character varying, + resource_id integer, created_at timestamp without time zone, updated_at timestamp without time zone ); @@ -2826,8 +2826,8 @@ CREATE TABLE public.users_roles ( CREATE TABLE public.wallet_transactions ( id integer NOT NULL, wallet_id integer, - transactable_id integer, transactable_type character varying, + transactable_id integer, transaction_type character varying, amount integer, created_at timestamp without time zone NOT NULL, @@ -3871,6 +3871,14 @@ ALTER TABLE ONLY public.roles ADD CONSTRAINT roles_pkey PRIMARY KEY (id); +-- +-- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.schema_migrations + ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version); + + -- -- Name: settings settings_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -4886,29 +4894,6 @@ CREATE INDEX profiles_lower_unaccent_last_name_trgm_idx ON public.profiles USING CREATE INDEX projects_search_vector_idx ON public.projects USING gin (search_vector); --- --- Name: unique_schema_migrations; Type: INDEX; Schema: public; Owner: - --- - -CREATE UNIQUE INDEX unique_schema_migrations ON public.schema_migrations USING btree (version); - - --- --- Name: accounting_periods accounting_periods_del_protect; Type: RULE; Schema: public; Owner: - --- - -CREATE RULE accounting_periods_del_protect AS - ON DELETE TO public.accounting_periods DO INSTEAD NOTHING; - - --- --- Name: accounting_periods accounting_periods_upd_protect; Type: RULE; Schema: public; Owner: - --- - -CREATE RULE accounting_periods_upd_protect AS - ON UPDATE TO public.accounting_periods DO INSTEAD NOTHING; - - -- -- Name: projects projects_search_content_trigger; Type: TRIGGER; Schema: public; Owner: - -- @@ -5395,7 +5380,6 @@ INSERT INTO "schema_migrations" (version) VALUES ('20140605125131'), ('20140605142133'), ('20140605151442'), -('20140606133116'), ('20140609092700'), ('20140609092827'), ('20140610153123'), @@ -5464,14 +5448,12 @@ INSERT INTO "schema_migrations" (version) VALUES ('20150507075620'), ('20150512123546'), ('20150520132030'), -('20150520133409'), ('20150526130729'), ('20150527153312'), ('20150529113555'), ('20150601125944'), ('20150603104502'), ('20150603104658'), -('20150603133050'), ('20150604081757'), ('20150604131525'), ('20150608142234'), @@ -5553,7 +5535,6 @@ INSERT INTO "schema_migrations" (version) VALUES ('20160905142700'), ('20160906094739'), ('20160906094847'), -('20160906145713'), ('20160915105234'), ('20161123104604'), ('20170109085345'), diff --git a/lib/tasks/fablab/es.rake b/lib/tasks/fablab/es.rake index add9de1f2..7b650f643 100644 --- a/lib/tasks/fablab/es.rake +++ b/lib/tasks/fablab/es.rake @@ -145,7 +145,8 @@ namespace :fablab do raise 'Interrupted by user' unless confirm == 'y' end - PeriodStatisticsWorker.perform(args.period) + worker = PeriodStatisticsWorker.new + worker.perform(args.period) end end end diff --git a/test/fixtures/accounting_periods.yml b/test/fixtures/accounting_periods.yml index eb22ae4ec..d84951b15 100644 --- a/test/fixtures/accounting_periods.yml +++ b/test/fixtures/accounting_periods.yml @@ -1,4 +1,5 @@ period2015: + id: 148622585 start_at: 2015-01-01 end_at: 2015-12-31 closed_at: 2016-01-04 18:12:07 diff --git a/test/fixtures/files/accounting/148622585/2015-01-01_2015-12-31.zip b/test/fixtures/files/accounting/148622585/2015-01-01_2015-12-31.zip new file mode 100644 index 0000000000000000000000000000000000000000..12f9a71bd136b9af72d6c40ca4018a261e3de738 GIT binary patch literal 1302 zcmWIWW@Zs#U|`^2$V?$~LYN-<$rnKr*^n(faSld0Wk_Pu7Y(3c3Hm%JJ}>Qf;e)*X7zhF7B{-=lEDq z>6TPd*(sLCuMT`^+}s~CkHy-sZi?mqX`RB!H|;*ZxbQe(!nvY@D#>#K%=-#I9r4L{ zDV1oEeyU4`XMM!dwU=6RW^52^EI#bBvg^{cJtYZCJ?6U^du>>-y6wdyiG|9m@>Q($ zw%?PP_~g4z-P}u0*B1--?+u3U!X>_d2{_nqs)8qHo|D2%O{k^vH#{b_& zfgk?s^&UOG;$HQB>o@;4zG=yC{;(&EZB7nXh^0|nVYJmk*1b)JmRWCIo@!}xWdv}B zOfBM_`;2w%0+C~hQ&SxFpSxWBZD()(W0}_+@$;_p?9y|TII;C*+HA3Rf_oj-{N2TK z*g|3IyUSlM=SDgw&AqUF@!I#dPhXwo@uQ`1S>wL;PpU3k`4@N3KlnJ9d%gcJjvOl*yJ8$rP<*yj!1x<^d_-0x#-<)zlaL&2lPLa!%$y|Ns z0zNKD)NpWKJU4i%PHd>E@#)ZuOGr)9=HVy? zaIUQ5?ezr?daSG>f8v=Ga}A?*P0tYPwM{(vE>FQ*@~*OCWdK9Q(Q=Qls}j1q3XjZN zIoau&iAu2PwWmDcKTecn9QrTL}dF4UiQ`cjUp1yNm=-B<> zd&iyIJO48Tcr!AYFyk&jfEF__0`ZbY5DRy4f^H6axPf#-%n1Y*PiUctt{L6y2+gO# Znvnw{z?&6V)-f