add simplistic wall of shame

This commit is contained in:
Felix Van der Jeugt 2015-09-11 18:04:45 +02:00
parent b81bccabac
commit 3530fd1e5d
10 changed files with 61 additions and 2 deletions

View 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/

View 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/

View 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

View file

@ -0,0 +1,9 @@
class PagesController < ApplicationController
require 'statistics'
def landing
@statistics = Statistics.new
end
end

View file

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

View file

@ -7,3 +7,7 @@
%p= link_to "Log in met Zeus WPI", user_omniauth_authorize_path(:zeuswpi)
%h2 Cute Little Statistics
%p None here yet.
%h2 Wall of Shame
%ul
- @statistics.shameful_users.each do |user|
%li="Shame on #{user.name}!"

View file

@ -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

View file

@ -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]

View file

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe PagesController, type: :controller do
end

View 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