add characters index page

This commit is contained in:
Etienne Ischer
2021-04-23 16:27:28 +02:00
parent 9d08bc8a23
commit 5d7217f355
14 changed files with 101 additions and 5 deletions

View File

@@ -1,7 +1,6 @@
BLIZZARD_API_CLIENT_ID=
BLIZZARD_API_CLIENT_SECRET=
DEVISE_JWT_SECRET_KEY=
DEVISE_SECRET_KEY=
DATABASE_USERNAME=

View File

@@ -0,0 +1,3 @@
// Place all the styles related to the characters controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: https://sass-lang.com/

View File

@@ -0,0 +1,3 @@
// Place all the styles related to the protected controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: https://sass-lang.com/

View File

@@ -0,0 +1,3 @@
class ProtectedController < ApplicationController
before_action :authenticate_user!
end

View File

@@ -0,0 +1,5 @@
class WowCharactersController < ProtectedController
def index
@characters = current_user.wow_characters.all
end
end

View File

@@ -0,0 +1,2 @@
module CharactersHelper
end

View File

@@ -0,0 +1,2 @@
module ProtectedHelper
end

View File

@@ -0,0 +1,32 @@
<h2>Characters list</h2>
<table class="table table-hover table-dark table-image">
<thead>
<tr>
<th scope="col"></th>
<th scope="col">Name</th>
<th scope="col">Gender</th>
<th scope="col">Realm</th>
<th scope="col">Race</th>
<th scope="col">Class</th>
<th scope="col">Faction</th>
<th scope="col">Level</th>
</tr>
</thead>
<tbody>
<% @characters.each do |character| %>
<tr>
<td><% if character.wow_character_medium %>
<img class="rounded-circle border border-white" src=<%= character.wow_character_medium.avatar %> alt="avatar">
<% end %></td>
<td><%= character.name %></td>
<td><%= character.translated_gender %></td>
<td><%= character.wow_realm.name %></td>
<td><%= %></td>
<td><%= %></td>
<td><%= character.translated_faction %></td>
<td><%= character.level %></td>
</tr>
<% end %>
</tbody>
</table>

View File

@@ -20,10 +20,10 @@ default: &default
# For details on connection pooling, see Rails configuration guide
# https://guides.rubyonrails.org/configuring.html#database-pooling
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: <%= ENV['DATABASE_URL'] %>
password: <%= ENV['DATABASE_URL'] %>
host: <%= ENV['DATABASE_URL'] %>
port: <%= ENV['DATABASE_URL'] %>
username: <%= ENV['DATABASE_USERNAME'] %>
password: <%= ENV['DATABASE_PASSWORD'] %>
host: <%= ENV['DATABASE_HOST'] %>
port: <%= ENV['DATABASE_PORT'] %>
development:
<<: *default
@@ -84,4 +84,6 @@ test:
# for a full overview on how database connection configuration can be specified.
#
production:
adapter: postgresql
encoding: unicode
url: <%= ENV['DATABASE_URL'] %>

View File

@@ -9,4 +9,5 @@ Rails.application.routes.draw do
end
root to: "home#index"
mount Sidekiq::Web => '/sidekiq'
resources :wow_characters, path: '/wow-characters', only: [:index, :show]
end

View File

@@ -0,0 +1,15 @@
require 'rails_helper'
# Specs in this file have access to a helper object that includes
# the CharactersHelper. For example:
#
# describe CharactersHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end
# end
RSpec.describe CharactersHelper, type: :helper do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@@ -0,0 +1,15 @@
require 'rails_helper'
# Specs in this file have access to a helper object that includes
# the ProtectedHelper. For example:
#
# describe ProtectedHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end
# end
RSpec.describe ProtectedHelper, type: :helper do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@@ -0,0 +1,7 @@
require 'rails_helper'
RSpec.describe "Characters", type: :request do
describe "GET /index" do
pending "add some examples (or delete) #{__FILE__}"
end
end

View File

@@ -0,0 +1,7 @@
require 'rails_helper'
RSpec.describe "Protecteds", type: :request do
describe "GET /index" do
pending "add some examples (or delete) #{__FILE__}"
end
end