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 KeepUp | |
module Permissions | |
module CommonMethods | |
def self.included(klass) | |
klass.class_eval do | |
alias :authorize :grant | |
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
module KeepUp | |
module Permissions | |
module Language | |
def method_missing(method_id, *attrs) | |
if /can_not_(.+)\?/.match(method_id.to_s) | |
return !has_permission?($~[1]) | |
elsif /can_(.+)\?/.match(method_id.to_s) | |
return has_permission?($~[1]) | |
#elsif /is_(.+)\?/.match(method_id.to_s) | |
#return true if has_permission? :god |
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 KeepUp | |
module Permissions | |
module RoleExtension | |
def self.included(klass) | |
klass.class_eval do | |
include KeepUp::Permissions::CommonMethods | |
include KeepUp::Permissions::Language | |
has_and_belongs_to_many :users, :join_table => :user_roles | |
has_one :permission, :as => :authorizable |
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 KeepUp | |
module Permissions | |
module UserExtension | |
def self.included(klass) | |
klass.class_eval do | |
has_one :permission, :as => :authorizable | |
has_and_belongs_to_many :roles, :join_table => :user_roles | |
alias :can? :has_permission? | |
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
vendored_cucumber_dir = Dir["#{RAILS_ROOT}/vendor/{gems,plugins}/cucumber*"].first | |
$LOAD_PATH.unshift("#{vendored_cucumber_dir}/lib") unless vendored_cucumber_dir.nil? | |
require 'cucumber/rake/task' | |
namespace :cucumber do | |
vendored_cucumber_binary = "#{vendored_cucumber_dir}/bin/cucumber" unless vendored_cucumber_dir.nil? | |
Cucumber::Rake::Task.new({:rcov => 'db:test:prepare'}, 'Run features through RCOV') do |t| | |
t.binary = vendored_cucumber_binary |
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
# mocks s3 for testing | |
S3_MODELS = { | |
:user => :avatar, | |
:car => :picture | |
} | |
S3_MODELS.each do |model, attachment| | |
definition = model.to_s.gsub(" ", "_").classify.constantize.attachment_definitions[attachment.to_sym] | |
path = "http://s3.amazonaws.com/:id/#{definition[:path]}" |
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
>> m = Mail.new :bcc => "[email protected]" | |
=> #<Mail::Message:2187944080, Multipart: false, Headers: <Bcc: [email protected]>> | |
>> m.bcc | |
=> ["[email protected]"] | |
>> m.to_s | |
=> "Date: Sat, 27 Mar 2010 02:18:00 -0700\r\nMessage-ID: <[email protected]>\r\nMime-Version: 1.0\r\nContent-Type: text/plain;\r\n\tcharset=\"US-ASCII\";\r\nContent-Transfer-Encoding: 7bit\r\n\r\n" | |
>> a = Mail.new(to_s) | |
=> #<Mail::Message:2187861660, Multipart: false, Headers: <main: >> | |
>> a.bcc | |
=> nil |
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
// duplicates the current functionality | |
settingsCheck({ | |
askUrl: '/settings/todo/ready', | |
formUrl: '/settings/todo/edit', | |
selector: 'a.new-todo', | |
event: 'click', | |
defaultAction: function() { | |
$("a.new-todo").live('click', function(){ | |
$("#" + $(this).attr('rel')).toggle('fast'); | |
return false; |
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
#!/usr/bin/ruby | |
require 'rss/2.0' | |
require 'open-uri' | |
require 'uri' | |
require 'rubygems' | |
require 'active_record' | |
ActiveRecord::Base.establish_connection :adapter => 'sqlite3', :database => 'downloaded.sqlite3' |
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
require File.expand_path(File.dirname(__FILE__) + "/../config/environment") | |
class MockResponse | |
def content_type | |
'text/html' | |
end | |
end | |
class RenderingController < ApplicationController |
OlderNewer