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 Membership | |
belongs_to :user | |
belongs_to :group | |
after_save :send_email_notification, if: ->(m) { m.accepted_changed? && m.accepted? } | |
def send_email_nofication | |
NotificationMailer.accepted(self, user).deliver! | |
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
# session controller | |
# receives callbacks with oauth | |
class SessionsController < ApplicationController | |
skip_before_filter :login_required | |
def create | |
login.run! | |
redirect_to root_path | |
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
# in your spec_helper.rb | |
RSpec.configure do |config| | |
config.around(:each) do |example| | |
timeout(0.2) { example.run } | |
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
machine: | |
environment: | |
AWS_ACCESS_KEY_ID: | |
AWS_SECRET_ACCESS_KEY: | |
dependencies: | |
pre: | |
- pip install cli53 --user | |
test: | |
override: | |
- "rake" |
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
cli53 = '/home/ubuntu/.local/bin/cli53' | |
zones_on_aws = `#{cli53} list`.lines.select{|e| e =~ /Name/ }.map{|e| e.split(":").last.strip.sub(/\.$/, '') } | |
Dir.glob('zones/*.bind').each do |zone| | |
zone_name = File.basename(zone, '.bind') | |
unless zones_on_aws.include?(zone_name) | |
system("#{cli53} create #{zone_name}") | |
puts "#{zone_name} created." | |
end | |
abort("Can't sync #{zone_name}...") unless system("#{cli53} import #{zone_name} --file #{zone} --replace") |
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 KittenMailer < ActionMailer::Base | |
def mail *args | |
attachments['cat.jpeg'] = open("http://placekitten.com/#{rand(300)+300}/#{rand(300)+300}").read | |
super | |
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 ApplicationController < ActionController::Base | |
extend DecentDecorate | |
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
feature "correct syntax in project" do | |
scenario "validate coffeescript files for errors" do | |
Dir["#{Rails.root}/**/*.coffee"].each do |file| | |
%x[coffee --lint -p #{file} ] | |
$?.success?.should be_true | |
end | |
end | |
scenario "validate haml files" 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
{ | |
"name": "some_project", | |
"version": "0.0.1", | |
"dependencies": { | |
"coffee-script": "1.1.1" | |
} | |
} |
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 Hash | |
define_method '[]_with_try_on', do |*args| | |
if args.size == 1 and (args.is_a?(Symbol) or args.is_a?(String)) | |
self.send(:'[]_with_try_on', args.first) | |
else | |
args.inject(self.dup){|memo, e| memo.dup.delete(e) if memo.is_a?(Hash) } | |
end | |
end | |