From 1a9b3496e1b02e82d3efb5e26f3cdb458ab193bd Mon Sep 17 00:00:00 2001 From: David Gwilliam Date: Wed, 2 Oct 2024 03:14:18 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=9F=A2=20create.rb=20for=20new=20files=20?= =?UTF-8?q?=F0=9F=9F=A2=20destroy.rb=20for=20new=20files=20=F0=9F=9F=A2=20?= =?UTF-8?q?edit.rb=20for=20new=20files=20=F0=9F=9F=A2=20index.rb=20for=20n?= =?UTF-8?q?ew=20files=20=F0=9F=9F=A2=20new.rb=20for=20new=20files=20?= =?UTF-8?q?=F0=9F=9F=A2=20update.rb=20for=20new=20files=20=F0=9F=9F=A2=20d?= =?UTF-8?q?estroy.html.erb=20for=20new=20files=20=F0=9F=9F=A2=20edit.html.?= =?UTF-8?q?erb=20for=20new=20files=20=F0=9F=9F=A2=20index.html.erb=20for?= =?UTF-8?q?=20new=20files=20=F0=9F=9F=A2=20new.html.erb=20for=20new=20file?= =?UTF-8?q?s=20=F0=9F=9F=A2=20destroy.rb=20for=20new=20files=20?= =?UTF-8?q?=F0=9F=9F=A2=20edit.rb=20for=20new=20files=20=F0=9F=9F=A2=20ind?= =?UTF-8?q?ex.rb=20for=20new=20files=20=F0=9F=9F=A2=20new.rb=20for=20new?= =?UTF-8?q?=20files?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- app/actions/admin/players/create.rb | 14 ++++++++++ app/actions/admin/players/destroy.rb | 14 ++++++++++ app/actions/admin/players/edit.rb | 14 ++++++++++ app/actions/admin/players/index.rb | 18 ++++++++++++ app/actions/admin/players/new.rb | 14 ++++++++++ app/actions/admin/players/update.rb | 14 ++++++++++ app/templates/admin/players/destroy.html.erb | 1 + app/templates/admin/players/edit.html.erb | 1 + app/templates/admin/players/index.html.erb | 29 ++++++++++++++++++++ app/templates/admin/players/new.html.erb | 1 + app/views/admin/players/destroy.rb | 12 ++++++++ app/views/admin/players/edit.rb | 12 ++++++++ app/views/admin/players/index.rb | 13 +++++++++ app/views/admin/players/new.rb | 12 ++++++++ config/routes.rb | 7 +++++ spec/actions/admin/players/create_spec.rb | 10 +++++++ spec/actions/admin/players/destroy_spec.rb | 10 +++++++ spec/actions/admin/players/edit_spec.rb | 10 +++++++ spec/actions/admin/players/index_spec.rb | 10 +++++++ spec/actions/admin/players/new_spec.rb | 10 +++++++ spec/actions/admin/players/update_spec.rb | 10 +++++++ 21 files changed, 236 insertions(+) create mode 100644 app/actions/admin/players/create.rb create mode 100644 app/actions/admin/players/destroy.rb create mode 100644 app/actions/admin/players/edit.rb create mode 100644 app/actions/admin/players/index.rb create mode 100644 app/actions/admin/players/new.rb create mode 100644 app/actions/admin/players/update.rb create mode 100644 app/templates/admin/players/destroy.html.erb create mode 100644 app/templates/admin/players/edit.html.erb create mode 100644 app/templates/admin/players/index.html.erb create mode 100644 app/templates/admin/players/new.html.erb create mode 100644 app/views/admin/players/destroy.rb create mode 100644 app/views/admin/players/edit.rb create mode 100644 app/views/admin/players/index.rb create mode 100644 app/views/admin/players/new.rb create mode 100644 spec/actions/admin/players/create_spec.rb create mode 100644 spec/actions/admin/players/destroy_spec.rb create mode 100644 spec/actions/admin/players/edit_spec.rb create mode 100644 spec/actions/admin/players/index_spec.rb create mode 100644 spec/actions/admin/players/new_spec.rb create mode 100644 spec/actions/admin/players/update_spec.rb diff --git a/app/actions/admin/players/create.rb b/app/actions/admin/players/create.rb new file mode 100644 index 0000000..ff4cddd --- /dev/null +++ b/app/actions/admin/players/create.rb @@ -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 diff --git a/app/actions/admin/players/destroy.rb b/app/actions/admin/players/destroy.rb new file mode 100644 index 0000000..3712891 --- /dev/null +++ b/app/actions/admin/players/destroy.rb @@ -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 diff --git a/app/actions/admin/players/edit.rb b/app/actions/admin/players/edit.rb new file mode 100644 index 0000000..72fc879 --- /dev/null +++ b/app/actions/admin/players/edit.rb @@ -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 diff --git a/app/actions/admin/players/index.rb b/app/actions/admin/players/index.rb new file mode 100644 index 0000000..23f303a --- /dev/null +++ b/app/actions/admin/players/index.rb @@ -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 diff --git a/app/actions/admin/players/new.rb b/app/actions/admin/players/new.rb new file mode 100644 index 0000000..1267413 --- /dev/null +++ b/app/actions/admin/players/new.rb @@ -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 diff --git a/app/actions/admin/players/update.rb b/app/actions/admin/players/update.rb new file mode 100644 index 0000000..f1a4338 --- /dev/null +++ b/app/actions/admin/players/update.rb @@ -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 diff --git a/app/templates/admin/players/destroy.html.erb b/app/templates/admin/players/destroy.html.erb new file mode 100644 index 0000000..d1edc1b --- /dev/null +++ b/app/templates/admin/players/destroy.html.erb @@ -0,0 +1 @@ +

