add characters index page
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
BLIZZARD_API_CLIENT_ID=
|
BLIZZARD_API_CLIENT_ID=
|
||||||
BLIZZARD_API_CLIENT_SECRET=
|
BLIZZARD_API_CLIENT_SECRET=
|
||||||
|
|
||||||
DEVISE_JWT_SECRET_KEY=
|
|
||||||
DEVISE_SECRET_KEY=
|
DEVISE_SECRET_KEY=
|
||||||
|
|
||||||
DATABASE_USERNAME=
|
DATABASE_USERNAME=
|
||||||
|
|||||||
3
app/assets/stylesheets/characters.scss
Normal file
3
app/assets/stylesheets/characters.scss
Normal 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/
|
||||||
3
app/assets/stylesheets/protected.scss
Normal file
3
app/assets/stylesheets/protected.scss
Normal 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/
|
||||||
3
app/controllers/protected_controller.rb
Normal file
3
app/controllers/protected_controller.rb
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
class ProtectedController < ApplicationController
|
||||||
|
before_action :authenticate_user!
|
||||||
|
end
|
||||||
5
app/controllers/wow_characters_controller.rb
Normal file
5
app/controllers/wow_characters_controller.rb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
class WowCharactersController < ProtectedController
|
||||||
|
def index
|
||||||
|
@characters = current_user.wow_characters.all
|
||||||
|
end
|
||||||
|
end
|
||||||
2
app/helpers/characters_helper.rb
Normal file
2
app/helpers/characters_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
module CharactersHelper
|
||||||
|
end
|
||||||
2
app/helpers/protected_helper.rb
Normal file
2
app/helpers/protected_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
module ProtectedHelper
|
||||||
|
end
|
||||||
32
app/views/wow_characters/index.html.erb
Normal file
32
app/views/wow_characters/index.html.erb
Normal 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>
|
||||||
@@ -20,10 +20,10 @@ default: &default
|
|||||||
# For details on connection pooling, see Rails configuration guide
|
# For details on connection pooling, see Rails configuration guide
|
||||||
# https://guides.rubyonrails.org/configuring.html#database-pooling
|
# https://guides.rubyonrails.org/configuring.html#database-pooling
|
||||||
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
|
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
|
||||||
username: <%= ENV['DATABASE_URL'] %>
|
username: <%= ENV['DATABASE_USERNAME'] %>
|
||||||
password: <%= ENV['DATABASE_URL'] %>
|
password: <%= ENV['DATABASE_PASSWORD'] %>
|
||||||
host: <%= ENV['DATABASE_URL'] %>
|
host: <%= ENV['DATABASE_HOST'] %>
|
||||||
port: <%= ENV['DATABASE_URL'] %>
|
port: <%= ENV['DATABASE_PORT'] %>
|
||||||
|
|
||||||
development:
|
development:
|
||||||
<<: *default
|
<<: *default
|
||||||
@@ -84,4 +84,6 @@ test:
|
|||||||
# for a full overview on how database connection configuration can be specified.
|
# for a full overview on how database connection configuration can be specified.
|
||||||
#
|
#
|
||||||
production:
|
production:
|
||||||
|
adapter: postgresql
|
||||||
|
encoding: unicode
|
||||||
url: <%= ENV['DATABASE_URL'] %>
|
url: <%= ENV['DATABASE_URL'] %>
|
||||||
|
|||||||
@@ -9,4 +9,5 @@ Rails.application.routes.draw do
|
|||||||
end
|
end
|
||||||
root to: "home#index"
|
root to: "home#index"
|
||||||
mount Sidekiq::Web => '/sidekiq'
|
mount Sidekiq::Web => '/sidekiq'
|
||||||
|
resources :wow_characters, path: '/wow-characters', only: [:index, :show]
|
||||||
end
|
end
|
||||||
|
|||||||
15
spec/helpers/characters_helper_spec.rb
Normal file
15
spec/helpers/characters_helper_spec.rb
Normal 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
|
||||||
15
spec/helpers/protected_helper_spec.rb
Normal file
15
spec/helpers/protected_helper_spec.rb
Normal 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
|
||||||
7
spec/requests/characters_spec.rb
Normal file
7
spec/requests/characters_spec.rb
Normal 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
|
||||||
7
spec/requests/protected_spec.rb
Normal file
7
spec/requests/protected_spec.rb
Normal 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
|
||||||
Reference in New Issue
Block a user