Remove ugly constraint

This commit is contained in:
benji 2015-03-03 20:11:50 +01:00
parent d72f691442
commit ea93a4c456
5 changed files with 15 additions and 8 deletions

View file

@ -70,3 +70,5 @@ gem 'paper_trail', '~> 4.0.0.beta'
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw] gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]
gem 'coveralls', require: false gem 'coveralls', require: false
gem "codeclimate-test-reporter", group: :test, require: nil

View file

@ -71,6 +71,8 @@ GEM
activesupport (>= 3.0) activesupport (>= 3.0)
cocaine (0.5.5) cocaine (0.5.5)
climate_control (>= 0.0.3, < 1.0) climate_control (>= 0.0.3, < 1.0)
codeclimate-test-reporter (0.4.7)
simplecov (>= 0.7.1, < 1.0.0)
coffee-rails (4.0.1) coffee-rails (4.0.1)
coffee-script (>= 2.2.0) coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.0) railties (>= 4.0.0, < 5.0)
@ -240,6 +242,7 @@ DEPENDENCIES
capistrano (~> 3.1) capistrano (~> 3.1)
capistrano-rails (~> 1.1) capistrano-rails (~> 1.1)
capistrano-rvm capistrano-rvm
codeclimate-test-reporter
coffee-rails (~> 4.0.0) coffee-rails (~> 4.0.0)
coveralls coveralls
devise devise

View file

@ -1,5 +0,0 @@
class UserHomepageConstraint < Struct.new(:role)
def matches?(request)
role == request.env['warden'].user.koelkast?
end
end

View file

@ -5,9 +5,13 @@ Rails.application.routes.draw do
unauthenticated :user do unauthenticated :user do
root to: 'devise/sessions#new' root to: 'devise/sessions#new'
end end
authenticated :user do
root to: 'orders#overview', constraints: UserHomepageConstraint.new(true), as: 'koelkast_root' authenticated :user, ->(u) { u.koelkast? } do
root to: 'users#show', constraints: UserHomepageConstraint.new(false), as: 'user_root' root to: 'orders#overview', as: :koelkast_root
end
authenticated :user, ->(u) { !u.koelkast? } do
root to: 'users#show', as: :user_root
end end
end end

View file

@ -1,3 +1,6 @@
require "codeclimate-test-reporter"
CodeClimate::TestReporter.start
require 'coveralls' require 'coveralls'
Coveralls.wear! Coveralls.wear!