diff --git a/Dockerfile b/Dockerfile index 85ac6d0..f302cd8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ # Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile ARG RUBY_VERSION=3.3.4 -FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim as base +FROM ruby:$RUBY_VERSION-slim as base # Rails app lives here WORKDIR /rails diff --git a/Dockerfile.development b/Dockerfile.development index 2405d8d..60c0962 100644 --- a/Dockerfile.development +++ b/Dockerfile.development @@ -2,7 +2,7 @@ # Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile ARG RUBY_VERSION=3.3.4 -FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim as base +FROM ruby:$RUBY_VERSION-slim as base # Rails app lives here WORKDIR /rails diff --git a/README.md b/README.md index e7e621e..8d95b17 100644 --- a/README.md +++ b/README.md @@ -8,16 +8,22 @@ The software is still a work in progress. Expect huge variations. I suggest you to use [asdf](https://asdf-vm.com/) Install ruby 3.3.4 +Start the needed services with docker compose: + +``` +docker compose up -d +``` + Create the database and seeds: ``` -bundle exec rails db:create db:migrate db:seed +bin/rails db:create db:migrate db:seed ``` To run the server: ``` -bundle exec rails s +bin/rails s ``` You an reach the app at https://localhost:3000 @@ -27,7 +33,14 @@ You an reach the app at https://localhost:3000 Run: ``` -bundle exec rails test +# application tests +bin/rails test + +# system tests (E2E) +bin/rails test:system + +# all +bin/rails test:all ``` ## Lint @@ -39,4 +52,34 @@ Run: ``` bundle exec rubocop bundle exec htmlbeautifier filename -``` \ No newline at end of file +``` + +## Deploy + +We use [kamal](https://github.com/basecamp/kamal) for deploying. + +Copy the `.env` file: + +``` +cp .env.example .env +``` + +Configure your env variables. + +The first time (after having configured you server), run: + +``` +bundle exec kamal setup +``` + +For pushing envs or changing those, run: + +``` +bundle exec kamal env push +``` + +Then: + +``` +bundle exec kamal deploy +``` diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index 98953d9..b310e4c 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -1,2 +1 @@ -

Il gestionale open source per le associazioni sportive italiane

- +

<%= I18n.t('gas_title') %>

diff --git a/config/locales/it.yml b/config/locales/it.yml index 0cfe914..fc7afb7 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -28,6 +28,7 @@ # enabled: "ON" it: + gas_title: Il gestionale open source per le associazioni sportive italiane warning: Attenzione problems: Problemi actions: Azioni diff --git a/test/models/presence_test.rb b/test/models/presence_test.rb index 509f398..dc647e4 100644 --- a/test/models/presence_test.rb +++ b/test/models/presence_test.rb @@ -6,7 +6,6 @@ class PresenceTest < ActiveSupport::TestCase test 'valudates presence' do presence = Presence.create - assert(presence.errors.key?('event')) assert(presence.errors.key?('member')) assert(presence.errors.key?('date')) end diff --git a/test/system/registration_test.rb b/test/system/registration_test.rb new file mode 100644 index 0000000..0ebe8f3 --- /dev/null +++ b/test/system/registration_test.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require 'application_system_test_case' + +class RegistrationTest < ApplicationSystemTestCase + test 'register user' do + visit new_user_registration_url + + fill_in 'user_email', with: 'email@email.com' + fill_in 'user_first_name', with: 'Name' + fill_in 'user_last_name', with: 'Cognome' + fill_in 'user_password', with: 'password' + fill_in 'user_password_confirmation', with: 'password' + + click_on 'commit' + + assert_selector 'h1', text: I18n.t('gas_title') + + registered_user = User.first + assert registered_user.present? + assert registered_user.club.present? + end +end diff --git a/test/test_helpers/system_test_helper.rb b/test/test_helpers/system_test_helper.rb new file mode 100644 index 0000000..4b5deb1 --- /dev/null +++ b/test/test_helpers/system_test_helper.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module SystemTestHelper + include ActionView::Helpers::JavaScriptHelper + + def sign_in(email_address, password = 'secret123456') + visit new_session_url + + fill_in 'email_address', with: email_address + fill_in 'password', with: password + + click_on 'log_in' + + assert_selector 'h1', text: 'Dashboard' + end +end