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 'test/unit' | |
require 'test/unit/ui/testrunnermediator' | |
require 'test/unit/ui/testrunnerutilities' | |
require 'rubygems' | |
require 'redgreen' | |
module Test::Unit | |
class TestCase | |
def name |
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 SMarkUp | |
def markup(&block) | |
yield | |
end | |
TAGS = %w(body h1 h2 p div) | |
TAGS.each do |tag| | |
send(:define_method, tag) do |*args, &block| | |
r = block.call | |
r = case r | |
when Array |
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 Test::Unit::TestCase | |
def self.should_require_login(http_method, method) | |
should "require login wth #{http_method.to_s.upcase} :#{method}" do | |
raise "http verb(#{http_method} is not my cup of tea)" unless [:put, :get, :post, :delete].include? http_method.to_sym | |
if UserSession.find | |
UserSession.find.destroy | |
end | |
eval(http_method.to_s + "(\"#{method}\")") | |
assert_redirected_to new_user_session_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
module RecordNotFoundMacros | |
def should_raise_record_not_found(&block) | |
should "raise 'Record not Found'" do | |
assert_raise(ActiveRecord::RecordNotFound) {block.bind(self).call} | |
end | |
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
// Set passed background-image to form type=submit just before ajax request was submitted. | |
// reset with ajax:complete. | |
// options: | |
// loadingImage: background-image | |
// loadingText: text | |
jQuery.fn.swapBackgroundToLoading = function(options){ | |
$(this).live('ajax:before', function(){ | |
var submit = $(this).find('input[type=submit]') | |
var text = submit.val(); | |
var backgroundImage = submit.css('background-image'); |
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
# -*- encoding: utf-8 -*- | |
require 'httparty' | |
class RemoteRedmine | |
include HTTParty | |
def initialize(cap) | |
raise ArgumentError, 'Please set your redmine settings' if !cap[:redmine] | |
self.class.base_uri cap[:redmine][:url] | |
self.class.default_params :key => cap[:redmine][:access_key] |
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
ls -t1|awk '{if(/f/ && nlines++ >= 5) print $1;}'|xargs rm |
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
after 'deploy' do | |
run "crontab -r && crontab #{File.join(current_path, 'cron')}" | |
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 | |
helper_method :count_something | |
def count_something | |
cache_of_today "count-of-something" do | |
Something.count | |
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
require 'active_support/all' | |
class HashWithJavaScriptishAccess < Hash | |
def method_missing(name, *args) | |
if name.to_s =~ /=$/ | |
name_to_be_set = name.to_s.gsub(/=$/, '').to_sym | |
self[name_to_be_set] = args.first | |
else | |
self[name] || super | |
end |
OlderNewer