This file contains hidden or 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 Cart | |
| def initialize | |
| @products = [] | |
| @rules = [] | |
| end | |
| def regular_total | |
| @products.map { |p| p.price }.inject(&:+) | |
| end |
This file contains hidden or 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 << self | |
| attrs_without_id = AppConfig.column_names.delete_if {|x| x=='id'} | |
| default_values = {'pending_earned_buck_period'=>30*24*60, 'pending_refer_buck_period'=>60*24*60, 'refer_buck_valid_period'=>100*24*60, 'order_delivery_hold_period'=>3*24*60,'code_length'=>8} | |
| attrs_without_id.each do |attr| | |
| define_method(attr) do | |
| load_config | |
| @config && @config.send(attr) || default_values[attr] | |
| end | |
| end | |
| end |
This file contains hidden or 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
| $(document).onready(function(){ | |
| var _timerId = 0; | |
| $("searchButton").keyup(function(){ | |
| window.clearTimeout(_timerId); | |
| _timerId = window.setTimeout(function() { | |
| ...perform actual search... | |
| }, 170); | |
| }).keydown(function(){ | |
| window.clearTimeout(_timerId); |
This file contains hidden or 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
| var delay = (function(){ | |
| var timer = 0; | |
| return function(callback, ms){ | |
| clearTimeout (timer); | |
| timer = setTimeout(callback, ms); | |
| }; | |
| })(); | |
| $('input').keyup(function() { |
This file contains hidden or 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
| [user] | |
| name = eric chen | |
| email = youremail | |
| [alias] | |
| st = status | |
| co = checkout | |
| ci = commit | |
| br = branch | |
| [color] | |
| ui = auto |
This file contains hidden or 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
| it "should sending command after record created" do | |
| @cmd_pool = CommandPool.new | |
| @cmd_pool.valid?.should == true | |
| @cmd_pool.should_receive(:send_udp_command) | |
| @cmd_pool.run_callbacks(:create) | |
| end |
This file contains hidden or 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
| it "should not update email" do | |
| lambda { | |
| post :profile, {:user => {:email=>'', :first_name => 'jacky'}} | |
| @user.reload | |
| }.should_not change(@user, :email) | |
| end | |
| it "should update first name" do | |
| expect { | |
| post :profile, {:user => {:email=>'', :first_name => 'jacky'}} |
This file contains hidden or 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
| User.stub!(:create!).and_raise(Mongoid::Errors::Validations) |
This file contains hidden or 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
| mock_http = mock("http") | |
| Net::HTTP.stub!(:new).with('www.google.com', 443).and_return(mock_http) | |
| mock_http.should_receive(:use_ssl=).with(true) | |
| mock_http.stub!(:start).and_yield mock_http | |
| mock_http.stub!(:request).and_return 3 | |
| get :rate_password, :password => '12345678' | |
| response.should be_success |
This file contains hidden or 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
| <?xml version="1.0" encoding="UTF-8"?> | |
| <yahoo-weather-codes> | |
| <code number="0" description="tornado"/> | |
| <code number="1" description="tropical storm"/> | |
| <code number="2" description="hurricane"/> | |
| <code number="3" description="severe thunderstorms"/> | |
| <code number="4" description="thunderstorms"/> | |
| <code number="5" description="mixed rain and snow"/> | |
| <code number="6" description="mixed rain and sleet"/> | |
| <code number="7" description="mixed snow and sleet"/> |
OlderNewer