🟢 create.rb for new files
🟢 destroy.rb for new files 🟢 edit.rb for new files 🟢 index.rb for new files 🟢 new.rb for new files 🟢 update.rb for new files 🟢 destroy.html.erb for new files 🟢 edit.html.erb for new files 🟢 index.html.erb for new files 🟢 new.html.erb for new files 🟢 destroy.rb for new files 🟢 edit.rb for new files 🟢 index.rb for new files 🟢 new.rb for new files The provided Git diff contains the addition of several new files representing different actions for the admin/players section of the application. These new files include create.rb, destroy.rb, edit.rb, index.rb, new.rb, update.rb, as well as corresponding HTML erb templates and view files. Additionally, the routes.rb file has been modified to include routes for the new admin player actions. Finally, there are new spec files for testing each of the new actions.
This commit is contained in:
@@ -0,0 +1,14 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module EuchreCamp
|
||||||
|
module Actions
|
||||||
|
module Admin
|
||||||
|
module Players
|
||||||
|
class Create < EuchreCamp::Action
|
||||||
|
def handle(request, response)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module EuchreCamp
|
||||||
|
module Actions
|
||||||
|
module Admin
|
||||||
|
module Players
|
||||||
|
class Destroy < EuchreCamp::Action
|
||||||
|
def handle(request, response)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module EuchreCamp
|
||||||
|
module Actions
|
||||||
|
module Admin
|
||||||
|
module Players
|
||||||
|
class Edit < EuchreCamp::Action
|
||||||
|
def handle(request, response)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module EuchreCamp
|
||||||
|
module Actions
|
||||||
|
module Admin
|
||||||
|
module Players
|
||||||
|
class Index < EuchreCamp::Action
|
||||||
|
include Deps[repo: 'repositories.players']
|
||||||
|
|
||||||
|
def handle(_request, response)
|
||||||
|
players = repo.all
|
||||||
|
response.render(view, players: players)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module EuchreCamp
|
||||||
|
module Actions
|
||||||
|
module Admin
|
||||||
|
module Players
|
||||||
|
class New < EuchreCamp::Action
|
||||||
|
def handle(request, response)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module EuchreCamp
|
||||||
|
module Actions
|
||||||
|
module Admin
|
||||||
|
module Players
|
||||||
|
class Update < EuchreCamp::Action
|
||||||
|
def handle(request, response)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<h1>EuchreCamp::Views::Admin::Players::Destroy</h1>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<h1>EuchreCamp::Views::Admin::Players::Edit</h1>
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<h1>EuchreCamp::Views::Admin::Players::Index</h1>
|
||||||
|
<h1>Player Administration</h1>
|
||||||
|
<a href="/admin/players/new">Create New Player</a>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Rating</th>
|
||||||
|
<th>Actions</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<% players.each do |player| %>
|
||||||
|
<tr>
|
||||||
|
<td><%= player.id %></td>
|
||||||
|
<td><%= player.name %></td>
|
||||||
|
<td><%= player.rating %></td>
|
||||||
|
<td>
|
||||||
|
<a href="/admin/players/<%= player.id %>/edit">Edit</a>
|
||||||
|
<form action="/admin/players/<%= player.id %>" method="post" style="display:inline;">
|
||||||
|
<input type="hidden" name="_method" value="delete">
|
||||||
|
<button type="submit">Delete</button>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<h1>EuchreCamp::Views::Admin::Players::New</h1>
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module EuchreCamp
|
||||||
|
module Views
|
||||||
|
module Admin
|
||||||
|
module Players
|
||||||
|
class Destroy < EuchreCamp::View
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module EuchreCamp
|
||||||
|
module Views
|
||||||
|
module Admin
|
||||||
|
module Players
|
||||||
|
class Edit < EuchreCamp::View
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module EuchreCamp
|
||||||
|
module Views
|
||||||
|
module Admin
|
||||||
|
module Players
|
||||||
|
class Index < EuchreCamp::View
|
||||||
|
expose :players
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module EuchreCamp
|
||||||
|
module Views
|
||||||
|
module Admin
|
||||||
|
module Players
|
||||||
|
class New < EuchreCamp::View
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -4,5 +4,12 @@ module EuchreCamp
|
|||||||
class Routes < Hanami::Routes
|
class Routes < Hanami::Routes
|
||||||
# Add your routes here. See https://guides.hanamirb.org/routing/overview/ for details.
|
# Add your routes here. See https://guides.hanamirb.org/routing/overview/ for details.
|
||||||
get "/players/:id", to: "players.show"
|
get "/players/:id", to: "players.show"
|
||||||
|
|
||||||
|
get "/admin/players/new", to: "admin.players.new"
|
||||||
|
post "/admin/players", to: "admin.players.create"
|
||||||
|
get "/admin/players", to: "admin.players.index"
|
||||||
|
get "/admin/players/:id/edit", to: "admin.players.edit"
|
||||||
|
patch "/admin/players/:id", to: "admin.players.update"
|
||||||
|
delete "/admin/players/:id", to: "admin.players.destroy"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
RSpec.describe EuchreCamp::Actions::Admin::Players::Create do
|
||||||
|
let(:params) { Hash[] }
|
||||||
|
|
||||||
|
it "works" do
|
||||||
|
response = subject.call(params)
|
||||||
|
expect(response).to be_successful
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
RSpec.describe EuchreCamp::Actions::Admin::Players::Destroy do
|
||||||
|
let(:params) { Hash[] }
|
||||||
|
|
||||||
|
it "works" do
|
||||||
|
response = subject.call(params)
|
||||||
|
expect(response).to be_successful
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
RSpec.describe EuchreCamp::Actions::Admin::Players::Edit do
|
||||||
|
let(:params) { Hash[] }
|
||||||
|
|
||||||
|
it "works" do
|
||||||
|
response = subject.call(params)
|
||||||
|
expect(response).to be_successful
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
RSpec.describe EuchreCamp::Actions::Admin::Players::Index do
|
||||||
|
let(:params) { Hash[] }
|
||||||
|
|
||||||
|
it "works" do
|
||||||
|
response = subject.call(params)
|
||||||
|
expect(response).to be_successful
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
RSpec.describe EuchreCamp::Actions::Admin::Players::New do
|
||||||
|
let(:params) { Hash[] }
|
||||||
|
|
||||||
|
it "works" do
|
||||||
|
response = subject.call(params)
|
||||||
|
expect(response).to be_successful
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
RSpec.describe EuchreCamp::Actions::Admin::Players::Update do
|
||||||
|
let(:params) { Hash[] }
|
||||||
|
|
||||||
|
it "works" do
|
||||||
|
response = subject.call(params)
|
||||||
|
expect(response).to be_successful
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user