Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ GEM
minitest (5.16.3)
msgpack (1.6.0)
nio4r (2.5.8)
nokogiri (1.13.8)
nokogiri (1.13.9)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
pg (1.4.4)
Expand Down Expand Up @@ -135,14 +135,14 @@ GEM
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
rspec-core (3.11.0)
rspec-support (~> 3.11.0)
rspec-expectations (3.11.1)
rspec-core (3.12.0)
rspec-support (~> 3.12.0)
rspec-expectations (3.12.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.11.0)
rspec-mocks (3.11.1)
rspec-support (~> 3.12.0)
rspec-mocks (3.12.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.11.0)
rspec-support (~> 3.12.0)
rspec-rails (5.1.2)
actionpack (>= 5.2)
activesupport (>= 5.2)
Expand All @@ -151,7 +151,7 @@ GEM
rspec-expectations (~> 3.10)
rspec-mocks (~> 3.10)
rspec-support (~> 3.10)
rspec-support (3.11.1)
rspec-support (3.12.0)
shoulda-matchers (5.2.0)
activesupport (>= 5.2.0)
spring (2.1.1)
Expand All @@ -172,7 +172,7 @@ GEM
websocket-driver (0.7.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
zeitwerk (2.6.1)
zeitwerk (2.6.5)

PLATFORMS
ruby
Expand Down
25 changes: 9 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
# README

This README would normally document whatever steps are necessary to get the
application up and running.
# api-postgresql

Things you may want to cover:
O projeto conta com uma api construida em Ruby on Rails para fins de desenvolvimento e aprendizado.

* Ruby version

* System dependencies
The project has an API built in Ruby on Rails for development and learning purposes.
## Tutor

* Configuration
- [Joathan](https://github.com/joathan)

* Database creation
## Referência

* Database initialization
- [RubyGems](https://rubygems.org/)
## 🛠 Habilidades
Ruby on Rails, HTML...

* How to run the test suite

* Services (job queues, cache servers, search engines, etc.)

* Deployment instructions

* ...
Comment on lines -1 to -24
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isso não faz parte da tarefa!

9 changes: 9 additions & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class UsersController < ApplicationController
before_action :set_user, only: [:update]

def create
@user = User.new(user_params)
Expand All @@ -10,6 +11,14 @@ def create
end
end

def update
if @user.update(user_params)
render json: @user, status: 200
else
render json: @user.errors, status: :unprocessable_entity
end
end

private
# Use callbacks to share common setup or constraints between actions.
def set_user
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Rails.application.routes.draw do
resources :users, only: [:create]
resources :users, only: [ :create, :update ]

# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
end
13 changes: 13 additions & 0 deletions spec/requests/users_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require 'rails_helper'

RSpec.describe "Users", type: :request do
describe "PUT /users/update" do
let!(:user) { User.create(name: 'John', age: 28) }
scenario 'valid user attributes' do
put "/users/#{user.id}", params: {
user: { name: 'John', age: 28 }
}
expect(response.status).to eq(200)
end
end
end