Skip to content

Instantly share code, notes, and snippets.

View tdouce's full-sized avatar

Travis Douce tdouce

View GitHub Profile
# spec/models/user_spec.rb` in client
it 'should be able to create a user with remote_factory_girl' do
user = RemoteFactoryGirl.create(:user, first_name: 'Sam')
expect(user.first_name).to eq('Sam')
end
# spec/spec_helper.rb` in client
RSpec.configure do |config|
config.before(:suite) do
RemoteDatabaseCleaner.clean
end
config.after(:each) do
RemoteDatabaseCleaner.clean
end
end
# spec/models/user_spec.rb
it "should be able to create a user with factory_girl" do
user = FactoryGirl.create(:user, first_name: 'Sam')
expect(user.first_name).to eq('Sam')
end
@tdouce
tdouce / spec_helper.rb
Last active August 29, 2015 14:03
Part of 'Testing Rails Service Oriented Architecture' blog
# spec/spec_helper.rb in client
...
require 'rspec/rails'
require 'database_cleaner'
...
RSpec.configure do |config|
config.before(:suite) do
# spec/factories/users.rb
FactoryGirl.define do
factory :user do
sequence(:email) { |n| "user#{n}@bignerdranch.com" }
sequence(:username) { |n| "user#{n}" }
password 'test123'
password_confirmation 'test123'
terms_of_use true
confirmed_at Time.now
@tdouce
tdouce / gist:6193810
Last active December 20, 2015 20:58 — forked from jeremiaheb/gist:6186725
class DashboardController < ApplicationController
before_filter :authenticate_diver!
authorize_resource
def show
@divers = Dashboard.new.divers(current_diver)
end
end
class DashboardController < ApplicationController
before_filter :authenticate_diver!
authorize_resource
def show
if current_diver.role == 'admin'
@boat_logs = BoatLog.all
elsif current_diver.role == 'manager'
@boat_logs = BoatLog.where( "boatlog_manager_id=?", current_diver.boatlog_manager_id )
@tdouce
tdouce / gist:4070231
Created November 14, 2012 04:20
changes to midland
app/models/model.rb
class Model < ActiveRecord::Base
include Tire::Model::Search
include Tire::Model::Callbacks
index_name INDEX_NAME
....
....
end
.project-eval .credit-details td { padding-left: 30px; padding-bottom: 8px; }
@tdouce
tdouce / gist:2158574
Created March 22, 2012 14:14
Jquery - Toggle distance text app/views/catalogs/_product_feature.rhtml
<script type="text/javascript">
$TB_jq(document).ready(function(){
// Hide all initially
$TB_jq(".distance-description-text").hide();
// Toggle visible and non-visible
$TB_jq('.distance-description').toggle(
function() {