Skip to content

Instantly share code, notes, and snippets.

View keeperofthenecklace's full-sized avatar

Albert McKeever keeperofthenecklace

  • New Jersey, U.S.A
View GitHub Profile
DASH
------
:Dash[!]
:Dash printf
:Dash setTimeout javascript
:Dash!
:Dash! func #Will search for 'func' in all docsets.
:DashKeywords
:DashKeywords backbone underscore javascript
@keeperofthenecklace
keeperofthenecklace / index.html.erb
Created July 23, 2015 17:43
Displays all products.
<h4><%= @product[0].quote.category.name.titleize if @product.present? %> Products</h4>
<% if @product.present? %>
<%= render partial: '/products/listings', locals: { product: @product } %>
<% else %>
<p>The are no agape love quotes</p>
<%= render partial: '/products/no_product' %>
<% end %>
@keeperofthenecklace
keeperofthenecklace / search_controller.rb
Last active August 29, 2015 14:25
This is based of ElasticSearch.
class SearchController < ApplicationController
before_action :set_search_option, only: [:index]
# Query the product model and return all indexed items.
def index
@product_results = ProductsIndex.aggregations(search_aggregations)
apply_filters(@search_options[:search_with]).each { |filter| @product_results = @product_results.merge(filter) }
# Apply any facet filters already selected
if @search_term.present?
@keeperofthenecklace
keeperofthenecklace / gist:3388605
Created August 18, 2012 17:33
Gemfile_setupgemfile.rb
gem 'rails', '3.2.6'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'mysql2'
gem 'heroku'
gem 'newrelic_rpm'
gem 'exception_notification'
@keeperofthenecklace
keeperofthenecklace / authentication_steps.rb
Created August 18, 2012 17:35
features/step_definitions/authentication_steps
Given /^a user visits the signin page$/ do
visit signin_path
end
When /^he submits invalid information$/ do
click_button "Sign in"
end
Then /^he should see an error message$/ do
page.should have_selector('div.alert.alert-error')
@keeperofthenecklace
keeperofthenecklace / sign_in.feature
Created August 18, 2012 17:37
features/sign_in.feature
Feature: Signing in
Scenario: Unsuccessful signin
Given a user visits the signin page
When he submits invalid information
Then he should see an error message
Scenario: Successful signin
Given a user visits the signin page
And the user has an account
@keeperofthenecklace
keeperofthenecklace / sessions_controller.rb
Created August 18, 2012 17:52
spec/controller/sessions_controller
class SessionsController < ApplicationController
def new
end
def create
user = User.find_by_email(params[:session][:email])
if user && user.authenticate(params[:session][:password])
sign_in user
redirect_to user
@keeperofthenecklace
keeperofthenecklace / application_helper.rb
Created August 18, 2012 17:55
spec/helpers/application_helper.rb
require 'spec_helper'
describe ApplicationHelper do
describe "full_title" do
it "should include the page title" do
full_title("foo").should =~ /foo/
end
it "should include the base title" do
@keeperofthenecklace
keeperofthenecklace / user_spec.rb
Created August 18, 2012 17:56
spec/models/user_spec.rb
# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# name :string(255)
# email :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
@keeperofthenecklace
keeperofthenecklace / authentication_pages_spec.rb
Created August 18, 2012 17:58
spec/requests/authentication_pages_spec.rb
require 'spec_helper'
describe "authentication" do
subject { page }
describe "signin page" do
before { visit signin_path }
describe "with invalid information" do