From 0475394b0804a40e217b136b8af0076bab50c030 Mon Sep 17 00:00:00 2001 From: Oleksii Kriuchykhin Date: Mon, 16 Sep 2019 13:03:41 +0200 Subject: [PATCH] Fix test [SCI-3881] --- Gemfile.lock | 6 +- db/structure.sql | 114 ++++++++++++++++++- spec/controllers/projects_controller_spec.rb | 12 -- spec/factories/team_repositories.rb | 1 - spec/models/team_repository_spec.rb | 1 + 5 files changed, 112 insertions(+), 22 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 276b53047..f2fbfab4a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,12 +1,12 @@ GIT remote: https://github.com/biosistemika/canaid - revision: 8c87ae49648f4ca2c37313b0d9b9c561a10a71a2 + revision: 2ac3004d728adbf1be7f4271689b83464f612b23 branch: rails_6 specs: canaid (1.0.4) - devise (~> 4.6.2) + devise (>= 3.4.1) docile (>= 1.1.0) - rails (~> 5.2.3) + rails (>= 4) GIT remote: https://github.com/biosistemika/jquery-scrollto-rails diff --git a/db/structure.sql b/db/structure.sql index 5e8c30322..858aad68a 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -44,11 +44,8 @@ COMMENT ON EXTENSION pg_trgm IS 'text similarity measurement and index searching CREATE FUNCTION public.trim_html_tags(input text, OUT output text) RETURNS text LANGUAGE sql AS $$ - SELECT regexp_replace(input, - E'<[^>]*>|\\[#.*\\]|\\[@.*\\]', - '', - 'g'); - $$; + SELECT regexp_replace(input, E'<[^>]*>', '', 'g'); + $$; SET default_tablespace = ''; @@ -1088,7 +1085,8 @@ CREATE TABLE public.repositories ( name character varying, created_at timestamp without time zone, updated_at timestamp without time zone, - discarded_at timestamp without time zone + discarded_at timestamp without time zone, + permission_level integer DEFAULT 0 NOT NULL ); @@ -1992,6 +1990,39 @@ CREATE SEQUENCE public.tags_id_seq ALTER SEQUENCE public.tags_id_seq OWNED BY public.tags.id; +-- +-- Name: team_repositories; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.team_repositories ( + id bigint NOT NULL, + team_id bigint, + repository_id bigint, + permission_level integer DEFAULT 0 NOT NULL, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL +); + + +-- +-- Name: team_repositories_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.team_repositories_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: team_repositories_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.team_repositories_id_seq OWNED BY public.team_repositories.id; + + -- -- Name: teams_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- @@ -2903,6 +2934,13 @@ ALTER TABLE ONLY public.tables ALTER COLUMN id SET DEFAULT nextval('public.table ALTER TABLE ONLY public.tags ALTER COLUMN id SET DEFAULT nextval('public.tags_id_seq'::regclass); +-- +-- Name: team_repositories id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.team_repositories ALTER COLUMN id SET DEFAULT nextval('public.team_repositories_id_seq'::regclass); + + -- -- Name: teams id; Type: DEFAULT; Schema: public; Owner: - -- @@ -3455,6 +3493,14 @@ ALTER TABLE ONLY public.tags ADD CONSTRAINT tags_pkey PRIMARY KEY (id); +-- +-- Name: team_repositories team_repositories_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.team_repositories + ADD CONSTRAINT team_repositories_pkey PRIMARY KEY (id); + + -- -- Name: teams teams_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -4325,6 +4371,13 @@ CREATE INDEX index_reports_on_user_id ON public.reports USING btree (user_id); CREATE INDEX index_repositories_on_discarded_at ON public.repositories USING btree (discarded_at); +-- +-- Name: index_repositories_on_permission_level; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_repositories_on_permission_level ON public.repositories USING btree (permission_level); + + -- -- Name: index_repositories_on_team_id; Type: INDEX; Schema: public; Owner: - -- @@ -4864,6 +4917,34 @@ CREATE INDEX index_tags_on_name ON public.tags USING gin (public.trim_html_tags( CREATE INDEX index_tags_on_project_id ON public.tags USING btree (project_id); +-- +-- Name: index_team_repositories_on_permission_level; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_team_repositories_on_permission_level ON public.team_repositories USING btree (permission_level); + + +-- +-- Name: index_team_repositories_on_repository_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_team_repositories_on_repository_id ON public.team_repositories USING btree (repository_id); + + +-- +-- Name: index_team_repositories_on_team_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_team_repositories_on_team_id ON public.team_repositories USING btree (team_id); + + +-- +-- Name: index_team_repositories_on_team_id_and_repository_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX index_team_repositories_on_team_id_and_repository_id ON public.team_repositories USING btree (team_id, repository_id); + + -- -- Name: index_teams_on_created_by_id; Type: INDEX; Schema: public; Owner: - -- @@ -5223,6 +5304,14 @@ ALTER TABLE ONLY public.tables ADD CONSTRAINT fk_rails_147b6eced4 FOREIGN KEY (last_modified_by_id) REFERENCES public.users(id); +-- +-- Name: team_repositories fk_rails_15daa6a6bf; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.team_repositories + ADD CONSTRAINT fk_rails_15daa6a6bf FOREIGN KEY (repository_id) REFERENCES public.repositories(id); + + -- -- Name: zip_exports fk_rails_1952fc2261; Type: FK CONSTRAINT; Schema: public; Owner: - -- @@ -6247,6 +6336,14 @@ ALTER TABLE ONLY public.tags ADD CONSTRAINT fk_rails_f95c7c81ac FOREIGN KEY (last_modified_by_id) REFERENCES public.users(id); +-- +-- Name: team_repositories fk_rails_f99472b670; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.team_repositories + ADD CONSTRAINT fk_rails_f99472b670 FOREIGN KEY (team_id) REFERENCES public.teams(id); + + -- -- Name: sample_groups fk_rails_fc2ab1a001; Type: FK CONSTRAINT; Schema: public; Owner: - -- @@ -6433,6 +6530,11 @@ INSERT INTO "schema_migrations" (version) VALUES ('20190520135317'), ('20190613094834'), ('20190613134100'), +('20190711125513'), +('20190715150326'), +('20190812065432'), +('20190812072649'), +('20190830141257'), ('20190910125740'); diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb index 3ed2e375b..97ff8a17a 100644 --- a/spec/controllers/projects_controller_spec.rb +++ b/spec/controllers/projects_controller_spec.rb @@ -90,18 +90,6 @@ describe ProjectsController, type: :controller do end end - describe '#archive' do - context 'in JSON format' do - let(:params) { { team: team.id, sort: 'atoz' } } - - it 'returns success response' do - get :archive, params: params, format: :json - expect(response).to have_http_status(:success) - expect(response.media_type).to eq 'application/json' - end - end - end - describe 'POST create' do context 'in JSON format' do let(:params) do diff --git a/spec/factories/team_repositories.rb b/spec/factories/team_repositories.rb index 060dfc4c7..b7db29b1b 100644 --- a/spec/factories/team_repositories.rb +++ b/spec/factories/team_repositories.rb @@ -2,7 +2,6 @@ FactoryBot.define do factory :team_repository do - team repository trait :read do permission_level { :shared_read } diff --git a/spec/models/team_repository_spec.rb b/spec/models/team_repository_spec.rb index bf1863b62..78cad5d5e 100644 --- a/spec/models/team_repository_spec.rb +++ b/spec/models/team_repository_spec.rb @@ -6,6 +6,7 @@ describe TeamRepository, type: :model do let(:team_repository) { build :team_repository, :read } it 'is valid' do + team_repository.team = create :team expect(team_repository).to be_valid end