diff --git a/app/assets/javascripts/pages.coffee b/app/assets/javascripts/pages.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/pages.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/stylesheets/pages.scss b/app/assets/stylesheets/pages.scss new file mode 100644 index 0000000..0d6878a --- /dev/null +++ b/app/assets/stylesheets/pages.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the pages controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/concerns/statistics.rb b/app/controllers/concerns/statistics.rb new file mode 100644 index 0000000..1d571c0 --- /dev/null +++ b/app/controllers/concerns/statistics.rb @@ -0,0 +1,15 @@ + +class Statistics < Rails::Application + + def shameful_users + User.where('balance > :amount', amount: config.shameful_balance) + .order(:balance) + end + + private + + def zeus_balance + User.zeus.balance + end + +end diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb new file mode 100644 index 0000000..fd7c718 --- /dev/null +++ b/app/controllers/pages_controller.rb @@ -0,0 +1,9 @@ +class PagesController < ApplicationController + + require 'statistics' + + def landing + @statistics = Statistics.new + end + +end diff --git a/app/helpers/pages_helper.rb b/app/helpers/pages_helper.rb new file mode 100644 index 0000000..2c057fd --- /dev/null +++ b/app/helpers/pages_helper.rb @@ -0,0 +1,2 @@ +module PagesHelper +end diff --git a/app/views/pages/landing.html.haml b/app/views/pages/landing.html.haml index 0acc58d..4f4fcb0 100644 --- a/app/views/pages/landing.html.haml +++ b/app/views/pages/landing.html.haml @@ -6,4 +6,8 @@ Log een keer in! %p= link_to "Log in met Zeus WPI", user_omniauth_authorize_path(:zeuswpi) %h2 Cute Little Statistics - %p None here yet. +%p None here yet. +%h2 Wall of Shame +%ul + - @statistics.shameful_users.each do |user| + %li="Shame on #{user.name}!" diff --git a/config/application.rb b/config/application.rb index 7f0d45a..c611175 100644 --- a/config/application.rb +++ b/config/application.rb @@ -22,5 +22,8 @@ module Tab # Do not swallow errors in after_commit/after_rollback callbacks. config.active_record.raise_in_transactional_callbacks = true + + # Which is the lowest balance you should be ashamed of. + config.shameful_balance = 50 end end diff --git a/config/routes.rb b/config/routes.rb index 7d6f8fa..1a3c572 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,7 +3,7 @@ Rails.application.routes.draw do omniauth_callbacks: 'callbacks' } - root to: 'high_voltage/pages#show', id: "landing" + root to: 'pages#landing' resources :transactions, only: [:index, :create] resources :users, only: [:show, :index] diff --git a/spec/controllers/pages_controller_spec.rb b/spec/controllers/pages_controller_spec.rb new file mode 100644 index 0000000..8a418be --- /dev/null +++ b/spec/controllers/pages_controller_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe PagesController, type: :controller do + +end diff --git a/spec/helpers/pages_helper_spec.rb b/spec/helpers/pages_helper_spec.rb new file mode 100644 index 0000000..2960941 --- /dev/null +++ b/spec/helpers/pages_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the PagesHelper. For example: +# +# describe PagesHelper 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 PagesHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end