EuchreCamp::Views::Admin::Players::Destroy

diff --git a/app/templates/admin/players/edit.html.erb b/app/templates/admin/players/edit.html.erb new file mode 100644 index 0000000..a163304 --- /dev/null +++ b/app/templates/admin/players/edit.html.erb @@ -0,0 +1 @@ +

EuchreCamp::Views::Admin::Players::Edit

diff --git a/app/templates/admin/players/index.html.erb b/app/templates/admin/players/index.html.erb new file mode 100644 index 0000000..798875a --- /dev/null +++ b/app/templates/admin/players/index.html.erb @@ -0,0 +1,29 @@ +

EuchreCamp::Views::Admin::Players::Index

+

Player Administration

+Create New Player + + + + + + + + + + + <% players.each do |player| %> + + + + + + + <% end %> + +
IDNameRatingActions
<%= player.id %><%= player.name %><%= player.rating %> + Edit +
+ + +
+
diff --git a/app/templates/admin/players/new.html.erb b/app/templates/admin/players/new.html.erb new file mode 100644 index 0000000..62a3041 --- /dev/null +++ b/app/templates/admin/players/new.html.erb @@ -0,0 +1 @@ +

EuchreCamp::Views::Admin::Players::New

diff --git a/app/views/admin/players/destroy.rb b/app/views/admin/players/destroy.rb new file mode 100644 index 0000000..914acb8 --- /dev/null +++ b/app/views/admin/players/destroy.rb @@ -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 diff --git a/app/views/admin/players/edit.rb b/app/views/admin/players/edit.rb new file mode 100644 index 0000000..b69e9fa --- /dev/null +++ b/app/views/admin/players/edit.rb @@ -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 diff --git a/app/views/admin/players/index.rb b/app/views/admin/players/index.rb new file mode 100644 index 0000000..8811012 --- /dev/null +++ b/app/views/admin/players/index.rb @@ -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 diff --git a/app/views/admin/players/new.rb b/app/views/admin/players/new.rb new file mode 100644 index 0000000..d67f525 --- /dev/null +++ b/app/views/admin/players/new.rb @@ -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 diff --git a/config/routes.rb b/config/routes.rb index 4071a83..8805065 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,5 +4,12 @@ module EuchreCamp class Routes < Hanami::Routes # Add your routes here. See https://guides.hanamirb.org/routing/overview/ for details. 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 diff --git a/spec/actions/admin/players/create_spec.rb b/spec/actions/admin/players/create_spec.rb new file mode 100644 index 0000000..be6bfea --- /dev/null +++ b/spec/actions/admin/players/create_spec.rb @@ -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 diff --git a/spec/actions/admin/players/destroy_spec.rb b/spec/actions/admin/players/destroy_spec.rb new file mode 100644 index 0000000..01bfd27 --- /dev/null +++ b/spec/actions/admin/players/destroy_spec.rb @@ -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 diff --git a/spec/actions/admin/players/edit_spec.rb b/spec/actions/admin/players/edit_spec.rb new file mode 100644 index 0000000..450d7da --- /dev/null +++ b/spec/actions/admin/players/edit_spec.rb @@ -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 diff --git a/spec/actions/admin/players/index_spec.rb b/spec/actions/admin/players/index_spec.rb new file mode 100644 index 0000000..8876cbc --- /dev/null +++ b/spec/actions/admin/players/index_spec.rb @@ -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 diff --git a/spec/actions/admin/players/new_spec.rb b/spec/actions/admin/players/new_spec.rb new file mode 100644 index 0000000..1e49d92 --- /dev/null +++ b/spec/actions/admin/players/new_spec.rb @@ -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 diff --git a/spec/actions/admin/players/update_spec.rb b/spec/actions/admin/players/update_spec.rb new file mode 100644 index 0000000..c1742e4 --- /dev/null +++ b/spec/actions/admin/players/update_spec.rb @@ -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