add simplistic wall of shame
This commit is contained in:
parent
b81bccabac
commit
3530fd1e5d
10 changed files with 61 additions and 2 deletions
3
app/assets/javascripts/pages.coffee
Normal file
3
app/assets/javascripts/pages.coffee
Normal file
|
@ -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/
|
3
app/assets/stylesheets/pages.scss
Normal file
3
app/assets/stylesheets/pages.scss
Normal file
|
@ -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/
|
15
app/controllers/concerns/statistics.rb
Normal file
15
app/controllers/concerns/statistics.rb
Normal file
|
@ -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
|
9
app/controllers/pages_controller.rb
Normal file
9
app/controllers/pages_controller.rb
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
class PagesController < ApplicationController
|
||||||
|
|
||||||
|
require 'statistics'
|
||||||
|
|
||||||
|
def landing
|
||||||
|
@statistics = Statistics.new
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
2
app/helpers/pages_helper.rb
Normal file
2
app/helpers/pages_helper.rb
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
module PagesHelper
|
||||||
|
end
|
|
@ -6,4 +6,8 @@
|
||||||
Log een keer in!
|
Log een keer in!
|
||||||
%p= link_to "Log in met Zeus WPI", user_omniauth_authorize_path(:zeuswpi)
|
%p= link_to "Log in met Zeus WPI", user_omniauth_authorize_path(:zeuswpi)
|
||||||
%h2 Cute Little Statistics
|
%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}!"
|
||||||
|
|
|
@ -22,5 +22,8 @@ module Tab
|
||||||
|
|
||||||
# Do not swallow errors in after_commit/after_rollback callbacks.
|
# Do not swallow errors in after_commit/after_rollback callbacks.
|
||||||
config.active_record.raise_in_transactional_callbacks = true
|
config.active_record.raise_in_transactional_callbacks = true
|
||||||
|
|
||||||
|
# Which is the lowest balance you should be ashamed of.
|
||||||
|
config.shameful_balance = 50
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,7 +3,7 @@ Rails.application.routes.draw do
|
||||||
omniauth_callbacks: 'callbacks'
|
omniauth_callbacks: 'callbacks'
|
||||||
}
|
}
|
||||||
|
|
||||||
root to: 'high_voltage/pages#show', id: "landing"
|
root to: 'pages#landing'
|
||||||
|
|
||||||
resources :transactions, only: [:index, :create]
|
resources :transactions, only: [:index, :create]
|
||||||
resources :users, only: [:show, :index]
|
resources :users, only: [:show, :index]
|
||||||
|
|
5
spec/controllers/pages_controller_spec.rb
Normal file
5
spec/controllers/pages_controller_spec.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe PagesController, type: :controller do
|
||||||
|
|
||||||
|
end
|
15
spec/helpers/pages_helper_spec.rb
Normal file
15
spec/helpers/pages_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 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
|
Loading…
Reference in a new issue