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
source 'http://rubygems.org' | |
gem 'nesta', '~> 0.9.13' | |
gem 'haml' | |
gem 'haml-coderay' | |
gem 'sass' | |
gem 'compass' | |
gem 'sprockets-sass' |
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
the 'create action' do | |
def post_create(params = {}) | |
post :create, invitation: params | |
end | |
def valid_params | |
{ email: 'user@domain.com', first_name: 'First', last_name: 'Last' } | |
end | |
it 'should send an email to invite new users' do |
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
import unittest | |
POINTS = ('0', '15', '30', '40') | |
def increment_point(player_points, scorer): | |
if player_points == ['40', '40']: | |
scorer_points = 'ADV' | |
else: |
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
$.ajax @api_url, | |
dataType: 'json' | |
beforeSend: (jqXHR, settings) -> | |
jqXHR.setRequestHeader('X-Requested-With', 'XMLHttpRequest') | |
success: (data, textStatus, jqXHR) => | |
@onDataLoaded(data, textStatus, jqXHR) | |
callback?() | |
error: (jqXHR, textStatus, errorThrown) => | |
@onLoadFailed(jqXHR, textStatus, errorThrown) |
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
module CapybaraAssertions | |
def css_assertion_builder(outcome, selector, text, message) | |
if text | |
options = { :text => text } | |
message ||= "#{outcome} have found '#{selector}' containing '#{text}'" | |
else | |
options = {} | |
message ||= "#{outcome} have found '#{selector}'" | |
end | |
is_present = page.has_css?(selector, options) |
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
def redirect_to_app_when_logged_in | |
if request.path == '/' && request.referer.blank? && current_user | |
redirect_to iteration_path('current') | |
end | |
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
class TasksController < ApplicationController | |
def complete | |
# add responder as listener, or could subscribe etc... | |
# task could be the actual task, or pass through the ID | |
task.add_subscriber(TaskCompletedResponse.new(self)) | |
task.add_subscriber(TaskEmail.new) | |
task.add_subscriber(TaskIndex) | |
task.complete_by(person) | |
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
class CardCreator | |
include Publisher | |
def create(iteration, attributes) | |
card = iteration.cards.build(attributes) | |
card.save! | |
rescue ActiveRecord::RecordInvalid | |
notify_subscribers(:create_failed, card) | |
else | |
notify_subscribers(:created, card) |
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
class CardCreator < Struct.new(:listener) | |
def create(iteration, attributes) | |
card = iteration.cards.build(attributes) | |
if card.save | |
listener.created(card) | |
else | |
listener.create_failed(card) | |
end | |
end | |
end |