generated from FGA0138-MDS-Ajax/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:FGA0138-MDS-Ajax/2024.1-POLLUX
- Loading branch information
Showing
23 changed files
with
349 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
class EventosController < ApplicationController | ||
before_action :set_evento, only: %i[ show edit update destroy ] | ||
|
||
# GET /eventos or /eventos.json | ||
def index | ||
@eventos = Evento.all | ||
end | ||
|
||
# GET /eventos/1 or /eventos/1.json | ||
def show | ||
end | ||
|
||
# GET /eventos/new | ||
def new | ||
@evento = Evento.new | ||
end | ||
|
||
# GET /eventos/1/edit | ||
def edit | ||
end | ||
|
||
# POST /eventos or /eventos.json | ||
def create | ||
@evento = Evento.new(evento_params) | ||
|
||
respond_to do |format| | ||
if @evento.save | ||
format.html { redirect_to evento_url(@evento), notice: "Evento was successfully created." } | ||
format.json { render :show, status: :created, location: @evento } | ||
else | ||
format.html { render :new, status: :unprocessable_entity } | ||
format.json { render json: @evento.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PATCH/PUT /eventos/1 or /eventos/1.json | ||
def update | ||
respond_to do |format| | ||
if @evento.update(evento_params) | ||
format.html { redirect_to evento_url(@evento), notice: "Evento was successfully updated." } | ||
format.json { render :show, status: :ok, location: @evento } | ||
else | ||
format.html { render :edit, status: :unprocessable_entity } | ||
format.json { render json: @evento.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /eventos/1 or /eventos/1.json | ||
def destroy | ||
@evento.destroy! | ||
|
||
respond_to do |format| | ||
format.html { redirect_to eventos_url, notice: "Evento was successfully destroyed." } | ||
format.json { head :no_content } | ||
end | ||
end | ||
|
||
private | ||
# Use callbacks to share common setup or constraints between actions. | ||
def set_evento | ||
@evento = Evento.find(params[:id]) | ||
end | ||
|
||
# Only allow a list of trusted parameters through. | ||
def evento_params | ||
params.require(:evento).permit(:nome, :data, :HoraInicio, :HoraTermino, :user_id) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module EventosHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class Evento < ApplicationRecord | ||
belongs_to :user | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<div id="<%= dom_id evento %>"> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
json.extract! evento, :id, :created_at, :updated_at | ||
json.url evento_url(evento, format: :json) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<%= form_with(model: evento) do |form| %> | ||
<% if evento.errors.any? %> | ||
<div style="color: red"> | ||
<h2><%= pluralize(evento.errors.count, "error") %> prohibited this evento from being saved:</h2> | ||
|
||
<ul> | ||
<% evento.errors.each do |error| %> | ||
<li><%= error.full_message %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
|
||
<div> | ||
<%= form.submit %> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<h1>Editing evento</h1> | ||
|
||
<%= render "form", evento: @evento %> | ||
|
||
<br> | ||
|
||
<div> | ||
<%= link_to "Show this evento", @evento %> | | ||
<%= link_to "Back to eventos", eventos_path %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<p style="color: green"><%= notice %></p> | ||
|
||
<h1>Eventos</h1> | ||
|
||
<div id="eventos"> | ||
<% @eventos.each do |evento| %> | ||
<%= render evento %> | ||
<p> | ||
<%= link_to "Show this evento", evento %> | ||
</p> | ||
<% end %> | ||
</div> | ||
|
||
<%= link_to "New evento", new_evento_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
json.array! @eventos, partial: "eventos/evento", as: :evento |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<h1>New evento</h1> | ||
|
||
<%= render "form", evento: @evento %> | ||
|
||
<br> | ||
|
||
<div> | ||
<%= link_to "Back to eventos", eventos_path %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<p style="color: green"><%= notice %></p> | ||
|
||
<%= render @evento %> | ||
|
||
<div> | ||
<%= link_to "Edit this evento", edit_evento_path(@evento) %> | | ||
<%= link_to "Back to eventos", eventos_path %> | ||
|
||
<%= button_to "Destroy this evento", @evento, method: :delete %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
json.partial! "eventos/evento", evento: @evento |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class CreateEventos < ActiveRecord::Migration[7.1] | ||
def change | ||
create_table :eventos do |t| | ||
t.string :nome | ||
t.string :data | ||
t.string :HoraInicio | ||
t.string :HoraTermino | ||
t.references :user, null: false, foreign_key: true | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
meta { | ||
name: CreateEvento | ||
type: http | ||
seq: 2 | ||
} | ||
|
||
post { | ||
url: http://localhost/3000/eventos | ||
body: none | ||
auth: none | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
require "test_helper" | ||
|
||
class EventosControllerTest < ActionDispatch::IntegrationTest | ||
setup do | ||
@evento = eventos(:one) | ||
end | ||
|
||
test "should get index" do | ||
get eventos_url | ||
assert_response :success | ||
end | ||
|
||
test "should get new" do | ||
get new_evento_url | ||
assert_response :success | ||
end | ||
|
||
test "should create evento" do | ||
assert_difference("Evento.count") do | ||
post eventos_url, params: { evento: { } } | ||
end | ||
|
||
assert_redirected_to evento_url(Evento.last) | ||
end | ||
|
||
test "should show evento" do | ||
get evento_url(@evento) | ||
assert_response :success | ||
end | ||
|
||
test "should get edit" do | ||
get edit_evento_url(@evento) | ||
assert_response :success | ||
end | ||
|
||
test "should update evento" do | ||
patch evento_url(@evento), params: { evento: { } } | ||
assert_redirected_to evento_url(@evento) | ||
end | ||
|
||
test "should destroy evento" do | ||
assert_difference("Evento.count", -1) do | ||
delete evento_url(@evento) | ||
end | ||
|
||
assert_redirected_to eventos_url | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html | ||
|
||
one: | ||
nome: MyString | ||
string: MyString | ||
data: MyString | ||
string: MyString | ||
HoraInicio: MyString | ||
HoraTermino: MyString | ||
user: one | ||
|
||
two: | ||
nome: MyString | ||
string: MyString | ||
data: MyString | ||
string: MyString | ||
HoraInicio: MyString | ||
HoraTermino: MyString | ||
user: two |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require "test_helper" | ||
|
||
class EventoTest < ActiveSupport::TestCase | ||
# test "the truth" do | ||
# assert true | ||
# end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
require "application_system_test_case" | ||
|
||
class EventosTest < ApplicationSystemTestCase | ||
setup do | ||
@evento = eventos(:one) | ||
end | ||
|
||
test "visiting the index" do | ||
visit eventos_url | ||
assert_selector "h1", text: "Eventos" | ||
end | ||
|
||
test "should create evento" do | ||
visit eventos_url | ||
click_on "New evento" | ||
|
||
click_on "Create Evento" | ||
|
||
assert_text "Evento was successfully created" | ||
click_on "Back" | ||
end | ||
|
||
test "should update Evento" do | ||
visit evento_url(@evento) | ||
click_on "Edit this evento", match: :first | ||
|
||
click_on "Update Evento" | ||
|
||
assert_text "Evento was successfully updated" | ||
click_on "Back" | ||
end | ||
|
||
test "should destroy Evento" do | ||
visit evento_url(@evento) | ||
click_on "Destroy this evento", match: :first | ||
|
||
assert_text "Evento was successfully destroyed" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.