Skip to content

Commit 5b44861

Browse files
committed
connect db and init model,routes
0 parents  commit 5b44861

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1587
-0
lines changed

.gitignore

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
2+
#
3+
# If you find yourself ignoring temporary files generated by your text editor
4+
# or operating system, you probably want to add a global ignore instead:
5+
# git config --global core.excludesfile '~/.gitignore_global'
6+
7+
# Ignore bundler config.
8+
/.bundle
9+
10+
# Ignore all logfiles and tempfiles.
11+
/log/*
12+
/tmp/*
13+
!/log/.keep
14+
!/tmp/.keep
15+
tips.md
16+
.byebug_history
17+
18+
# Ignore master key for decrypting credentials and more.
19+
/config/master.key

.rspec

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--require spec_helper

.ruby-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ruby-2.6.5

Dockerfile

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM ruby:2.6.5
2+
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
3+
4+
RUN mkdir /app
5+
WORKDIR /app
6+
7+
COPY Gemfile /app/Gemfile
8+
COPY Gemfile.lock /app/Gemfile.lock
9+
RUN gem install bundler:2.0.2
10+
RUN bundle install
11+
12+
COPY . /app

Gemfile

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
source 'https://rubygems.org'
2+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3+
4+
ruby '2.6.5'
5+
6+
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
7+
gem 'rails', '~> 6.0.1'
8+
# Use postgresql as the database for Active Record
9+
gem 'pg', '>= 0.18', '< 2.0'
10+
# Use Puma as the app server
11+
gem 'puma', '~> 4.1'
12+
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
13+
# gem 'jbuilder', '~> 2.7'
14+
# Use Active Model has_secure_password
15+
# gem 'bcrypt', '~> 3.1.7'
16+
17+
# Reduces boot times through caching; required in config/boot.rb
18+
gem 'bootsnap', '>= 1.4.2', require: false
19+
gem 'active_model_serializers', '~> 0.10.10' #Json:Api
20+
gem 'aasm', '~> 5.0.6' #pattern state
21+
22+
# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
23+
# gem 'rack-cors'
24+
25+
group :development, :test do
26+
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
27+
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
28+
gem 'rspec-rails', '~> 3.9.0'
29+
gem 'factory_bot_rails', '~> 5.1.0'
30+
gem 'faker', '~> 2.7.0'
31+
end
32+
33+
group :development do
34+
gem 'listen', '>= 3.0.5', '< 3.2'
35+
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
36+
gem 'spring'
37+
gem 'spring-watcher-listen', '~> 2.0.0'
38+
end
39+
40+
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
41+
#gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

Gemfile.lock

+205
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
aasm (5.0.6)
5+
concurrent-ruby (~> 1.0)
6+
actioncable (6.0.1)
7+
actionpack (= 6.0.1)
8+
nio4r (~> 2.0)
9+
websocket-driver (>= 0.6.1)
10+
actionmailbox (6.0.1)
11+
actionpack (= 6.0.1)
12+
activejob (= 6.0.1)
13+
activerecord (= 6.0.1)
14+
activestorage (= 6.0.1)
15+
activesupport (= 6.0.1)
16+
mail (>= 2.7.1)
17+
actionmailer (6.0.1)
18+
actionpack (= 6.0.1)
19+
actionview (= 6.0.1)
20+
activejob (= 6.0.1)
21+
mail (~> 2.5, >= 2.5.4)
22+
rails-dom-testing (~> 2.0)
23+
actionpack (6.0.1)
24+
actionview (= 6.0.1)
25+
activesupport (= 6.0.1)
26+
rack (~> 2.0)
27+
rack-test (>= 0.6.3)
28+
rails-dom-testing (~> 2.0)
29+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
30+
actiontext (6.0.1)
31+
actionpack (= 6.0.1)
32+
activerecord (= 6.0.1)
33+
activestorage (= 6.0.1)
34+
activesupport (= 6.0.1)
35+
nokogiri (>= 1.8.5)
36+
actionview (6.0.1)
37+
activesupport (= 6.0.1)
38+
builder (~> 3.1)
39+
erubi (~> 1.4)
40+
rails-dom-testing (~> 2.0)
41+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
42+
active_model_serializers (0.10.10)
43+
actionpack (>= 4.1, < 6.1)
44+
activemodel (>= 4.1, < 6.1)
45+
case_transform (>= 0.2)
46+
jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
47+
activejob (6.0.1)
48+
activesupport (= 6.0.1)
49+
globalid (>= 0.3.6)
50+
activemodel (6.0.1)
51+
activesupport (= 6.0.1)
52+
activerecord (6.0.1)
53+
activemodel (= 6.0.1)
54+
activesupport (= 6.0.1)
55+
activestorage (6.0.1)
56+
actionpack (= 6.0.1)
57+
activejob (= 6.0.1)
58+
activerecord (= 6.0.1)
59+
marcel (~> 0.3.1)
60+
activesupport (6.0.1)
61+
concurrent-ruby (~> 1.0, >= 1.0.2)
62+
i18n (>= 0.7, < 2)
63+
minitest (~> 5.1)
64+
tzinfo (~> 1.1)
65+
zeitwerk (~> 2.2)
66+
bootsnap (1.4.5)
67+
msgpack (~> 1.0)
68+
builder (3.2.3)
69+
byebug (11.0.1)
70+
case_transform (0.2)
71+
activesupport
72+
concurrent-ruby (1.1.5)
73+
crass (1.0.5)
74+
diff-lcs (1.3)
75+
erubi (1.9.0)
76+
factory_bot (5.1.1)
77+
activesupport (>= 4.2.0)
78+
factory_bot_rails (5.1.1)
79+
factory_bot (~> 5.1.0)
80+
railties (>= 4.2.0)
81+
faker (2.7.0)
82+
i18n (>= 1.6, < 1.8)
83+
ffi (1.11.2)
84+
globalid (0.4.2)
85+
activesupport (>= 4.2.0)
86+
i18n (1.7.0)
87+
concurrent-ruby (~> 1.0)
88+
jsonapi-renderer (0.2.2)
89+
listen (3.1.5)
90+
rb-fsevent (~> 0.9, >= 0.9.4)
91+
rb-inotify (~> 0.9, >= 0.9.7)
92+
ruby_dep (~> 1.2)
93+
loofah (2.3.1)
94+
crass (~> 1.0.2)
95+
nokogiri (>= 1.5.9)
96+
mail (2.7.1)
97+
mini_mime (>= 0.1.1)
98+
marcel (0.3.3)
99+
mimemagic (~> 0.3.2)
100+
method_source (0.9.2)
101+
mimemagic (0.3.3)
102+
mini_mime (1.0.2)
103+
mini_portile2 (2.4.0)
104+
minitest (5.13.0)
105+
msgpack (1.3.1)
106+
nio4r (2.5.2)
107+
nokogiri (1.10.5)
108+
mini_portile2 (~> 2.4.0)
109+
pg (1.1.4)
110+
puma (4.3.0)
111+
nio4r (~> 2.0)
112+
rack (2.0.7)
113+
rack-test (1.1.0)
114+
rack (>= 1.0, < 3)
115+
rails (6.0.1)
116+
actioncable (= 6.0.1)
117+
actionmailbox (= 6.0.1)
118+
actionmailer (= 6.0.1)
119+
actionpack (= 6.0.1)
120+
actiontext (= 6.0.1)
121+
actionview (= 6.0.1)
122+
activejob (= 6.0.1)
123+
activemodel (= 6.0.1)
124+
activerecord (= 6.0.1)
125+
activestorage (= 6.0.1)
126+
activesupport (= 6.0.1)
127+
bundler (>= 1.3.0)
128+
railties (= 6.0.1)
129+
sprockets-rails (>= 2.0.0)
130+
rails-dom-testing (2.0.3)
131+
activesupport (>= 4.2.0)
132+
nokogiri (>= 1.6)
133+
rails-html-sanitizer (1.3.0)
134+
loofah (~> 2.3)
135+
railties (6.0.1)
136+
actionpack (= 6.0.1)
137+
activesupport (= 6.0.1)
138+
method_source
139+
rake (>= 0.8.7)
140+
thor (>= 0.20.3, < 2.0)
141+
rake (13.0.1)
142+
rb-fsevent (0.10.3)
143+
rb-inotify (0.10.0)
144+
ffi (~> 1.0)
145+
rspec-core (3.9.0)
146+
rspec-support (~> 3.9.0)
147+
rspec-expectations (3.9.0)
148+
diff-lcs (>= 1.2.0, < 2.0)
149+
rspec-support (~> 3.9.0)
150+
rspec-mocks (3.9.0)
151+
diff-lcs (>= 1.2.0, < 2.0)
152+
rspec-support (~> 3.9.0)
153+
rspec-rails (3.9.0)
154+
actionpack (>= 3.0)
155+
activesupport (>= 3.0)
156+
railties (>= 3.0)
157+
rspec-core (~> 3.9.0)
158+
rspec-expectations (~> 3.9.0)
159+
rspec-mocks (~> 3.9.0)
160+
rspec-support (~> 3.9.0)
161+
rspec-support (3.9.0)
162+
ruby_dep (1.5.0)
163+
spring (2.1.0)
164+
spring-watcher-listen (2.0.1)
165+
listen (>= 2.7, < 4.0)
166+
spring (>= 1.2, < 3.0)
167+
sprockets (4.0.0)
168+
concurrent-ruby (~> 1.0)
169+
rack (> 1, < 3)
170+
sprockets-rails (3.2.1)
171+
actionpack (>= 4.0)
172+
activesupport (>= 4.0)
173+
sprockets (>= 3.0.0)
174+
thor (0.20.3)
175+
thread_safe (0.3.6)
176+
tzinfo (1.2.5)
177+
thread_safe (~> 0.1)
178+
websocket-driver (0.7.1)
179+
websocket-extensions (>= 0.1.0)
180+
websocket-extensions (0.1.4)
181+
zeitwerk (2.2.1)
182+
183+
PLATFORMS
184+
ruby
185+
186+
DEPENDENCIES
187+
aasm (~> 5.0.6)
188+
active_model_serializers (~> 0.10.10)
189+
bootsnap (>= 1.4.2)
190+
byebug
191+
factory_bot_rails (~> 5.1.0)
192+
faker (~> 2.7.0)
193+
listen (>= 3.0.5, < 3.2)
194+
pg (>= 0.18, < 2.0)
195+
puma (~> 4.1)
196+
rails (~> 6.0.1)
197+
rspec-rails (~> 3.9.0)
198+
spring
199+
spring-watcher-listen (~> 2.0.0)
200+
201+
RUBY VERSION
202+
ruby 2.6.5p114
203+
204+
BUNDLED WITH
205+
2.0.2

README.md

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Trabajo Final Integrador - TTPS Ruby 2019
2+
3+
## Requisitos
4+
- [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
5+
- [Ruby](https://www.ruby-lang.org/es/)
6+
- [Bundle gem](https://github.com/bundler/bundler)
7+
- [Docker Compose](https://docs.docker.com/compose/install/)
8+
9+
## Instalando el proyecto
10+
11+
Para instalar el proyecto es necesario abrir la terminal y ejecutar los siguientes comandos:
12+
13+
```sh
14+
git clone [email protected]:EstebanDebole/TTPS-Ruby-Tpi.git
15+
cd TTPS-Ruby-Tpi
16+
docker-compose build
17+
```
18+
19+
## Levantando el proyecto
20+
21+
Para levantar el proyecto es necesario estar posicionado en la carpeta del proyecto y ejecutar los comandos:
22+
23+
```sh
24+
docker-compose up -d
25+
docker-compose exec web rails db:setup
26+
```
27+
28+
Una vez hecho esto, se podrá acceder al sitio desde http://localhost:3001, con el nombre de usuario `admin` y la contraseña `123456`.
29+
30+
## Corriendo los tests
31+
Para correr todos los tests juntos utilizando el comando:
32+
```sh
33+
docker-compose exec web rails test
34+
```
35+
Para correrlos uno por uno:
36+
```sh
37+
docker-compose exec web rails test test/models/course_test.rb
38+
docker-compose exec web rails test test/models/examination_test.rb
39+
docker-compose exec web rails test test/models/student_test.rb
40+
docker-compose exec web rails test test/models/score_test.rb
41+
```
42+
43+
## Terminando
44+
Para finalizar es necesario ejecutar:
45+
46+
```sh
47+
docker-compose down
48+
```
49+
50+
51+

Rakefile

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Add your own tasks in files placed in lib/tasks ending in .rake,
2+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3+
4+
require_relative 'config/application'
5+
6+
Rails.application.load_tasks
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class ApplicationController < ActionController::API
2+
end

app/controllers/concerns/.keep

Whitespace-only changes.

app/controllers/items_controller.rb

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
class ItemsController < ApplicationController
2+
before_action :set_item, only: [:show, :update, :destroy]
3+
4+
# GET /items
5+
def index
6+
@items = Item.all
7+
8+
render json: @items
9+
end
10+
11+
# GET /items/1
12+
def show
13+
render json: @item
14+
end
15+
16+
# POST /items
17+
def create
18+
@item = Item.new(item_params)
19+
20+
if @item.save
21+
render json: @item, status: :created, location: @item
22+
else
23+
render json: @item.errors, status: :unprocessable_entity
24+
end
25+
end
26+
27+
# PATCH/PUT /items/1
28+
def update
29+
if @item.update(item_params)
30+
render json: @item
31+
else
32+
render json: @item.errors, status: :unprocessable_entity
33+
end
34+
end
35+
36+
# DELETE /items/1
37+
def destroy
38+
@item.destroy
39+
end
40+
41+
private
42+
# Use callbacks to share common setup or constraints between actions.
43+
def set_item
44+
@item = Item.find(params[:id])
45+
end
46+
47+
# Only allow a trusted parameter "white list" through.
48+
def item_params
49+
params.require(:item).permit(:state)
50+
end
51+
end

0 commit comments

Comments
 (0)