Skip to content

Commit

Permalink
fix tests and better docker file
Browse files Browse the repository at this point in the history
  • Loading branch information
baldarn committed Aug 20, 2024
1 parent 0bc1132 commit 502fd7c
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.development
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
51 changes: 47 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -39,4 +52,34 @@ Run:
```
bundle exec rubocop
bundle exec htmlbeautifier filename
```
```

## 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
```
3 changes: 1 addition & 2 deletions app/views/home/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
<h1 class="text-center">Il gestionale open source per le associazioni sportive italiane</h1>

<h1 class="text-center"><%= I18n.t('gas_title') %></h1>
1 change: 1 addition & 0 deletions config/locales/it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
# enabled: "ON"

it:
gas_title: Il gestionale open source per le associazioni sportive italiane
warning: Attenzione
problems: Problemi
actions: Azioni
Expand Down
1 change: 0 additions & 1 deletion test/models/presence_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions test/system/registration_test.rb
Original file line number Diff line number Diff line change
@@ -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 protected]'
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
16 changes: 16 additions & 0 deletions test/test_helpers/system_test_helper.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 502fd7c

Please sign in to comment.