Skip to content

Instantly share code, notes, and snippets.

View albertobajo's full-sized avatar

Alberto Bajo albertobajo

  • Sage
  • Bilbao
  • 23:23 (UTC +02:00)
View GitHub Profile
@kamloops
kamloops / linkedin_oauth2_sample.rb
Last active April 19, 2017 06:01
Simple LinkedIn OAuth2 authentication
require 'oauth2'
require 'net/http'
require 'uri'
API_KEY = 'XXXXXXXXX' #Your app's API key
API_SECRET = 'XXXXXXXXXXXXX' #Your app's API secret
REDIRECT_URI = 'http://localhost:3000/accept' #Redirect users after authentication to this path
#Instantiate your OAuth2 client object
def client
@eileencodes
eileencodes / gist:5b0a2fe011dcff6203fe
Last active October 28, 2021 14:21
CollectionProxy `delete_all` and `destroy_all` behavior by dependency AND association type AND strategy

Testing behavior of a CollectionProxy based on :dependent option, delete method used and assocation type (:has_many vs :has_many :through)

:has_many association

class Category < ActiveRecord::Base
	has_many :contacts, through: :categorizations
	has_many :categorizations, dependent: DEPENDENT
end
@murbanski
murbanski / api_clients_controller_spec.rb
Last active February 27, 2024 19:53
RSpec 3.1 and Rails 4 HTTP Digest Auth testing
# spec/controllers/api_clients_controller_spec.rb
RSpec.describe APIClientsController, type: :controller do
let(:api_client) { mock_model(APIClient) }
context "when HTTP Digest auth credentials are invalid" do
before do
authenticate_with_http_digest("invalid_login", "invalid_password") do
get :index
end
end