Skip to content
source 'http://rubygems.org'
gem 'nesta', '~> 0.9.13'
gem 'haml'
gem 'haml-coderay'
gem 'sass'
gem 'compass'
gem 'sprockets-sass'
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
import unittest
POINTS = ('0', '15', '30', '40')
def increment_point(player_points, scorer):
if player_points == ['40', '40']:
scorer_points = 'ADV'
else:
$.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)
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)
def redirect_to_app_when_logged_in
if request.path == '/' && request.referer.blank? && current_user
redirect_to iteration_path('current')
end
end
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
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)
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
class CardCreator < Struct.new(:listener)
class Failed < RuntimeError
attr_accessor :model
def initialize(model)
@model = model
end
end
def self.create(iteration, attributes)
Something went wrong with that request. Please try again.