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
Given /^(?:|I )am on (.+)$/ do |page_name| | |
visit path_to(page_name) | |
selenium.wait_for_page_to_load(5) | |
end | |
When /^(?:|I )press "([^\"]*)"$/ do |button| | |
click_button(button) | |
selenium.wait_for_page_to_load(5) | |
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
Scenario: unsucessful login | |
Given "John Doe" is a registered user | |
And I am on the login page | |
When I fill in "email" with "John Doe's" user information | |
And I fill in "password" with "incorrect information" | |
And I press "Login" | |
Then I should be on the login page | |
And I should see "Login unsuccessful!" |
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
git config --global user.name "Your Name Comes Here" | |
git config --global user.email [email protected] | |
git config --global core.editor "vim" | |
git config --global core.excludesfile ~/.gitignore | |
git config --global color.diff auto | |
git config --global color.status auto | |
git config --global color.branch auto | |
git config --global color.interactive auto | |
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
#------------------------------------------------------------------------------------------------------------------ | |
# type name description | |
#------------------------------------------------------------------------------------------------------------------ | |
# int iTotalRecords Total records, before filtering (i.e. the total number of records in | |
# the database) | |
# | |
# int iTotalDisplayRecords Total records, after filtering (i.e. the total number of records after | |
# filtering has been applied - not just the number of records being returned | |
# in this result set) | |
# |
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 render(object) | |
receiver = object | |
accessors = accessor.split(".") | |
while accessor = accessors.shift | |
if receiver.class.reflect_on_association(accessor.to_sym) | |
receiver = receiver.send(accessor) | |
else | |
return receiver.send(accessor) | |
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
# 1. data table subclass is initialized | |
# class methods are going to be called on the class instance, and the class will store table data | |
# | |
# 2. instantiate an instance of the data table subclass ( OrdersIndex.new) | |
# | |
# 3. query the instance w/ pagination and sorting params | |
# a query gets executed w/ params -> ARel | |
# results get stored -> AR | |
# results get passed back as json | |
class DataTable |
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 Foo | |
# create class instance variables | |
class << self; | |
attr_accessor :bar; | |
end | |
#initialize class instance variables | |
@bar = 42 | |
# use class instance variables in class methods |
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 'spec_helper' | |
describe 'Data tables subclasses' do | |
# it 'should work' do | |
# Order.create!(:order_number => 32) | |
# data_table = OrdersIndex.new | |
# params = {} | |
# json = data_table.query(params).json | |
# json['aaRecords'][0][0].should == 32 |
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
# apps/data_tables/orders_index.rb | |
class OrdersIndex < DataTable | |
model Order | |
column :order_number, :width => 300 | |
joins :customer | |
column :first_name | |
column :last_name | |
end | |
column :memo | |
order [:memo, :first_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
# undefine the class if it's defined | |
Object.send(:remove_const, :OrderExample) rescue nil | |
# define the class | |
class OrderExample < DataTable | |
set_model Order | |
column :id | |
column :order_number | |
joins :customer do | |
column :first_name |
OlderNewer