From 5d7217f355f615d9e7642ccc9657d603a10039b3 Mon Sep 17 00:00:00 2001 From: Etienne Ischer Date: Fri, 23 Apr 2021 16:27:28 +0200 Subject: [PATCH] add characters index page --- .env.example | 1 - app/assets/stylesheets/characters.scss | 3 ++ app/assets/stylesheets/protected.scss | 3 ++ app/controllers/protected_controller.rb | 3 ++ app/controllers/wow_characters_controller.rb | 5 +++ app/helpers/characters_helper.rb | 2 ++ app/helpers/protected_helper.rb | 2 ++ app/views/wow_characters/index.html.erb | 32 ++++++++++++++++++++ config/database.yml | 10 +++--- config/routes.rb | 1 + spec/helpers/characters_helper_spec.rb | 15 +++++++++ spec/helpers/protected_helper_spec.rb | 15 +++++++++ spec/requests/characters_spec.rb | 7 +++++ spec/requests/protected_spec.rb | 7 +++++ 14 files changed, 101 insertions(+), 5 deletions(-) create mode 100644 app/assets/stylesheets/characters.scss create mode 100644 app/assets/stylesheets/protected.scss create mode 100644 app/controllers/protected_controller.rb create mode 100644 app/controllers/wow_characters_controller.rb create mode 100644 app/helpers/characters_helper.rb create mode 100644 app/helpers/protected_helper.rb create mode 100644 app/views/wow_characters/index.html.erb create mode 100644 spec/helpers/characters_helper_spec.rb create mode 100644 spec/helpers/protected_helper_spec.rb create mode 100644 spec/requests/characters_spec.rb create mode 100644 spec/requests/protected_spec.rb diff --git a/.env.example b/.env.example index a889bcf..da9b046 100644 --- a/.env.example +++ b/.env.example @@ -1,7 +1,6 @@ BLIZZARD_API_CLIENT_ID= BLIZZARD_API_CLIENT_SECRET= -DEVISE_JWT_SECRET_KEY= DEVISE_SECRET_KEY= DATABASE_USERNAME= diff --git a/app/assets/stylesheets/characters.scss b/app/assets/stylesheets/characters.scss new file mode 100644 index 0000000..459c569 --- /dev/null +++ b/app/assets/stylesheets/characters.scss @@ -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/ diff --git a/app/assets/stylesheets/protected.scss b/app/assets/stylesheets/protected.scss new file mode 100644 index 0000000..cdae182 --- /dev/null +++ b/app/assets/stylesheets/protected.scss @@ -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/ diff --git a/app/controllers/protected_controller.rb b/app/controllers/protected_controller.rb new file mode 100644 index 0000000..cf05fab --- /dev/null +++ b/app/controllers/protected_controller.rb @@ -0,0 +1,3 @@ +class ProtectedController < ApplicationController + before_action :authenticate_user! +end diff --git a/app/controllers/wow_characters_controller.rb b/app/controllers/wow_characters_controller.rb new file mode 100644 index 0000000..6817ab0 --- /dev/null +++ b/app/controllers/wow_characters_controller.rb @@ -0,0 +1,5 @@ +class WowCharactersController < ProtectedController + def index + @characters = current_user.wow_characters.all + end +end diff --git a/app/helpers/characters_helper.rb b/app/helpers/characters_helper.rb new file mode 100644 index 0000000..8acbd18 --- /dev/null +++ b/app/helpers/characters_helper.rb @@ -0,0 +1,2 @@ +module CharactersHelper +end diff --git a/app/helpers/protected_helper.rb b/app/helpers/protected_helper.rb new file mode 100644 index 0000000..12b7e1c --- /dev/null +++ b/app/helpers/protected_helper.rb @@ -0,0 +1,2 @@ +module ProtectedHelper +end diff --git a/app/views/wow_characters/index.html.erb b/app/views/wow_characters/index.html.erb new file mode 100644 index 0000000..de35ed1 --- /dev/null +++ b/app/views/wow_characters/index.html.erb @@ -0,0 +1,32 @@ +

Characters list

+ + + + + + + + + + + + + + + + <% @characters.each do |character| %> + + + + + + + + + + + <% end %> + +
NameGenderRealmRaceClassFactionLevel
<% if character.wow_character_medium %> + alt="avatar"> + <% end %><%= character.name %><%= character.translated_gender %><%= character.wow_realm.name %><%= %><%= %><%= character.translated_faction %><%= character.level %>
diff --git a/config/database.yml b/config/database.yml index 386ed7c..d336619 100644 --- a/config/database.yml +++ b/config/database.yml @@ -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'] %> diff --git a/config/routes.rb b/config/routes.rb index 83e5616..ed6802b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 diff --git a/spec/helpers/characters_helper_spec.rb b/spec/helpers/characters_helper_spec.rb new file mode 100644 index 0000000..f05bc64 --- /dev/null +++ b/spec/helpers/characters_helper_spec.rb @@ -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 diff --git a/spec/helpers/protected_helper_spec.rb b/spec/helpers/protected_helper_spec.rb new file mode 100644 index 0000000..d10d063 --- /dev/null +++ b/spec/helpers/protected_helper_spec.rb @@ -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 diff --git a/spec/requests/characters_spec.rb b/spec/requests/characters_spec.rb new file mode 100644 index 0000000..290be7f --- /dev/null +++ b/spec/requests/characters_spec.rb @@ -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 diff --git a/spec/requests/protected_spec.rb b/spec/requests/protected_spec.rb new file mode 100644 index 0000000..11272b1 --- /dev/null +++ b/spec/requests/protected_spec.rb @@ -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