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 ImportController << ApplicationController | |
| require 'net/http' | |
| require 'net/https' | |
| require 'uri' | |
| #THIS METHOD TO SEND USER TO THE GOOGLE AUTHENTICATION PAGE. | |
| def authenticate | |
| # initiate authentication w/ gmail | |
| # create url with url-encoded params to initiate connection with contacts api |
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
| require 'spec_helper' | |
| describe Purchase do | |
| before :all do | |
| @city = Factory.create(:city) | |
| @user = Factory.create(:user, :cities => [@city]) | |
| @ticket = Factory.create(:ticket) | |
| 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
| describe Foo do | |
| let(:bar) { Factory.create(:bar) } | |
| subject { Factory.create(:foo, :bar => bar) } | |
| context "something" do | |
| let(:bar) { Factory.create(:different_bar) } |
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
| ruby-1.9.2-p180 :005 > Date.today.to_time | |
| => 2011-05-12 00:00:00 +0300 | |
| ruby-1.9.2-p180 :006 > Date.today.to_datetime | |
| => Thu, 12 May 2011 00:00:00 +0000 | |
| ruby-1.9.2-p180 :007 > Date.today.to_time_in_current_zone | |
| => Thu, 12 May 2011 00:00:00 EDT -04:00 | |
| ruby-1.9.2-p180 :008 > Time.zone | |
| => (GMT-05:00) Eastern Time (US & Canada) | |
| ruby-1.9.2-p180 :009 > Time.now | |
| => 2011-05-12 23:43:28 +0300 |
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
| def set_cache_buster | |
| response.headers["Cache-Control"] = "no-store, no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0" | |
| response.headers["Pragma"] = "no-cache" | |
| response.headers["Expires"] = "#{10.year.ago}" | |
| 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
| RSpec.configure do |config| | |
| config.include Paperclip::Shoulda::Matchers | |
| config.mock_with :mocha | |
| config.use_transactional_fixtures = true | |
| config.before(:all) do | |
| geocode_payload = GeoKit::GeoLoc.new(:lat => 123.456, :lng => 123.456) | |
| geocode_payload.success = true | |
| GeoKit::Geocoders::MultiGeocoder.stubs(:geocode => nil) | |
| 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
| # TODO - add dependent option support | |
| def delete_records(records) | |
| case @reflection.through_reflection.options[:dependent] | |
| when :destroy | |
| records.each do |associate| | |
| @reflection.through_reflection.klass.destroy_all(construct_join_attributes(associate)) | |
| end | |
| when :delete_all | |
| @reflection.through_reflection.klass.delete(records.map { |record| record.id }) | |
| else |
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
| auth = Twitter::OAuth.new(TWITTER_TOKEN, TWITTER_SECRET) | |
| auth.authorize_from_access(TWITTER_ACCESS_TOKEN, TWITTER_ACCESS_SECRET) | |
| base = Twitter::Base.new(auth) | |
| base.update("#{title} - #{url}") |
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 UserPassword | |
| include ActiveModel::Validations | |
| include ActiveModel::Validations::Callbacks | |
| include ActiveModel::Conversion | |
| extend ActiveModel::Naming | |
| extend ActiveModel::Translation | |
| attr_accessor :email |
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
| def value=(value) | |
| write_attribute(:value, value.gsub(/<your regexp>/, '')) | |
| end |