This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I don't really see any services here. What I see is: | |
# - Normal HTTP boundary stuff (params flash, redirect). | |
# - Model creation and retrieval. | |
# - Warden manipulation, which is an odd done but smells like boundary. | |
# | |
# I left all of the HTTP boundary stuff in the controller (and only the | |
# controller). I moved the model creation/retrieval into simple class methods | |
# in the models. I moved the warden manipulation stuff into | |
# ApplicationController (with caveats that I'll discuss inline). | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Hash form: | |
{ | |
:current_user => "CurrentUser.current_user" | |
} | |
# Discovery form with inverted app structure: | |
module Injectables | |
def current_user(session) | |
User.find(:id => session['current_user_id']) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rails controller | |
def create | |
@profile = ProfileManager.create(params[:profile]) | |
rescue ProfileManager::CreationFailed => e | |
render :new, :errors => e.errors | |
end | |
# Raptor route | |
create :to => "ProfileManager#create", ProfileManager::CreationFailed => render(:new) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I want to give a lightning talk about: | |
"Wat?" | |
I need the projector: yes / no | |
Yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# mock-based (interaction) | |
# db independent, but tied to implementation (I can change the AR call without affecting the behavior and this will fail) | |
context "data gathering" do | |
it "finds all indicators associated with the given sector and includes indicators not associated with any sectors" do | |
sector = stub_model(Sector, :id => 6) | |
Indicator.should_receive(:where).with("sector_id is null or sector_id = ?", sector.id) | |
Indicator.for_sector(sector) | |
end |