Merge remote-tracking branch 'origin/main' into vns
Some checks failed
Run unit tests / unit_tests (pull_request) Failing after 30s
Some checks failed
Run unit tests / unit_tests (pull_request) Failing after 30s
This commit is contained in:
commit
f15fbf5431
34
.github/workflows/tests.yml
vendored
Normal file
34
.github/workflows/tests.yml
vendored
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
name: Run unit tests
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
jobs:
|
||||||
|
unit_tests:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
services:
|
||||||
|
postgres:
|
||||||
|
image: postgres
|
||||||
|
env:
|
||||||
|
POSTGRES_USER: postgres
|
||||||
|
POSTGRES_PASSWORD: postgres
|
||||||
|
options: >-
|
||||||
|
--health-cmd pg_isready
|
||||||
|
--health-interval 10s
|
||||||
|
--health-timeout 5s
|
||||||
|
--health-retries 5
|
||||||
|
ports:
|
||||||
|
- 5432
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
- uses: ruby/setup-ruby@v1
|
||||||
|
- run: bundle install
|
||||||
|
- run: |
|
||||||
|
bundle exec rake db:create db:schema:load
|
||||||
|
bundle exec rspec
|
||||||
|
env:
|
||||||
|
RAILS_ENV: test
|
||||||
|
DATABASE_URL: postgres://postgres:postgres@postgres:5432/postgres
|
@ -239,7 +239,7 @@ GEM
|
|||||||
stringio (3.1.1)
|
stringio (3.1.1)
|
||||||
thor (1.3.1)
|
thor (1.3.1)
|
||||||
timeout (0.4.1)
|
timeout (0.4.1)
|
||||||
turbo-rails (2.0.5)
|
turbo-rails (2.0.6)
|
||||||
actionpack (>= 6.0.0)
|
actionpack (>= 6.0.0)
|
||||||
activejob (>= 6.0.0)
|
activejob (>= 6.0.0)
|
||||||
railties (>= 6.0.0)
|
railties (>= 6.0.0)
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
require 'csv'
|
||||||
|
|
||||||
class GuestsController < ApplicationController
|
class GuestsController < ApplicationController
|
||||||
before_action :set_guest, only: %i[show edit update destroy]
|
before_action :set_guest, only: %i[show edit update destroy]
|
||||||
|
|
||||||
@ -58,6 +60,20 @@ class GuestsController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def import
|
||||||
|
csv = CSV.parse(params[:file].read, headers: true)
|
||||||
|
ActiveRecord::Base.transaction do
|
||||||
|
csv.each do |row|
|
||||||
|
guest = Guest.create!(first_name: row['name'])
|
||||||
|
|
||||||
|
guest.affinity_group_list.add(row['affinity_group'])
|
||||||
|
guest.save!
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
redirect_to guests_url
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# Use callbacks to share common setup or constraints between actions.
|
# Use callbacks to share common setup or constraints between actions.
|
||||||
|
@ -29,3 +29,9 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= link_to "New guest", new_guest_path %>
|
<%= link_to "New guest", new_guest_path %>
|
||||||
|
|
||||||
|
<%= form_with url: import_guests_path, method: :post do |form| %>
|
||||||
|
<%= form.label :file %>
|
||||||
|
<%= form.file_field :file %>
|
||||||
|
<%= form.submit "Import" %>
|
||||||
|
<% end %>
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
Rails.application.routes.draw do
|
Rails.application.routes.draw do
|
||||||
resources :guests
|
resources :guests do
|
||||||
|
post :import, on: :collection
|
||||||
|
end
|
||||||
resources :expenses
|
resources :expenses
|
||||||
resources :tables_arrangements, only: [:index, :show]
|
resources :tables_arrangements, only: [:index, :show]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user