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
dealers = Dealer.arel_table | |
sales_reps = SalesRep.arel_table | |
dealer_counts = dealers. | |
group(dealers[:sales_rep_id]). | |
where(dealers[:deleted_at].eq(nil)). | |
where(dealers[:ended].eq(nil)). | |
project(dealers[:sales_rep_id], dealers[:id].count.as('value')) | |
def left_outer_join(subselect,as,on) | |
result = Arel.sql("") |
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 next | |
loop do | |
if cache.empty? | |
cache.concat(next_block) | |
if cache.empty? | |
nil | |
else | |
redo | |
end | |
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
class Datatable::Base | |
#.... | |
include ActionView::Helpers::UrlHelper | |
include ActionView::Helpers::TagHelper | |
def method_missing(symbol, *args, &block) | |
if symbol.to_s =~ /(path|url)$/ | |
return Rails.application.routes.url_helpers.send(symbol, *args) | |
end | |
super(symbol, *args, &block) | |
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
RSpec.configure do |config| | |
config.before(:suite) do | |
ActiveRecord::Base.establish_connection database['one'] | |
DatabaseCleaner.strategy = :deletion | |
ActiveRecord::Base.establish_connection config.database['two'] | |
DatabaseCleaner.strategy = :deletion | |
end | |
config.before(:each) 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
bundle config build.linecache19 --with-ruby-include=$rvm_path/src/ruby-1.9.2-p290 | |
bundle config build.ruby-debug-base19 --with-ruby-include=$rvm_path/src/ruby-1.9.2-p290 |
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
tries, connection = 0, nil | |
print "connecting to #{dns_name}" | |
until connection || ((tries += 1) > 10) | |
begin | |
Timeout::timeout(5) do | |
begin | |
connection = Net::SSH.start(dns_name, user_name, ssh_options) | |
rescue Exception => e | |
connection = 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
# ./config/initializers/datatable.rb | |
Datatable::Base.configure do |config| | |
config.jquery_ui = true | |
config.table_tools = true | |
config.sDom = '<"H"lrf>t<"F"ip>' | |
config.iDisplayLength = 25 | |
config.oLanguage = { 'sProcessing' => "<img alt='Spinner' src='/images/loader.gif'/>", 'sInfoFiltered' => '' } | |
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
# Edit this file to introduce tasks to be run by cron. | |
# | |
# Each task to run has to be defined through a single line | |
# indicating with different fields when the task will be run | |
# and what command to run for the task | |
# | |
# To define the time you can provide concrete values for | |
# minute (m), hour (h), day of month (dom), month (mon), | |
# and day of week (dow) or use '*' in these fields (for 'any').# | |
# Notice that tasks will be started based on the cron's system |
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: dealer creates warranty claim | |
Background: | |
Given I am a dealer | |
Scenario: Dealer fails to create a warranty claim | |
Given I'm on the "new warranty claim" page | |
When I submit invalid warranty claim details | |
Then I should see an error | |
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
describe WarrantyClaim do | |
it "validates presence of failure_date" do | |
warranty_claim = Factory.build(:warranty_claim) | |
warranty_claim.failure_date = nil | |
warranty_claim.valid?.should be_false | |
warranty_claim.failure_date = Date.today | |
warranty_claim.valid?.should be_true | |
end |