From d83fe1eeb232b8b11651982e2ebfa167736439b7 Mon Sep 17 00:00:00 2001
From: Derek Ekins
Date: Wed, 2 Oct 2019 08:42:13 +0100
Subject: [PATCH] build models using rails scaffold
---
.exrc | 9 +++
.rubocop.yml | 1 +
Gemfile | 1 +
Gemfile.lock | 2 +
Rakefile | 2 +
app/assets/stylesheets/group_types.css | 4 +
app/assets/stylesheets/group_websites.css | 4 +
app/assets/stylesheets/groups.css | 4 +
app/assets/stylesheets/project_statuses.css | 4 +
app/assets/stylesheets/scaffold.css | 80 +++++++++++++++++++
app/assets/stylesheets/tags.css | 4 +
app/controllers/group_types_controller.rb | 50 ++++++++++++
app/controllers/group_websites_controller.rb | 56 +++++++++++++
app/controllers/groups_controller.rb | 59 ++++++++++++++
.../initiative_statuses_controller.rb | 50 ++++++++++++
app/controllers/tags_controller.rb | 50 ++++++++++++
app/helpers/group_types_helper.rb | 4 +
app/helpers/group_websites_helper.rb | 4 +
app/helpers/groups_helper.rb | 4 +
app/helpers/tags_helper.rb | 4 +
app/jobs/application_job.rb | 2 +
app/mailers/application_mailer.rb | 2 +
app/models/application_record.rb | 2 +
app/models/group.rb | 7 ++
app/models/group_group_type.rb | 6 ++
app/models/group_type.rb | 5 ++
app/models/group_website.rb | 5 ++
app/models/initiative_status.rb | 4 +
app/models/tag.rb | 4 +
app/models/user.rb | 11 +--
app/views/group_types/_form.html.erb | 22 +++++
app/views/group_types/edit.html.erb | 6 ++
app/views/group_types/index.html.erb | 27 +++++++
app/views/group_types/new.html.erb | 5 ++
app/views/group_types/show.html.erb | 9 +++
app/views/group_websites/_form.html.erb | 22 +++++
app/views/group_websites/edit.html.erb | 6 ++
app/views/group_websites/index.html.erb | 30 +++++++
app/views/group_websites/new.html.erb | 5 ++
app/views/group_websites/show.html.erb | 14 ++++
app/views/groups/_form.html.erb | 59 ++++++++++++++
app/views/groups/edit.html.erb | 6 ++
app/views/groups/index.html.erb | 41 ++++++++++
app/views/groups/new.html.erb | 5 ++
app/views/groups/show.html.erb | 45 +++++++++++
app/views/initiative_statuses/_form.html.erb | 27 +++++++
app/views/initiative_statuses/edit.html.erb | 6 ++
app/views/initiative_statuses/index.html.erb | 29 +++++++
app/views/initiative_statuses/new.html.erb | 5 ++
app/views/initiative_statuses/show.html.erb | 14 ++++
app/views/layouts/application.html.erb | 3 +
app/views/tags/_form.html.erb | 22 +++++
app/views/tags/edit.html.erb | 6 ++
app/views/tags/index.html.erb | 27 +++++++
app/views/tags/new.html.erb | 5 ++
app/views/tags/show.html.erb | 9 +++
bin/bundle | 42 +++++-----
bin/rails | 4 +-
bin/rake | 4 +-
bin/setup | 2 +
bin/spring | 1 +
bin/webpack | 21 ++---
bin/webpack-dev-server | 21 ++---
bin/yarn | 14 ++--
config.ru | 2 +
config/application.rb | 2 +
config/boot.rb | 2 +
config/environment.rb | 2 +
.../application_controller_renderer.rb | 2 +
config/initializers/assets.rb | 2 +
config/initializers/backtrace_silencers.rb | 2 +
.../initializers/content_security_policy.rb | 2 +
config/initializers/cookies_serializer.rb | 2 +
config/initializers/inflections.rb | 2 +
config/initializers/mime_types.rb | 2 +
config/routes.rb | 13 +--
.../20190830160313_devise_create_users.rb | 2 +-
...190919213519_create_initiative_statuses.rb | 12 +++
db/migrate/20190919213829_create_tags.rb | 11 +++
.../20190919213923_create_group_types.rb | 11 +++
db/migrate/20190919214023_create_groups.rb | 19 +++++
.../20190919222547_create_group_websites.rb | 12 +++
...20191001200104_create_group_group_types.rb | 12 +++
db/schema.rb | 56 ++++++++++++-
db/seeds.rb | 3 +-
.../group_types_controller_test.rb | 57 +++++++++++++
.../group_websites_controller_test.rb | 62 ++++++++++++++
test/controllers/groups_controller_test.rb | 79 ++++++++++++++++++
.../initiative_statuses_controller_test.rb | 61 ++++++++++++++
test/controllers/tags_controller_test.rb | 57 +++++++++++++
test/fixtures/group_group_types.yml | 1 +
test/fixtures/group_types.yml | 7 ++
test/fixtures/group_websites.yml | 9 +++
test/fixtures/groups.yml | 23 ++++++
test/fixtures/initiative_statuses.yml | 9 +++
test/fixtures/tags.yml | 7 ++
test/models/group_group_type_test.rb | 9 +++
test/models/group_test.rb | 9 +++
test/models/group_type_test.rb | 9 +++
test/models/group_website_test.rb | 9 +++
test/models/initiative_status_test.rb | 9 +++
test/models/tag_test.rb | 9 +++
test/models/user_test.rb | 2 +
test/system/group_types_test.rb | 45 +++++++++++
test/system/group_websites_test.rb | 47 +++++++++++
test/system/groups_test.rb | 59 ++++++++++++++
test/system/initiative_statuses_test.rb | 47 +++++++++++
test/system/tags_test.rb | 45 +++++++++++
test/test_helper.rb | 8 +-
109 files changed, 1789 insertions(+), 71 deletions(-)
create mode 100644 .exrc
create mode 100644 app/assets/stylesheets/group_types.css
create mode 100644 app/assets/stylesheets/group_websites.css
create mode 100644 app/assets/stylesheets/groups.css
create mode 100644 app/assets/stylesheets/project_statuses.css
create mode 100644 app/assets/stylesheets/scaffold.css
create mode 100644 app/assets/stylesheets/tags.css
create mode 100644 app/controllers/group_types_controller.rb
create mode 100644 app/controllers/group_websites_controller.rb
create mode 100644 app/controllers/groups_controller.rb
create mode 100644 app/controllers/initiative_statuses_controller.rb
create mode 100644 app/controllers/tags_controller.rb
create mode 100644 app/helpers/group_types_helper.rb
create mode 100644 app/helpers/group_websites_helper.rb
create mode 100644 app/helpers/groups_helper.rb
create mode 100644 app/helpers/tags_helper.rb
create mode 100644 app/models/group.rb
create mode 100644 app/models/group_group_type.rb
create mode 100644 app/models/group_type.rb
create mode 100644 app/models/group_website.rb
create mode 100644 app/models/initiative_status.rb
create mode 100644 app/models/tag.rb
create mode 100644 app/views/group_types/_form.html.erb
create mode 100644 app/views/group_types/edit.html.erb
create mode 100644 app/views/group_types/index.html.erb
create mode 100644 app/views/group_types/new.html.erb
create mode 100644 app/views/group_types/show.html.erb
create mode 100644 app/views/group_websites/_form.html.erb
create mode 100644 app/views/group_websites/edit.html.erb
create mode 100644 app/views/group_websites/index.html.erb
create mode 100644 app/views/group_websites/new.html.erb
create mode 100644 app/views/group_websites/show.html.erb
create mode 100644 app/views/groups/_form.html.erb
create mode 100644 app/views/groups/edit.html.erb
create mode 100644 app/views/groups/index.html.erb
create mode 100644 app/views/groups/new.html.erb
create mode 100644 app/views/groups/show.html.erb
create mode 100644 app/views/initiative_statuses/_form.html.erb
create mode 100644 app/views/initiative_statuses/edit.html.erb
create mode 100644 app/views/initiative_statuses/index.html.erb
create mode 100644 app/views/initiative_statuses/new.html.erb
create mode 100644 app/views/initiative_statuses/show.html.erb
create mode 100644 app/views/tags/_form.html.erb
create mode 100644 app/views/tags/edit.html.erb
create mode 100644 app/views/tags/index.html.erb
create mode 100644 app/views/tags/new.html.erb
create mode 100644 app/views/tags/show.html.erb
create mode 100644 db/migrate/20190919213519_create_initiative_statuses.rb
create mode 100644 db/migrate/20190919213829_create_tags.rb
create mode 100644 db/migrate/20190919213923_create_group_types.rb
create mode 100644 db/migrate/20190919214023_create_groups.rb
create mode 100644 db/migrate/20190919222547_create_group_websites.rb
create mode 100644 db/migrate/20191001200104_create_group_group_types.rb
create mode 100644 test/controllers/group_types_controller_test.rb
create mode 100644 test/controllers/group_websites_controller_test.rb
create mode 100644 test/controllers/groups_controller_test.rb
create mode 100644 test/controllers/initiative_statuses_controller_test.rb
create mode 100644 test/controllers/tags_controller_test.rb
create mode 100644 test/fixtures/group_group_types.yml
create mode 100644 test/fixtures/group_types.yml
create mode 100644 test/fixtures/group_websites.yml
create mode 100644 test/fixtures/groups.yml
create mode 100644 test/fixtures/initiative_statuses.yml
create mode 100644 test/fixtures/tags.yml
create mode 100644 test/models/group_group_type_test.rb
create mode 100644 test/models/group_test.rb
create mode 100644 test/models/group_type_test.rb
create mode 100644 test/models/group_website_test.rb
create mode 100644 test/models/initiative_status_test.rb
create mode 100644 test/models/tag_test.rb
create mode 100644 test/system/group_types_test.rb
create mode 100644 test/system/group_websites_test.rb
create mode 100644 test/system/groups_test.rb
create mode 100644 test/system/initiative_statuses_test.rb
create mode 100644 test/system/tags_test.rb
diff --git a/.exrc b/.exrc
new file mode 100644
index 0000000..6edac40
--- /dev/null
+++ b/.exrc
@@ -0,0 +1,9 @@
+let g:vigun_extra_keywords = ['test']
+
+let g:vigun_commands = [
+ \ {
+ \ 'pattern': 'test/.*_test.rb$',
+ \ 'normal': 'rails test',
+ \ 'debug': 'BACKTRACE=1 rails test',
+ \ }
+ \]
diff --git a/.rubocop.yml b/.rubocop.yml
index 639f3dc..9200774 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -7,6 +7,7 @@ AllCops:
- "db/schema.rb"
- "node_modules/**/*"
- "vendor/**/*"
+ - "bin/bundle"
Documentation:
Enabled: false
diff --git a/Gemfile b/Gemfile
index c95dfb4..600a482 100644
--- a/Gemfile
+++ b/Gemfile
@@ -28,6 +28,7 @@ gem 'komponent', '>= 3.0.0.beta1'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
+ gem 'awesome_print'
gem 'byebug', platforms: %i[mri mingw x64_mingw]
gem 'rails_best_practices'
gem 'rubocop-performance'
diff --git a/Gemfile.lock b/Gemfile.lock
index 4797481..a66c4bf 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -59,6 +59,7 @@ GEM
addressable (2.6.0)
public_suffix (>= 2.0.2, < 4.0)
ast (2.4.0)
+ awesome_print (1.8.0)
bcrypt (3.1.13)
bindex (0.8.1)
bootsnap (1.4.5)
@@ -241,6 +242,7 @@ PLATFORMS
ruby
DEPENDENCIES
+ awesome_print
bootsnap (>= 1.4.2)
byebug
capybara (>= 2.15)
diff --git a/Rakefile b/Rakefile
index e85f913..488c551 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
diff --git a/app/assets/stylesheets/group_types.css b/app/assets/stylesheets/group_types.css
new file mode 100644
index 0000000..afad32d
--- /dev/null
+++ b/app/assets/stylesheets/group_types.css
@@ -0,0 +1,4 @@
+/*
+ Place all the styles related to the matching controller here.
+ They will automatically be included in application.css.
+*/
diff --git a/app/assets/stylesheets/group_websites.css b/app/assets/stylesheets/group_websites.css
new file mode 100644
index 0000000..afad32d
--- /dev/null
+++ b/app/assets/stylesheets/group_websites.css
@@ -0,0 +1,4 @@
+/*
+ Place all the styles related to the matching controller here.
+ They will automatically be included in application.css.
+*/
diff --git a/app/assets/stylesheets/groups.css b/app/assets/stylesheets/groups.css
new file mode 100644
index 0000000..afad32d
--- /dev/null
+++ b/app/assets/stylesheets/groups.css
@@ -0,0 +1,4 @@
+/*
+ Place all the styles related to the matching controller here.
+ They will automatically be included in application.css.
+*/
diff --git a/app/assets/stylesheets/project_statuses.css b/app/assets/stylesheets/project_statuses.css
new file mode 100644
index 0000000..afad32d
--- /dev/null
+++ b/app/assets/stylesheets/project_statuses.css
@@ -0,0 +1,4 @@
+/*
+ Place all the styles related to the matching controller here.
+ They will automatically be included in application.css.
+*/
diff --git a/app/assets/stylesheets/scaffold.css b/app/assets/stylesheets/scaffold.css
new file mode 100644
index 0000000..cd4f3de
--- /dev/null
+++ b/app/assets/stylesheets/scaffold.css
@@ -0,0 +1,80 @@
+body {
+ background-color: #fff;
+ color: #333;
+ margin: 33px;
+}
+
+body, p, ol, ul, td {
+ font-family: verdana, arial, helvetica, sans-serif;
+ font-size: 13px;
+ line-height: 18px;
+}
+
+pre {
+ background-color: #eee;
+ padding: 10px;
+ font-size: 11px;
+}
+
+a {
+ color: #000;
+}
+
+a:visited {
+ color: #666;
+}
+
+a:hover {
+ color: #fff;
+ background-color: #000;
+}
+
+th {
+ padding-bottom: 5px;
+}
+
+td {
+ padding: 0 5px 7px;
+}
+
+div.field,
+div.actions {
+ margin-bottom: 10px;
+}
+
+#notice {
+ color: green;
+}
+
+.field_with_errors {
+ padding: 2px;
+ background-color: red;
+ display: table;
+}
+
+#error_explanation {
+ width: 450px;
+ border: 2px solid red;
+ padding: 7px 7px 0;
+ margin-bottom: 20px;
+ background-color: #f0f0f0;
+}
+
+#error_explanation h2 {
+ text-align: left;
+ font-weight: bold;
+ padding: 5px 5px 5px 15px;
+ font-size: 12px;
+ margin: -7px -7px 0;
+ background-color: #c00;
+ color: #fff;
+}
+
+#error_explanation ul li {
+ font-size: 12px;
+ list-style: square;
+}
+
+label {
+ display: block;
+}
diff --git a/app/assets/stylesheets/tags.css b/app/assets/stylesheets/tags.css
new file mode 100644
index 0000000..afad32d
--- /dev/null
+++ b/app/assets/stylesheets/tags.css
@@ -0,0 +1,4 @@
+/*
+ Place all the styles related to the matching controller here.
+ They will automatically be included in application.css.
+*/
diff --git a/app/controllers/group_types_controller.rb b/app/controllers/group_types_controller.rb
new file mode 100644
index 0000000..4af410b
--- /dev/null
+++ b/app/controllers/group_types_controller.rb
@@ -0,0 +1,50 @@
+# frozen_string_literal: true
+
+class GroupTypesController < ApplicationController
+ before_action :set_group_type, only: %i[show edit update destroy]
+
+ def index
+ @group_types = GroupType.all
+ end
+
+ def show; end
+
+ def new
+ @group_type = GroupType.new
+ end
+
+ def edit; end
+
+ def create
+ @group_type = GroupType.new(group_type_params)
+
+ if @group_type.save
+ redirect_to @group_type, notice: 'Group type was successfully created.'
+ else
+ render :new
+ end
+ end
+
+ def update
+ if @group_type.update(group_type_params)
+ redirect_to @group_type, notice: 'Group type was successfully updated.'
+ else
+ render :edit
+ end
+ end
+
+ def destroy
+ @group_type.destroy!
+ redirect_to group_types_url, notice: 'Group type was successfully destroyed.'
+ end
+
+ private
+
+ def set_group_type
+ @group_type = GroupType.find(params[:id])
+ end
+
+ def group_type_params
+ params.require(:group_type).permit(:name)
+ end
+end
diff --git a/app/controllers/group_websites_controller.rb b/app/controllers/group_websites_controller.rb
new file mode 100644
index 0000000..76b58f1
--- /dev/null
+++ b/app/controllers/group_websites_controller.rb
@@ -0,0 +1,56 @@
+# frozen_string_literal: true
+
+class GroupWebsitesController < ApplicationController
+ before_action :set_group_website, only: %i[show edit update destroy]
+
+ before_action :set_group
+
+ def index
+ @group_websites = @group.websites
+ end
+
+ def show; end
+
+ def new
+ @group_website = @group.websites.new
+ end
+
+ def edit; end
+
+ def create
+ @group_website = @group.websites.new(group_website_params)
+
+ if @group_website.save
+ redirect_to [@group, @group_website], notice: 'Group website was successfully created.'
+ else
+ render :new
+ end
+ end
+
+ def update
+ if @group_website.update(group_website_params)
+ redirect_to [@group, @group_website], notice: 'Group website was successfully updated.'
+ else
+ render :edit
+ end
+ end
+
+ def destroy
+ @group_website.destroy
+ redirect_to group_group_websites_url(@group), notice: 'Group website was successfully destroyed.'
+ end
+
+ private
+
+ def set_group
+ @group = current_user.groups.find(params['group_id'])
+ end
+
+ def set_group_website
+ @group_website = GroupWebsite.find(params[:id])
+ end
+
+ def group_website_params
+ params.require(:group_website).permit(:website, :group_id)
+ end
+end
diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb
new file mode 100644
index 0000000..43b04ef
--- /dev/null
+++ b/app/controllers/groups_controller.rb
@@ -0,0 +1,59 @@
+# frozen_string_literal: true
+
+class GroupsController < ApplicationController
+ before_action :set_group, only: %i[show edit update destroy]
+
+ def index
+ @groups = Group.all
+ end
+
+ def show; end
+
+ def new
+ @group = Group.new
+ end
+
+ def edit; end
+
+ def create
+ @group = current_user.groups.new(group_params)
+
+ if @group.save
+ redirect_to @group, notice: 'Group was successfully created.'
+ else
+ render :new
+ end
+ end
+
+ def update
+ if @group.update(group_params)
+ redirect_to @group, notice: 'Group was successfully updated.'
+ else
+ render :edit
+ end
+ end
+
+ def destroy
+ @group.destroy
+ redirect_to groups_url, notice: 'Group was successfully destroyed.'
+ end
+
+ private
+
+ def set_group
+ @group = Group.find(params[:id])
+ end
+
+ def group_params
+ params.require(:group).permit(
+ :name,
+ :abbreviation,
+ :opening_hours,
+ :contact_name,
+ :contact_email,
+ :contact_phone,
+ :gdpr,
+ :gdpr_email_verified
+ )
+ end
+end
diff --git a/app/controllers/initiative_statuses_controller.rb b/app/controllers/initiative_statuses_controller.rb
new file mode 100644
index 0000000..836d316
--- /dev/null
+++ b/app/controllers/initiative_statuses_controller.rb
@@ -0,0 +1,50 @@
+# frozen_string_literal: true
+
+class InitiativeStatusesController < ApplicationController
+ before_action :set_initiative_status, only: %i[show edit update destroy]
+
+ def index
+ @initiative_statuses = InitiativeStatus.all
+ end
+
+ def show; end
+
+ def new
+ @initiative_status = InitiativeStatus.new
+ end
+
+ def edit; end
+
+ def create
+ @initiative_status = InitiativeStatus.new(initiative_status_params)
+
+ if @initiative_status.save
+ redirect_to @initiative_status, notice: 'Initiative status was successfully created.'
+ else
+ render :new
+ end
+ end
+
+ def update
+ if @initiative_status.update(initiative_status_params)
+ redirect_to @initiative_status, notice: 'Initiative status was successfully updated.'
+ else
+ render :edit
+ end
+ end
+
+ def destroy
+ @initiative_status.destroy
+ redirect_to initiative_statuses_url, notice: 'Initiative status was successfully destroyed.'
+ end
+
+ private
+
+ def set_initiative_status
+ @initiative_status = InitiativeStatus.find(params[:id])
+ end
+
+ def initiative_status_params
+ params.require(:initiative_status).permit(:name, :description)
+ end
+end
diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb
new file mode 100644
index 0000000..6262743
--- /dev/null
+++ b/app/controllers/tags_controller.rb
@@ -0,0 +1,50 @@
+# frozen_string_literal: true
+
+class TagsController < ApplicationController
+ before_action :set_tag, only: %i[show edit update destroy]
+
+ def index
+ @tags = Tag.all
+ end
+
+ def show; end
+
+ def new
+ @tag = Tag.new
+ end
+
+ def edit; end
+
+ def create
+ @tag = Tag.new(tag_params)
+
+ if @tag.save
+ redirect_to @tag, notice: 'Tag was successfully created.'
+ else
+ render :new
+ end
+ end
+
+ def update
+ if @tag.update(tag_params)
+ redirect_to @tag, notice: 'Tag was successfully updated.'
+ else
+ render :edit
+ end
+ end
+
+ def destroy
+ @tag.destroy
+ redirect_to tags_url, notice: 'Tag was successfully destroyed.'
+ end
+
+ private
+
+ def set_tag
+ @tag = Tag.find(params[:id])
+ end
+
+ def tag_params
+ params.require(:tag).permit(:name)
+ end
+end
diff --git a/app/helpers/group_types_helper.rb b/app/helpers/group_types_helper.rb
new file mode 100644
index 0000000..5dc617d
--- /dev/null
+++ b/app/helpers/group_types_helper.rb
@@ -0,0 +1,4 @@
+# frozen_string_literal: true
+
+module GroupTypesHelper
+end
diff --git a/app/helpers/group_websites_helper.rb b/app/helpers/group_websites_helper.rb
new file mode 100644
index 0000000..81aab04
--- /dev/null
+++ b/app/helpers/group_websites_helper.rb
@@ -0,0 +1,4 @@
+# frozen_string_literal: true
+
+module GroupWebsitesHelper
+end
diff --git a/app/helpers/groups_helper.rb b/app/helpers/groups_helper.rb
new file mode 100644
index 0000000..46abae7
--- /dev/null
+++ b/app/helpers/groups_helper.rb
@@ -0,0 +1,4 @@
+# frozen_string_literal: true
+
+module GroupsHelper
+end
diff --git a/app/helpers/tags_helper.rb b/app/helpers/tags_helper.rb
new file mode 100644
index 0000000..5b2b3ca
--- /dev/null
+++ b/app/helpers/tags_helper.rb
@@ -0,0 +1,4 @@
+# frozen_string_literal: true
+
+module TagsHelper
+end
diff --git a/app/jobs/application_job.rb b/app/jobs/application_job.rb
index d394c3d..bef3959 100644
--- a/app/jobs/application_job.rb
+++ b/app/jobs/application_job.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class ApplicationJob < ActiveJob::Base
# Automatically retry jobs that encountered a deadlock
# retry_on ActiveRecord::Deadlocked
diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb
index 286b223..d84cb6e 100644
--- a/app/mailers/application_mailer.rb
+++ b/app/mailers/application_mailer.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class ApplicationMailer < ActionMailer::Base
default from: 'from@example.com'
layout 'mailer'
diff --git a/app/models/application_record.rb b/app/models/application_record.rb
index 10a4cba..71fbba5 100644
--- a/app/models/application_record.rb
+++ b/app/models/application_record.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end
diff --git a/app/models/group.rb b/app/models/group.rb
new file mode 100644
index 0000000..621011e
--- /dev/null
+++ b/app/models/group.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class Group < ApplicationRecord
+ belongs_to :owner, class_name: 'User', dependent: :destroy
+ has_many :websites, class_name: 'GroupWebsite', dependent: :destroy
+ has_many :types, class_name: 'GroupGroupType', dependent: :destroy
+end
diff --git a/app/models/group_group_type.rb b/app/models/group_group_type.rb
new file mode 100644
index 0000000..c10c82d
--- /dev/null
+++ b/app/models/group_group_type.rb
@@ -0,0 +1,6 @@
+# frozen_string_literal: true
+
+class GroupGroupType < ApplicationRecord
+ belongs_to :group
+ belongs_to :group_type, dependent: :destroy
+end
diff --git a/app/models/group_type.rb b/app/models/group_type.rb
new file mode 100644
index 0000000..d4becb0
--- /dev/null
+++ b/app/models/group_type.rb
@@ -0,0 +1,5 @@
+# frozen_string_literal: true
+
+class GroupType < ApplicationRecord
+ has_many :group_types, class_name: 'GroupGroupType', dependent: :destroy
+end
diff --git a/app/models/group_website.rb b/app/models/group_website.rb
new file mode 100644
index 0000000..bf28186
--- /dev/null
+++ b/app/models/group_website.rb
@@ -0,0 +1,5 @@
+# frozen_string_literal: true
+
+class GroupWebsite < ApplicationRecord
+ belongs_to :group
+end
diff --git a/app/models/initiative_status.rb b/app/models/initiative_status.rb
new file mode 100644
index 0000000..d745acf
--- /dev/null
+++ b/app/models/initiative_status.rb
@@ -0,0 +1,4 @@
+# frozen_string_literal: true
+
+class InitiativeStatus < ApplicationRecord
+end
diff --git a/app/models/tag.rb b/app/models/tag.rb
new file mode 100644
index 0000000..5d747aa
--- /dev/null
+++ b/app/models/tag.rb
@@ -0,0 +1,4 @@
+# frozen_string_literal: true
+
+class Tag < ApplicationRecord
+end
diff --git a/app/models/user.rb b/app/models/user.rb
index 8b84c4a..1828ebd 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -8,14 +8,5 @@ class User < ApplicationRecord
:recoverable,
:rememberable,
:validatable
- has_many :subscriptions, dependent: :nullify
- has_many :addresses, dependent: :nullify
-
- def address
- addresses.last
- end
-
- def active_subscriptions
- subscriptions.where(ended: nil)
- end
+ has_many :groups, dependent: :nullify, foreign_key: 'owner_id', inverse_of: :owner
end
diff --git a/app/views/group_types/_form.html.erb b/app/views/group_types/_form.html.erb
new file mode 100644
index 0000000..5b99dae
--- /dev/null
+++ b/app/views/group_types/_form.html.erb
@@ -0,0 +1,22 @@
+<%= form_with(model: group_type, local: true) do |form| %>
+ <% if group_type.errors.any? %>
+
+
<%= pluralize(group_type.errors.count, "error") %> prohibited this group_type from being saved:
+
+
+ <% group_type.errors.full_messages.each do |message| %>
+ - <%= message %>
+ <% end %>
+
+
+ <% end %>
+
+
+ <%= form.label :name %>
+ <%= form.text_field :name %>
+
+
+
+ <%= form.submit %>
+
+<% end %>
diff --git a/app/views/group_types/edit.html.erb b/app/views/group_types/edit.html.erb
new file mode 100644
index 0000000..06da566
--- /dev/null
+++ b/app/views/group_types/edit.html.erb
@@ -0,0 +1,6 @@
+Editing Group Type
+
+<%= render 'form', group_type: @group_type %>
+
+<%= link_to 'Show', @group_type %> |
+<%= link_to 'Back', group_types_path %>
diff --git a/app/views/group_types/index.html.erb b/app/views/group_types/index.html.erb
new file mode 100644
index 0000000..188b609
--- /dev/null
+++ b/app/views/group_types/index.html.erb
@@ -0,0 +1,27 @@
+<%= notice %>
+
+Group Types
+
+
+
+
+ Name |
+ |
+
+
+
+
+ <% @group_types.each do |group_type| %>
+
+ <%= group_type.name %> |
+ <%= link_to 'Show', group_type %> |
+ <%= link_to 'Edit', edit_group_type_path(group_type) %> |
+ <%= link_to 'Destroy', group_type, method: :delete, data: { confirm: 'Are you sure?' } %> |
+
+ <% end %>
+
+
+
+
+
+<%= link_to 'New Group Type', new_group_type_path %>
diff --git a/app/views/group_types/new.html.erb b/app/views/group_types/new.html.erb
new file mode 100644
index 0000000..877782e
--- /dev/null
+++ b/app/views/group_types/new.html.erb
@@ -0,0 +1,5 @@
+New Group Type
+
+<%= render 'form', group_type: @group_type %>
+
+<%= link_to 'Back', group_types_path %>
diff --git a/app/views/group_types/show.html.erb b/app/views/group_types/show.html.erb
new file mode 100644
index 0000000..d3d63b6
--- /dev/null
+++ b/app/views/group_types/show.html.erb
@@ -0,0 +1,9 @@
+<%= notice %>
+
+
+ Name:
+ <%= @group_type.name %>
+
+
+<%= link_to 'Edit', edit_group_type_path(@group_type) %> |
+<%= link_to 'Back', group_types_path %>
diff --git a/app/views/group_websites/_form.html.erb b/app/views/group_websites/_form.html.erb
new file mode 100644
index 0000000..8258717
--- /dev/null
+++ b/app/views/group_websites/_form.html.erb
@@ -0,0 +1,22 @@
+<%= form_with(model: group_website, url: [group, group_website], local: true) do |form| %>
+ <% if group_website.errors.any? %>
+
+
<%= pluralize(group_website.errors.count, "error") %> prohibited this group_website from being saved:
+
+
+ <% group_website.errors.full_messages.each do |message| %>
+ - <%= message %>
+ <% end %>
+
+
+ <% end %>
+
+
+ <%= form.label :website %>
+ <%= form.text_field :website %>
+
+
+
+ <%= form.submit %>
+
+<% end %>
diff --git a/app/views/group_websites/edit.html.erb b/app/views/group_websites/edit.html.erb
new file mode 100644
index 0000000..0a0756e
--- /dev/null
+++ b/app/views/group_websites/edit.html.erb
@@ -0,0 +1,6 @@
+Editing Group Website
+
+<%= render 'form', group: @group, group_website: @group_website %>
+
+<%= link_to 'Show', [@group, @group_website] %> |
+<%= link_to 'Back', group_group_websites_path(@group) %>
diff --git a/app/views/group_websites/index.html.erb b/app/views/group_websites/index.html.erb
new file mode 100644
index 0000000..186ae5a
--- /dev/null
+++ b/app/views/group_websites/index.html.erb
@@ -0,0 +1,30 @@
+<%= notice %>
+
+Group Websites
+
+
+
+
+ Website |
+ Group |
+ |
+
+
+
+
+ <% @group_websites.each do |group_website| %>
+
+ <%= group_website.website %> |
+ <%= group_website.group.name %> |
+ <%= link_to 'Show', group_group_website_path(@group, group_website) %> |
+ <%= link_to 'Edit', edit_group_group_website_path(@group, group_website) %> |
+ <%= link_to 'Destroy', group_group_website_path(@group, group_website), method: :delete, data: { confirm: 'Are you sure?' } %> |
+
+ <% end %>
+
+
+
+
+
+<%= link_to 'Add Website', new_group_group_website_path(@group) %>
+<%= link_to 'Back', @group %>
diff --git a/app/views/group_websites/new.html.erb b/app/views/group_websites/new.html.erb
new file mode 100644
index 0000000..2ecb377
--- /dev/null
+++ b/app/views/group_websites/new.html.erb
@@ -0,0 +1,5 @@
+New Group Website
+
+<%= render 'form', group: @group, group_website: @group_website %>
+
+<%= link_to 'Back', group_group_websites_path(@group) %>
diff --git a/app/views/group_websites/show.html.erb b/app/views/group_websites/show.html.erb
new file mode 100644
index 0000000..f31b1da
--- /dev/null
+++ b/app/views/group_websites/show.html.erb
@@ -0,0 +1,14 @@
+<%= notice %>
+
+
+ Website:
+ <%= @group_website.website %>
+
+
+
+ Group:
+ <%= @group_website.group_id %>
+
+
+<%= link_to 'Edit', edit_group_group_website_path(@group, @group_website) %> |
+<%= link_to 'Back', group_group_websites_path(@group) %>
diff --git a/app/views/groups/_form.html.erb b/app/views/groups/_form.html.erb
new file mode 100644
index 0000000..e41bbcf
--- /dev/null
+++ b/app/views/groups/_form.html.erb
@@ -0,0 +1,59 @@
+<%= form_with(model: group, local: true) do |form| %>
+ <% if group.errors.any? %>
+
+
<%= pluralize(group.errors.count, "error") %> prohibited this group from being saved:
+
+
+ <% group.errors.full_messages.each do |message| %>
+ - <%= message %>
+ <% end %>
+
+
+ <% end %>
+
+
+ <%= form.label :name %>
+ <%= form.text_field :name %>
+
+
+
+ <%= form.label :abbreviation %>
+ <%= form.text_field :abbreviation %>
+
+
+
+ <%= form.label :opening_hours %>
+ <%= form.text_field :opening_hours %>
+
+
+
+ <%= form.label :contact_name %>
+ <%= form.text_field :contact_name %>
+
+
+
+ <%= form.label :contact_email %>
+ <%= form.text_field :contact_email %>
+
+
+
+ <%= form.label :contact_phone %>
+ <%= form.text_field :contact_phone %>
+
+
+
+ <%= form.label :gdpr %>
+ <%= form.check_box :gdpr %>
+
+
+
+ <%= form.label :gdpr_email_verified %>
+ <%= form.check_box :gdpr_email_verified %>
+
+
+ insert group type check boxes here
+
+
+ <%= form.submit %>
+
+<% end %>
diff --git a/app/views/groups/edit.html.erb b/app/views/groups/edit.html.erb
new file mode 100644
index 0000000..cd875bb
--- /dev/null
+++ b/app/views/groups/edit.html.erb
@@ -0,0 +1,6 @@
+Editing Group
+
+<%= render 'form', group: @group %>
+
+<%= link_to 'Show', @group %> |
+<%= link_to 'Back', groups_path %>
diff --git a/app/views/groups/index.html.erb b/app/views/groups/index.html.erb
new file mode 100644
index 0000000..2d14341
--- /dev/null
+++ b/app/views/groups/index.html.erb
@@ -0,0 +1,41 @@
+<%= notice %>
+
+Groups
+
+
+
+
+ Name |
+ Abbreviation |
+ Opening hours |
+ Contact name |
+ Contact email |
+ Contact phone |
+ Gdpr |
+ Gdpr email verified |
+ |
+
+
+
+
+ <% @groups.each do |group| %>
+
+ <%= group.name %> |
+ <%= group.abbreviation %> |
+ <%= group.opening_hours %> |
+ <%= group.contact_name %> |
+ <%= group.contact_email %> |
+ <%= group.contact_phone %> |
+ <%= group.gdpr %> |
+ <%= group.gdpr_email_verified %> |
+ <%= link_to 'Show', group %> |
+ <%= link_to 'Edit', edit_group_path(group) %> |
+ <%= link_to 'Destroy', group, method: :delete, data: { confirm: 'Are you sure?' } %> |
+
+ <% end %>
+
+
+
+
+
+<%= link_to 'New Group', new_group_path %>
diff --git a/app/views/groups/new.html.erb b/app/views/groups/new.html.erb
new file mode 100644
index 0000000..13219bd
--- /dev/null
+++ b/app/views/groups/new.html.erb
@@ -0,0 +1,5 @@
+New Group
+
+<%= render 'form', group: @group %>
+
+<%= link_to 'Back', groups_path %>
diff --git a/app/views/groups/show.html.erb b/app/views/groups/show.html.erb
new file mode 100644
index 0000000..26601c8
--- /dev/null
+++ b/app/views/groups/show.html.erb
@@ -0,0 +1,45 @@
+<%= notice %>
+
+
+ Name:
+ <%= @group.name %>
+
+
+
+ Abbreviation:
+ <%= @group.abbreviation %>
+
+
+
+ Opening hours:
+ <%= @group.opening_hours %>
+
+
+
+ Contact name:
+ <%= @group.contact_name %>
+
+
+
+ Contact email:
+ <%= @group.contact_email %>
+
+
+
+ Contact phone:
+ <%= @group.contact_phone %>
+
+
+
+ Gdpr:
+ <%= @group.gdpr %>
+
+
+
+ Gdpr email verified:
+ <%= @group.gdpr_email_verified %>
+
+
+<%= link_to 'Edit', edit_group_path(@group) %> |
+<%= link_to 'Back', groups_path %> |
+<%= link_to 'Websites', group_group_websites_path(@group) %>
diff --git a/app/views/initiative_statuses/_form.html.erb b/app/views/initiative_statuses/_form.html.erb
new file mode 100644
index 0000000..70d887e
--- /dev/null
+++ b/app/views/initiative_statuses/_form.html.erb
@@ -0,0 +1,27 @@
+<%= form_with(model: initiative_status, local: true) do |form| %>
+ <% if initiative_status.errors.any? %>
+
+
<%= pluralize(initiative_status.errors.count, "error") %> prohibited this initiative_status from being saved:
+
+
+ <% initiative_status.errors.full_messages.each do |message| %>
+ - <%= message %>
+ <% end %>
+
+
+ <% end %>
+
+
+ <%= form.label :name %>
+ <%= form.text_field :name %>
+
+
+
+ <%= form.label :description %>
+ <%= form.text_field :description %>
+
+
+
+ <%= form.submit %>
+
+<% end %>
diff --git a/app/views/initiative_statuses/edit.html.erb b/app/views/initiative_statuses/edit.html.erb
new file mode 100644
index 0000000..84fa226
--- /dev/null
+++ b/app/views/initiative_statuses/edit.html.erb
@@ -0,0 +1,6 @@
+Editing Initiative Status
+
+<%= render 'form', initiative_status: @initiative_status %>
+
+<%= link_to 'Show', @initiative_status %> |
+<%= link_to 'Back', initiative_statuses_path %>
diff --git a/app/views/initiative_statuses/index.html.erb b/app/views/initiative_statuses/index.html.erb
new file mode 100644
index 0000000..84e1d62
--- /dev/null
+++ b/app/views/initiative_statuses/index.html.erb
@@ -0,0 +1,29 @@
+<%= notice %>
+
+Initiative Statuses
+
+
+
+
+ Name |
+ Description |
+ |
+
+
+
+
+ <% @initiative_statuses.each do |initiative_status| %>
+
+ <%= initiative_status.name %> |
+ <%= initiative_status.description %> |
+ <%= link_to 'Show', initiative_status %> |
+ <%= link_to 'Edit', edit_initiative_status_path(initiative_status) %> |
+ <%= link_to 'Destroy', initiative_status, method: :delete, data: { confirm: 'Are you sure?' } %> |
+
+ <% end %>
+
+
+
+
+
+<%= link_to 'New Initiative Status', new_initiative_status_path %>
diff --git a/app/views/initiative_statuses/new.html.erb b/app/views/initiative_statuses/new.html.erb
new file mode 100644
index 0000000..f2f4909
--- /dev/null
+++ b/app/views/initiative_statuses/new.html.erb
@@ -0,0 +1,5 @@
+New Initiative Status
+
+<%= render 'form', initiative_status: @initiative_status %>
+
+<%= link_to 'Back', initiative_statuses_path %>
diff --git a/app/views/initiative_statuses/show.html.erb b/app/views/initiative_statuses/show.html.erb
new file mode 100644
index 0000000..e52c265
--- /dev/null
+++ b/app/views/initiative_statuses/show.html.erb
@@ -0,0 +1,14 @@
+<%= notice %>
+
+
+ Name:
+ <%= @initiative_status.name %>
+
+
+
+ Description:
+ <%= @initiative_status.description %>
+
+
+<%= link_to 'Edit', edit_initiative_status_path(@initiative_status) %> |
+<%= link_to 'Back', initiative_statuses_path %>
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index 572fbde..6664d61 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -16,6 +16,9 @@
<%= link_to 'Home', root_path %>
<%= link_to 'Sign in', new_user_session_path unless user_signed_in? %>
<%= link_to 'Sign out', destroy_user_session_path if user_signed_in? %>
+ <%= link_to 'Groups', groups_path if user_signed_in? %>
+ <%= link_to 'Group Types', group_types_path if user_signed_in? %>
+ <%= link_to 'Iniative Statuses', initiative_statuses_path if user_signed_in? %>
<% if notice || alert %>
diff --git a/app/views/tags/_form.html.erb b/app/views/tags/_form.html.erb
new file mode 100644
index 0000000..58d9ab9
--- /dev/null
+++ b/app/views/tags/_form.html.erb
@@ -0,0 +1,22 @@
+<%= form_with(model: tag, local: true) do |form| %>
+ <% if tag.errors.any? %>
+
+
<%= pluralize(tag.errors.count, "error") %> prohibited this tag from being saved:
+
+
+ <% tag.errors.full_messages.each do |message| %>
+ - <%= message %>
+ <% end %>
+
+
+ <% end %>
+
+
+ <%= form.label :name %>
+ <%= form.text_field :name %>
+
+
+
+ <%= form.submit %>
+
+<% end %>
diff --git a/app/views/tags/edit.html.erb b/app/views/tags/edit.html.erb
new file mode 100644
index 0000000..97f6701
--- /dev/null
+++ b/app/views/tags/edit.html.erb
@@ -0,0 +1,6 @@
+Editing Tag
+
+<%= render 'form', tag: @tag %>
+
+<%= link_to 'Show', @tag %> |
+<%= link_to 'Back', tags_path %>
diff --git a/app/views/tags/index.html.erb b/app/views/tags/index.html.erb
new file mode 100644
index 0000000..dc4b424
--- /dev/null
+++ b/app/views/tags/index.html.erb
@@ -0,0 +1,27 @@
+<%= notice %>
+
+Tags
+
+
+
+
+ Name |
+ |
+
+
+
+
+ <% @tags.each do |tag| %>
+
+ <%= tag.name %> |
+ <%= link_to 'Show', tag %> |
+ <%= link_to 'Edit', edit_tag_path(tag) %> |
+ <%= link_to 'Destroy', tag, method: :delete, data: { confirm: 'Are you sure?' } %> |
+
+ <% end %>
+
+
+
+
+
+<%= link_to 'New Tag', new_tag_path %>
diff --git a/app/views/tags/new.html.erb b/app/views/tags/new.html.erb
new file mode 100644
index 0000000..db40fd5
--- /dev/null
+++ b/app/views/tags/new.html.erb
@@ -0,0 +1,5 @@
+New Tag
+
+<%= render 'form', tag: @tag %>
+
+<%= link_to 'Back', tags_path %>
diff --git a/app/views/tags/show.html.erb b/app/views/tags/show.html.erb
new file mode 100644
index 0000000..6ee25e6
--- /dev/null
+++ b/app/views/tags/show.html.erb
@@ -0,0 +1,9 @@
+<%= notice %>
+
+
+ Name:
+ <%= @tag.name %>
+
+
+<%= link_to 'Edit', edit_tag_path(@tag) %> |
+<%= link_to 'Back', tags_path %>
diff --git a/bin/bundle b/bin/bundle
index 4f5e057..e9a8073 100755
--- a/bin/bundle
+++ b/bin/bundle
@@ -8,46 +8,46 @@
# this file is here to facilitate running it.
#
-require "rubygems"
+require 'rubygems'
m = Module.new do
module_function
def invoked_as_script?
- File.expand_path($0) == File.expand_path(__FILE__)
+ File.expand_path($PROGRAM_NAME) == File.expand_path(__FILE__)
end
def env_var_version
- ENV["BUNDLER_VERSION"]
+ ENV['BUNDLER_VERSION']
end
def cli_arg_version
return unless invoked_as_script? # don't want to hijack other binstubs
- return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
+ return unless 'update'.start_with?(ARGV.first || ' ') # must be running `bundle update`
+
bundler_version = nil
update_index = nil
ARGV.each_with_index do |a, i|
- if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
- bundler_version = a
- end
+ bundler_version = a if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
- bundler_version = $1 || ">= 0.a"
+
+ bundler_version = Regexp.last_match(1) || '>= 0.a'
update_index = i
end
bundler_version
end
def gemfile
- gemfile = ENV["BUNDLE_GEMFILE"]
- return gemfile if gemfile && !gemfile.empty?
+ gemfile = ENV['BUNDLE_GEMFILE']
+ return gemfile if gemfile.present?
- File.expand_path("../../Gemfile", __FILE__)
+ File.expand_path('../Gemfile', __dir__)
end
def lockfile
lockfile =
case File.basename(gemfile)
- when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
+ when 'gems.rb' then gemfile.sub(/\.rb$/, gemfile)
else "#{gemfile}.lock"
end
File.expand_path(lockfile)
@@ -55,8 +55,10 @@ m = Module.new do
def lockfile_version
return unless File.file?(lockfile)
+
lockfile_contents = File.read(lockfile)
return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
+
Regexp.last_match(1)
end
@@ -68,24 +70,26 @@ m = Module.new do
end
def load_bundler!
- ENV["BUNDLE_GEMFILE"] ||= gemfile
+ ENV['BUNDLE_GEMFILE'] ||= gemfile
# must dup string for RG < 1.8 compatibility
activate_bundler(bundler_version.dup)
end
def activate_bundler(bundler_version)
- if Gem::Version.correct?(bundler_version) && Gem::Version.new(bundler_version).release < Gem::Version.new("2.0")
- bundler_version = "< 2"
+ if Gem::Version.correct?(bundler_version) && Gem::Version.new(bundler_version).release < Gem::Version.new('2.0')
+ bundler_version = '< 2'
end
gem_error = activation_error_handling do
- gem "bundler", bundler_version
+ gem 'bundler', bundler_version
end
return if gem_error.nil?
+
require_error = activation_error_handling do
- require "bundler/version"
+ require 'bundler/version'
end
return if require_error.nil? && Gem::Requirement.new(bundler_version).satisfied_by?(Gem::Version.new(Bundler::VERSION))
+
warn "Activating bundler (#{bundler_version}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_version}'`"
exit 42
end
@@ -100,6 +104,4 @@ end
m.load_bundler!
-if m.invoked_as_script?
- load Gem.bin_path("bundler", "bundle")
-end
+load Gem.bin_path('bundler', 'bundle') if m.invoked_as_script?
diff --git a/bin/rails b/bin/rails
index 5badb2f..3504c3f 100755
--- a/bin/rails
+++ b/bin/rails
@@ -1,6 +1,8 @@
#!/usr/bin/env ruby
+# frozen_string_literal: true
+
begin
- load File.expand_path('../spring', __FILE__)
+ load File.expand_path('spring', __dir__)
rescue LoadError => e
raise unless e.message.include?('spring')
end
diff --git a/bin/rake b/bin/rake
index d87d5f5..1fe6cf0 100755
--- a/bin/rake
+++ b/bin/rake
@@ -1,6 +1,8 @@
#!/usr/bin/env ruby
+# frozen_string_literal: true
+
begin
- load File.expand_path('../spring', __FILE__)
+ load File.expand_path('spring', __dir__)
rescue LoadError => e
raise unless e.message.include?('spring')
end
diff --git a/bin/setup b/bin/setup
index 5853b5e..ac9f624 100755
--- a/bin/setup
+++ b/bin/setup
@@ -1,4 +1,6 @@
#!/usr/bin/env ruby
+# frozen_string_literal: true
+
require 'fileutils'
# path to your application root.
diff --git a/bin/spring b/bin/spring
index d89ee49..1c6eabf 100755
--- a/bin/spring
+++ b/bin/spring
@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
+# frozen_string_literal: true
# This file loads Spring without using Bundler, in order to be fast.
# It gets overwritten when you run the `spring binstub` command.
diff --git a/bin/webpack b/bin/webpack
index 008ecb2..31ea498 100755
--- a/bin/webpack
+++ b/bin/webpack
@@ -1,19 +1,20 @@
#!/usr/bin/env ruby
+# frozen_string_literal: true
-ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development"
-ENV["NODE_ENV"] ||= "development"
+ENV['RAILS_ENV'] ||= ENV['RACK_ENV'] || 'development'
+ENV['NODE_ENV'] ||= 'development'
-require "pathname"
-ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
- Pathname.new(__FILE__).realpath)
+require 'pathname'
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
+ Pathname.new(__FILE__).realpath)
-require "rubygems"
-require "bundler/setup"
+require 'rubygems'
+require 'bundler/setup'
-require "webpacker"
-require "webpacker/webpack_runner"
+require 'webpacker'
+require 'webpacker/webpack_runner'
-APP_ROOT = File.expand_path("..", __dir__)
+APP_ROOT = File.expand_path('..', __dir__)
Dir.chdir(APP_ROOT) do
Webpacker::WebpackRunner.run(ARGV)
end
diff --git a/bin/webpack-dev-server b/bin/webpack-dev-server
index a931a9b..41e6035 100755
--- a/bin/webpack-dev-server
+++ b/bin/webpack-dev-server
@@ -1,19 +1,20 @@
#!/usr/bin/env ruby
+# frozen_string_literal: true
-ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development"
-ENV["NODE_ENV"] ||= "development"
+ENV['RAILS_ENV'] ||= ENV['RACK_ENV'] || 'development'
+ENV['NODE_ENV'] ||= 'development'
-require "pathname"
-ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
- Pathname.new(__FILE__).realpath)
+require 'pathname'
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
+ Pathname.new(__FILE__).realpath)
-require "rubygems"
-require "bundler/setup"
+require 'rubygems'
+require 'bundler/setup'
-require "webpacker"
-require "webpacker/dev_server_runner"
+require 'webpacker'
+require 'webpacker/dev_server_runner'
-APP_ROOT = File.expand_path("..", __dir__)
+APP_ROOT = File.expand_path('..', __dir__)
Dir.chdir(APP_ROOT) do
Webpacker::DevServerRunner.run(ARGV)
end
diff --git a/bin/yarn b/bin/yarn
index 460dd56..4cac416 100755
--- a/bin/yarn
+++ b/bin/yarn
@@ -1,11 +1,11 @@
#!/usr/bin/env ruby
+# frozen_string_literal: true
+
APP_ROOT = File.expand_path('..', __dir__)
Dir.chdir(APP_ROOT) do
- begin
- exec "yarnpkg", *ARGV
- rescue Errno::ENOENT
- $stderr.puts "Yarn executable was not detected in the system."
- $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
- exit 1
- end
+ exec 'yarnpkg', *ARGV
+rescue Errno::ENOENT
+ warn 'Yarn executable was not detected in the system.'
+ warn 'Download Yarn at https://yarnpkg.com/en/docs/install'
+ exit 1
end
diff --git a/config.ru b/config.ru
index f7ba0b5..842bccc 100644
--- a/config.ru
+++ b/config.ru
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
# This file is used by Rack-based servers to start the application.
require_relative 'config/environment'
diff --git a/config/application.rb b/config/application.rb
index 994f7fc..9e2578a 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require_relative 'boot'
require 'rails/all'
diff --git a/config/boot.rb b/config/boot.rb
index b9e460c..c04863f 100644
--- a/config/boot.rb
+++ b/config/boot.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
require 'bundler/setup' # Set up gems listed in the Gemfile.
diff --git a/config/environment.rb b/config/environment.rb
index 426333b..d5abe55 100644
--- a/config/environment.rb
+++ b/config/environment.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
# Load the Rails application.
require_relative 'application'
diff --git a/config/initializers/application_controller_renderer.rb b/config/initializers/application_controller_renderer.rb
index 89d2efa..6d56e43 100644
--- a/config/initializers/application_controller_renderer.rb
+++ b/config/initializers/application_controller_renderer.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
# Be sure to restart your server when you modify this file.
# ActiveSupport::Reloader.to_prepare do
diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb
index 4b828e8..a9b0d0f 100644
--- a/config/initializers/assets.rb
+++ b/config/initializers/assets.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
# Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets.
diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb
index 59385cd..4b63f28 100644
--- a/config/initializers/backtrace_silencers.rb
+++ b/config/initializers/backtrace_silencers.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
# Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb
index 35d0f26..9c49284 100644
--- a/config/initializers/content_security_policy.rb
+++ b/config/initializers/content_security_policy.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
# Be sure to restart your server when you modify this file.
# Define an application-wide content security policy
diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb
index 5a6a32d..ee8dff9 100644
--- a/config/initializers/cookies_serializer.rb
+++ b/config/initializers/cookies_serializer.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
# Be sure to restart your server when you modify this file.
# Specify a serializer for the signed and encrypted cookie jars.
diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb
index ac033bf..dc84742 100644
--- a/config/initializers/inflections.rb
+++ b/config/initializers/inflections.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format. Inflections
diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb
index dc18996..be6fedc 100644
--- a/config/initializers/mime_types.rb
+++ b/config/initializers/mime_types.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
# Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
diff --git a/config/routes.rb b/config/routes.rb
index 772f9c6..ba0031e 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,12 +1,15 @@
# frozen_string_literal: true
Rails.application.routes.draw do
- resource :address, only: %i[edit update]
- get '/address' => 'addresses#edit'
- resources :subscriptions, only: %i[new create update index show]
+ resources :groups do
+ resources :group_websites
+ end
+ resources :tags
+ scope '/admin' do
+ resources :initiative_statuses
+ resources :group_types
+ end
devise_for :users
- get 'home/index'
- get '/thanks' => 'home#thanks'
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
root 'home#index'
end
diff --git a/db/migrate/20190830160313_devise_create_users.rb b/db/migrate/20190830160313_devise_create_users.rb
index d28b78b..830d394 100644
--- a/db/migrate/20190830160313_devise_create_users.rb
+++ b/db/migrate/20190830160313_devise_create_users.rb
@@ -5,7 +5,7 @@ def change
create_table :users do |t|
## Database authenticatable
t.string :email,
- null: false, default: ''
+ null: false, default: ''
t.string :encrypted_password, null: false, default: ''
## Recoverable
diff --git a/db/migrate/20190919213519_create_initiative_statuses.rb b/db/migrate/20190919213519_create_initiative_statuses.rb
new file mode 100644
index 0000000..e16adf9
--- /dev/null
+++ b/db/migrate/20190919213519_create_initiative_statuses.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+class CreateInitiativeStatuses < ActiveRecord::Migration[6.0]
+ def change
+ create_table :initiative_statuses do |t|
+ t.string :name
+ t.string :description
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20190919213829_create_tags.rb b/db/migrate/20190919213829_create_tags.rb
new file mode 100644
index 0000000..c95b197
--- /dev/null
+++ b/db/migrate/20190919213829_create_tags.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class CreateTags < ActiveRecord::Migration[6.0]
+ def change
+ create_table :tags do |t|
+ t.string :name
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20190919213923_create_group_types.rb b/db/migrate/20190919213923_create_group_types.rb
new file mode 100644
index 0000000..b1b5f02
--- /dev/null
+++ b/db/migrate/20190919213923_create_group_types.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class CreateGroupTypes < ActiveRecord::Migration[6.0]
+ def change
+ create_table :group_types do |t|
+ t.string :name
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20190919214023_create_groups.rb b/db/migrate/20190919214023_create_groups.rb
new file mode 100644
index 0000000..586b49a
--- /dev/null
+++ b/db/migrate/20190919214023_create_groups.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class CreateGroups < ActiveRecord::Migration[6.0]
+ def change
+ create_table :groups do |t|
+ t.string :name
+ t.string :abbreviation
+ t.string :opening_hours
+ t.string :contact_name
+ t.string :contact_email
+ t.string :contact_phone
+ t.boolean :gdpr
+ t.boolean :gdpr_email_verified
+ t.references :owner
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20190919222547_create_group_websites.rb b/db/migrate/20190919222547_create_group_websites.rb
new file mode 100644
index 0000000..057802f
--- /dev/null
+++ b/db/migrate/20190919222547_create_group_websites.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+class CreateGroupWebsites < ActiveRecord::Migration[6.0]
+ def change
+ create_table :group_websites do |t|
+ t.string :website
+ t.references :group, null: false, foreign_key: true
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20191001200104_create_group_group_types.rb b/db/migrate/20191001200104_create_group_group_types.rb
new file mode 100644
index 0000000..48345e0
--- /dev/null
+++ b/db/migrate/20191001200104_create_group_group_types.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+class CreateGroupGroupTypes < ActiveRecord::Migration[6.0]
+ def change
+ create_table :group_group_types do |t|
+ t.references :group, null: false, foreign_key: true
+ t.references :group_type, null: false, foreign_key: true
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 6553f6b..bee2110 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,58 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 2019_08_30_160313) do
+ActiveRecord::Schema.define(version: 2019_10_01_200104) do
+
+ create_table "group_group_types", force: :cascade do |t|
+ t.integer "group_id", null: false
+ t.integer "group_type_id", null: false
+ t.datetime "created_at", precision: 6, null: false
+ t.datetime "updated_at", precision: 6, null: false
+ t.index ["group_id"], name: "index_group_group_types_on_group_id"
+ t.index ["group_type_id"], name: "index_group_group_types_on_group_type_id"
+ end
+
+ create_table "group_types", force: :cascade do |t|
+ t.string "name"
+ t.datetime "created_at", precision: 6, null: false
+ t.datetime "updated_at", precision: 6, null: false
+ end
+
+ create_table "group_websites", force: :cascade do |t|
+ t.string "website"
+ t.integer "group_id", null: false
+ t.datetime "created_at", precision: 6, null: false
+ t.datetime "updated_at", precision: 6, null: false
+ t.index ["group_id"], name: "index_group_websites_on_group_id"
+ end
+
+ create_table "groups", force: :cascade do |t|
+ t.string "name"
+ t.string "abbreviation"
+ t.string "opening_hours"
+ t.string "contact_name"
+ t.string "contact_email"
+ t.string "contact_phone"
+ t.boolean "gdpr"
+ t.boolean "gdpr_email_verified"
+ t.integer "owner_id"
+ t.datetime "created_at", precision: 6, null: false
+ t.datetime "updated_at", precision: 6, null: false
+ t.index ["owner_id"], name: "index_groups_on_owner_id"
+ end
+
+ create_table "initiative_statuses", force: :cascade do |t|
+ t.string "name"
+ t.string "description"
+ t.datetime "created_at", precision: 6, null: false
+ t.datetime "updated_at", precision: 6, null: false
+ end
+
+ create_table "tags", force: :cascade do |t|
+ t.string "name"
+ t.datetime "created_at", precision: 6, null: false
+ t.datetime "updated_at", precision: 6, null: false
+ end
create_table "users", force: :cascade do |t|
t.string "email", default: "", null: false
@@ -24,4 +75,7 @@
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
end
+ add_foreign_key "group_group_types", "group_types"
+ add_foreign_key "group_group_types", "groups"
+ add_foreign_key "group_websites", "groups"
end
diff --git a/db/seeds.rb b/db/seeds.rb
index 145f44b..ebd1889 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
@@ -5,4 +7,3 @@
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Character.create(name: 'Luke', movie: movies.first)
-
diff --git a/test/controllers/group_types_controller_test.rb b/test/controllers/group_types_controller_test.rb
new file mode 100644
index 0000000..e865815
--- /dev/null
+++ b/test/controllers/group_types_controller_test.rb
@@ -0,0 +1,57 @@
+# frozen_string_literal: true
+
+require 'test_helper'
+
+class GroupTypesControllerTest < ActionDispatch::IntegrationTest
+ setup do
+ @group_type = group_types(:one)
+ end
+
+ test 'should get index' do
+ sign_in_as :georgie
+ get group_types_url
+ assert_response :success
+ end
+
+ test 'should get new' do
+ sign_in_as :georgie
+ get new_group_type_url
+ assert_response :success
+ end
+
+ test 'should create group_type' do
+ sign_in_as :georgie
+ assert_difference('GroupType.count') do
+ post group_types_url, params: { group_type: { name: @group_type.name } }
+ end
+
+ assert_redirected_to group_type_url(GroupType.last)
+ end
+
+ test 'should show group_type' do
+ sign_in_as :georgie
+ get group_type_url(@group_type)
+ assert_response :success
+ end
+
+ test 'should get edit' do
+ sign_in_as :georgie
+ get edit_group_type_url(@group_type)
+ assert_response :success
+ end
+
+ test 'should update group_type' do
+ sign_in_as :georgie
+ patch group_type_url(@group_type), params: { group_type: { name: @group_type.name } }
+ assert_redirected_to group_type_url(@group_type)
+ end
+
+ test 'should destroy group_type' do
+ sign_in_as :georgie
+ assert_difference('GroupType.count', -1) do
+ delete group_type_url(@group_type)
+ end
+
+ assert_redirected_to group_types_url
+ end
+end
diff --git a/test/controllers/group_websites_controller_test.rb b/test/controllers/group_websites_controller_test.rb
new file mode 100644
index 0000000..0202b5c
--- /dev/null
+++ b/test/controllers/group_websites_controller_test.rb
@@ -0,0 +1,62 @@
+# frozen_string_literal: true
+
+require 'test_helper'
+
+class GroupWebsitesControllerTest < ActionDispatch::IntegrationTest
+ setup do
+ @group = groups(:one)
+ @group_website = group_websites(:one)
+ end
+
+ test 'should get index' do
+ sign_in_as :georgie
+ get group_group_websites_url(@group)
+ assert_response :success
+ end
+
+ test 'should get new' do
+ sign_in_as :georgie
+ get new_group_group_website_url @group
+ assert_response :success
+ end
+
+ test 'should create group_website' do
+ sign_in_as :georgie
+ assert_difference('@group.websites.count') do
+ post group_group_websites_url(@group), params: {
+ group_website: { website: 'http://new.website' }
+ }
+ end
+
+ assert_redirected_to group_group_website_url(@group, GroupWebsite.last)
+ end
+
+ test 'should show group_website' do
+ sign_in_as :georgie
+ get group_group_website_url(@group, @group_website)
+ assert_response :success
+ end
+
+ test 'should get edit' do
+ sign_in_as :georgie
+ get edit_group_group_website_url(@group, @group_website)
+ assert_response :success
+ end
+
+ test 'should update group_website' do
+ sign_in_as :georgie
+ patch group_group_website_url(@group, @group_website), params: {
+ group_website: { group: @group_website.group, website: @group_website.website }
+ }
+ assert_redirected_to group_group_website_url(@group, @group_website)
+ end
+
+ test 'should destroy group_website' do
+ sign_in_as :georgie
+ assert_difference('GroupWebsite.count', -1) do
+ delete group_group_website_url(@group, @group_website)
+ end
+
+ assert_redirected_to group_group_websites_url @group
+ end
+end
diff --git a/test/controllers/groups_controller_test.rb b/test/controllers/groups_controller_test.rb
new file mode 100644
index 0000000..39657d7
--- /dev/null
+++ b/test/controllers/groups_controller_test.rb
@@ -0,0 +1,79 @@
+# frozen_string_literal: true
+
+require 'test_helper'
+
+class GroupsControllerTest < ActionDispatch::IntegrationTest
+ setup do
+ @group = groups(:one)
+ end
+
+ test 'should get index' do
+ sign_in_as :georgie
+ get groups_url
+ assert_response :success
+ end
+
+ test 'should get new' do
+ sign_in_as :georgie
+ get new_group_url
+ assert_response :success
+ end
+
+ test 'should create group' do
+ sign_in_as :georgie
+ assert_difference('Group.count') do
+ post groups_url, params: {
+ group: {
+ abbreviation: @group.abbreviation,
+ contact_email: @group.contact_email,
+ contact_name: @group.contact_name,
+ contact_phone: @group.contact_phone,
+ gdpr: @group.gdpr,
+ gdpr_email_verified: @group.gdpr_email_verified,
+ name: @group.name,
+ opening_hours: @group.opening_hours
+ }
+ }
+ end
+
+ assert_redirected_to group_url(Group.last)
+ end
+
+ test 'should show group' do
+ sign_in_as :georgie
+ get group_url(@group)
+ assert_response :success
+ end
+
+ test 'should get edit' do
+ sign_in_as :georgie
+ get edit_group_url(@group)
+ assert_response :success
+ end
+
+ test 'should update group' do
+ sign_in_as :georgie
+ patch group_url(@group), params: {
+ group: {
+ abbreviation: @group.abbreviation,
+ contact_email: @group.contact_email,
+ contact_name: @group.contact_name,
+ contact_phone: @group.contact_phone,
+ gdpr: @group.gdpr,
+ gdpr_email_verified: @group.gdpr_email_verified,
+ name: @group.name,
+ opening_hours: @group.opening_hours
+ }
+ }
+ assert_redirected_to group_url(@group)
+ end
+
+ test 'should destroy group' do
+ sign_in_as :georgie
+ assert_difference('Group.count', -1) do
+ delete group_url(@group)
+ end
+
+ assert_redirected_to groups_url
+ end
+end
diff --git a/test/controllers/initiative_statuses_controller_test.rb b/test/controllers/initiative_statuses_controller_test.rb
new file mode 100644
index 0000000..816d6c8
--- /dev/null
+++ b/test/controllers/initiative_statuses_controller_test.rb
@@ -0,0 +1,61 @@
+# frozen_string_literal: true
+
+require 'test_helper'
+
+class InitiativeStatusesControllerTest < ActionDispatch::IntegrationTest
+ setup do
+ @initiative_status = initiative_statuses(:one)
+ end
+
+ test 'should get index' do
+ sign_in_as :georgie
+ get initiative_statuses_url
+ assert_response :success
+ end
+
+ test 'should get new' do
+ sign_in_as :georgie
+ get new_initiative_status_url
+ assert_response :success
+ end
+
+ test 'should create initiative_status' do
+ sign_in_as :georgie
+ assert_difference('InitiativeStatus.count') do
+ post initiative_statuses_url, params: {
+ initiative_status: { description: @initiative_status.description, name: @initiative_status.name }
+ }
+ end
+
+ assert_redirected_to initiative_status_url(InitiativeStatus.last)
+ end
+
+ test 'should show initiative_status' do
+ sign_in_as :georgie
+ get initiative_status_url(@initiative_status)
+ assert_response :success
+ end
+
+ test 'should get edit' do
+ sign_in_as :georgie
+ get edit_initiative_status_url(@initiative_status)
+ assert_response :success
+ end
+
+ test 'should update initiative_status' do
+ sign_in_as :georgie
+ patch initiative_status_url(@initiative_status), params: {
+ initiative_status: { description: @initiative_status.description, name: @initiative_status.name }
+ }
+ assert_redirected_to initiative_status_url(@initiative_status)
+ end
+
+ test 'should destroy initiative_status' do
+ sign_in_as :georgie
+ assert_difference('InitiativeStatus.count', -1) do
+ delete initiative_status_url(@initiative_status)
+ end
+
+ assert_redirected_to initiative_statuses_url
+ end
+end
diff --git a/test/controllers/tags_controller_test.rb b/test/controllers/tags_controller_test.rb
new file mode 100644
index 0000000..17e236a
--- /dev/null
+++ b/test/controllers/tags_controller_test.rb
@@ -0,0 +1,57 @@
+# frozen_string_literal: true
+
+require 'test_helper'
+
+class TagsControllerTest < ActionDispatch::IntegrationTest
+ setup do
+ @tag = tags(:one)
+ end
+
+ test 'should get index' do
+ sign_in_as :georgie
+ get tags_url
+ assert_response :success
+ end
+
+ test 'should get new' do
+ sign_in_as :georgie
+ get new_tag_url
+ assert_response :success
+ end
+
+ test 'should create tag' do
+ sign_in_as :georgie
+ assert_difference('Tag.count') do
+ post tags_url, params: { tag: { name: @tag.name } }
+ end
+
+ assert_redirected_to tag_url(Tag.last)
+ end
+
+ test 'should show tag' do
+ sign_in_as :georgie
+ get tag_url(@tag)
+ assert_response :success
+ end
+
+ test 'should get edit' do
+ sign_in_as :georgie
+ get edit_tag_url(@tag)
+ assert_response :success
+ end
+
+ test 'should update tag' do
+ sign_in_as :georgie
+ patch tag_url(@tag), params: { tag: { name: @tag.name } }
+ assert_redirected_to tag_url(@tag)
+ end
+
+ test 'should destroy tag' do
+ sign_in_as :georgie
+ assert_difference('Tag.count', -1) do
+ delete tag_url(@tag)
+ end
+
+ assert_redirected_to tags_url
+ end
+end
diff --git a/test/fixtures/group_group_types.yml b/test/fixtures/group_group_types.yml
new file mode 100644
index 0000000..a905039
--- /dev/null
+++ b/test/fixtures/group_group_types.yml
@@ -0,0 +1 @@
+# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
diff --git a/test/fixtures/group_types.yml b/test/fixtures/group_types.yml
new file mode 100644
index 0000000..c5afb4d
--- /dev/null
+++ b/test/fixtures/group_types.yml
@@ -0,0 +1,7 @@
+# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+one:
+ name: type one
+
+two:
+ name: type two
diff --git a/test/fixtures/group_websites.yml b/test/fixtures/group_websites.yml
new file mode 100644
index 0000000..796e19b
--- /dev/null
+++ b/test/fixtures/group_websites.yml
@@ -0,0 +1,9 @@
+# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+one:
+ website: MyString
+ group: one
+
+two:
+ website: MyString
+ group: two
diff --git a/test/fixtures/groups.yml b/test/fixtures/groups.yml
new file mode 100644
index 0000000..490c424
--- /dev/null
+++ b/test/fixtures/groups.yml
@@ -0,0 +1,23 @@
+# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+one:
+ name: MyString
+ abbreviation: MyString
+ opening_hours: MyString
+ contact_name: MyString
+ contact_email: MyString
+ contact_phone: MyString
+ gdpr: false
+ gdpr_email_verified: false
+ owner: georgie
+
+two:
+ name: MyString
+ abbreviation: MyString
+ opening_hours: MyString
+ contact_name: MyString
+ contact_email: MyString
+ contact_phone: MyString
+ gdpr: false
+ gdpr_email_verified: false
+ owner: georgie
diff --git a/test/fixtures/initiative_statuses.yml b/test/fixtures/initiative_statuses.yml
new file mode 100644
index 0000000..a750ec3
--- /dev/null
+++ b/test/fixtures/initiative_statuses.yml
@@ -0,0 +1,9 @@
+# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+one:
+ name: MyString
+ description: MyString
+
+two:
+ name: MyString
+ description: MyString
diff --git a/test/fixtures/tags.yml b/test/fixtures/tags.yml
new file mode 100644
index 0000000..7d41224
--- /dev/null
+++ b/test/fixtures/tags.yml
@@ -0,0 +1,7 @@
+# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+one:
+ name: MyString
+
+two:
+ name: MyString
diff --git a/test/models/group_group_type_test.rb b/test/models/group_group_type_test.rb
new file mode 100644
index 0000000..d135d69
--- /dev/null
+++ b/test/models/group_group_type_test.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+require 'test_helper'
+
+class GroupGroupTypeTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/models/group_test.rb b/test/models/group_test.rb
new file mode 100644
index 0000000..ae91507
--- /dev/null
+++ b/test/models/group_test.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+require 'test_helper'
+
+class GroupTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/models/group_type_test.rb b/test/models/group_type_test.rb
new file mode 100644
index 0000000..d2c1cff
--- /dev/null
+++ b/test/models/group_type_test.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+require 'test_helper'
+
+class GroupTypeTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/models/group_website_test.rb b/test/models/group_website_test.rb
new file mode 100644
index 0000000..46a57b5
--- /dev/null
+++ b/test/models/group_website_test.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+require 'test_helper'
+
+class GroupWebsiteTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/models/initiative_status_test.rb b/test/models/initiative_status_test.rb
new file mode 100644
index 0000000..634ba03
--- /dev/null
+++ b/test/models/initiative_status_test.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+require 'test_helper'
+
+class InitiativeStatusTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/models/tag_test.rb b/test/models/tag_test.rb
new file mode 100644
index 0000000..faf64bc
--- /dev/null
+++ b/test/models/tag_test.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+require 'test_helper'
+
+class TagTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/models/user_test.rb b/test/models/user_test.rb
index 82f61e0..5cc44ed 100644
--- a/test/models/user_test.rb
+++ b/test/models/user_test.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'test_helper'
class UserTest < ActiveSupport::TestCase
diff --git a/test/system/group_types_test.rb b/test/system/group_types_test.rb
new file mode 100644
index 0000000..3d3408a
--- /dev/null
+++ b/test/system/group_types_test.rb
@@ -0,0 +1,45 @@
+# frozen_string_literal: true
+
+require 'application_system_test_case'
+
+class GroupTypesTest < ApplicationSystemTestCase
+ setup do
+ @group_type = group_types(:one)
+ end
+
+ test 'visiting the index' do
+ visit group_types_url
+ assert_selector 'h1', text: 'Group Types'
+ end
+
+ test 'creating a Group type' do
+ visit group_types_url
+ click_on 'New Group Type'
+
+ fill_in 'Name', with: @group_type.name
+ click_on 'Create Group type'
+
+ assert_text 'Group type was successfully created'
+ click_on 'Back'
+ end
+
+ test 'updating a Group type' do
+ visit group_types_url
+ click_on 'Edit', match: :first
+
+ fill_in 'Name', with: @group_type.name
+ click_on 'Update Group type'
+
+ assert_text 'Group type was successfully updated'
+ click_on 'Back'
+ end
+
+ test 'destroying a Group type' do
+ visit group_types_url
+ page.accept_confirm do
+ click_on 'Destroy', match: :first
+ end
+
+ assert_text 'Group type was successfully destroyed'
+ end
+end
diff --git a/test/system/group_websites_test.rb b/test/system/group_websites_test.rb
new file mode 100644
index 0000000..46b177a
--- /dev/null
+++ b/test/system/group_websites_test.rb
@@ -0,0 +1,47 @@
+# frozen_string_literal: true
+
+require 'application_system_test_case'
+
+class GroupWebsitesTest < ApplicationSystemTestCase
+ setup do
+ @group_website = group_websites(:one)
+ end
+
+ test 'visiting the index' do
+ visit group_websites_url
+ assert_selector 'h1', text: 'Group Websites'
+ end
+
+ test 'creating a Group website' do
+ visit group_websites_url
+ click_on 'New Group Website'
+
+ fill_in 'Group', with: @group_website.group
+ fill_in 'Website', with: @group_website.website
+ click_on 'Create Group website'
+
+ assert_text 'Group website was successfully created'
+ click_on 'Back'
+ end
+
+ test 'updating a Group website' do
+ visit group_websites_url
+ click_on 'Edit', match: :first
+
+ fill_in 'Group', with: @group_website.group
+ fill_in 'Website', with: @group_website.website
+ click_on 'Update Group website'
+
+ assert_text 'Group website was successfully updated'
+ click_on 'Back'
+ end
+
+ test 'destroying a Group website' do
+ visit group_websites_url
+ page.accept_confirm do
+ click_on 'Destroy', match: :first
+ end
+
+ assert_text 'Group website was successfully destroyed'
+ end
+end
diff --git a/test/system/groups_test.rb b/test/system/groups_test.rb
new file mode 100644
index 0000000..ef6397f
--- /dev/null
+++ b/test/system/groups_test.rb
@@ -0,0 +1,59 @@
+# frozen_string_literal: true
+
+require 'application_system_test_case'
+
+class GroupsTest < ApplicationSystemTestCase
+ setup do
+ @group = groups(:one)
+ end
+
+ test 'visiting the index' do
+ visit groups_url
+ assert_selector 'h1', text: 'Groups'
+ end
+
+ test 'creating a Group' do
+ visit groups_url
+ click_on 'New Group'
+
+ fill_in 'Abbreviation', with: @group.abbreviation
+ fill_in 'Contact email', with: @group.contact_email
+ fill_in 'Contact name', with: @group.contact_name
+ fill_in 'Contact phone', with: @group.contact_phone
+ check 'Gdpr' if @group.gdpr
+ check 'Gdpr email verified' if @group.gdpr_email_verified
+ fill_in 'Name', with: @group.name
+ fill_in 'Opening hours', with: @group.opening_hours
+ click_on 'Create Group'
+
+ assert_text 'Group was successfully created'
+ click_on 'Back'
+ end
+
+ test 'updating a Group' do
+ visit groups_url
+ click_on 'Edit', match: :first
+
+ fill_in 'Abbreviation', with: @group.abbreviation
+ fill_in 'Contact email', with: @group.contact_email
+ fill_in 'Contact name', with: @group.contact_name
+ fill_in 'Contact phone', with: @group.contact_phone
+ check 'Gdpr' if @group.gdpr
+ check 'Gdpr email verified' if @group.gdpr_email_verified
+ fill_in 'Name', with: @group.name
+ fill_in 'Opening hours', with: @group.opening_hours
+ click_on 'Update Group'
+
+ assert_text 'Group was successfully updated'
+ click_on 'Back'
+ end
+
+ test 'destroying a Group' do
+ visit groups_url
+ page.accept_confirm do
+ click_on 'Destroy', match: :first
+ end
+
+ assert_text 'Group was successfully destroyed'
+ end
+end
diff --git a/test/system/initiative_statuses_test.rb b/test/system/initiative_statuses_test.rb
new file mode 100644
index 0000000..2154848
--- /dev/null
+++ b/test/system/initiative_statuses_test.rb
@@ -0,0 +1,47 @@
+# frozen_string_literal: true
+
+require 'application_system_test_case'
+
+class InitiativeStatusesTest < ApplicationSystemTestCase
+ setup do
+ @initiative_status = initiative_statuses(:one)
+ end
+
+ test 'visiting the index' do
+ visit initiative_statuses_url
+ assert_selector 'h1', text: 'Initiative Statuses'
+ end
+
+ test 'creating a Initiative status' do
+ visit initiative_statuses_url
+ click_on 'New Initiative Status'
+
+ fill_in 'Description', with: @initiative_status.description
+ fill_in 'Name', with: @initiative_status.name
+ click_on 'Create Initiative status'
+
+ assert_text 'Initiative status was successfully created'
+ click_on 'Back'
+ end
+
+ test 'updating a Initiative status' do
+ visit initiative_statuses_url
+ click_on 'Edit', match: :first
+
+ fill_in 'Description', with: @initiative_status.description
+ fill_in 'Name', with: @initiative_status.name
+ click_on 'Update Initiative status'
+
+ assert_text 'Initiative status was successfully updated'
+ click_on 'Back'
+ end
+
+ test 'destroying a Initiative status' do
+ visit initiative_statuses_url
+ page.accept_confirm do
+ click_on 'Destroy', match: :first
+ end
+
+ assert_text 'Initiative status was successfully destroyed'
+ end
+end
diff --git a/test/system/tags_test.rb b/test/system/tags_test.rb
new file mode 100644
index 0000000..08a19f4
--- /dev/null
+++ b/test/system/tags_test.rb
@@ -0,0 +1,45 @@
+# frozen_string_literal: true
+
+require 'application_system_test_case'
+
+class TagsTest < ApplicationSystemTestCase
+ setup do
+ @tag = tags(:one)
+ end
+
+ test 'visiting the index' do
+ visit tags_url
+ assert_selector 'h1', text: 'Tags'
+ end
+
+ test 'creating a Tag' do
+ visit tags_url
+ click_on 'New Tag'
+
+ fill_in 'Name', with: @tag.name
+ click_on 'Create Tag'
+
+ assert_text 'Tag was successfully created'
+ click_on 'Back'
+ end
+
+ test 'updating a Tag' do
+ visit tags_url
+ click_on 'Edit', match: :first
+
+ fill_in 'Name', with: @tag.name
+ click_on 'Update Tag'
+
+ assert_text 'Tag was successfully updated'
+ click_on 'Back'
+ end
+
+ test 'destroying a Tag' do
+ visit tags_url
+ page.accept_confirm do
+ click_on 'Destroy', match: :first
+ end
+
+ assert_text 'Tag was successfully destroyed'
+ end
+end
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 47534f1..ef11d70 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -16,10 +16,10 @@ class TestCase
def sign_in_as(key, with_password: 'password')
user = users key
post user_session_url params: {
- user: {
- email: user.email, password: with_password
- }
- }
+ user: {
+ email: user.email, password: with_password
+ }
+ }
end
end
end