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 ComicsController < ApplicationController | |
| respond_to :html | |
| before_filter :authenticated | |
| before_filter :authenticate_admin, except: :index | |
| expose :comic | |
| expose(:comics) do | |
| User.find_by_username(params[:username]).try(:comics) || Comic.all | |
| 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
| module YourApp | |
| class Application < Rails::Application | |
| config.generators do |g| | |
| g.orm :mongoid | |
| 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
| Fabricator(:model) do | |
| manufacturer! | |
| name { Fabricate.sequence(:model_name) { |i| "Model #{i}" } } | |
| 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 Model < ActiveRecord::Base | |
| belongs_to :manufacturer | |
| has_many :motorcycles | |
| validates :name, presence: true, uniqueness: true | |
| 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 Manufacturer < ActiveRecord::Base | |
| has_many :models | |
| validates_presence_of :name | |
| end | |
| class Model < ActiveRecord::Base | |
| belongs_to :manufacturer | |
| has_many :motorcycles |
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' | |
| context 'as a guest on the sign in page' do | |
| #Make sure your factory generates a valid user for your authentication system | |
| let(:user) { Factory(:user) } | |
| #Browse to the homepage and click the Sign In link | |
| before do | |
| visit root_path |
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
| group :test do | |
| gem "capybara", ">= 0.3.9" | |
| gem "rspec-rails", ">= 2.0.0.beta.12" | |
| 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
| require 'action_dispatch' | |
| require 'capybara/rails' | |
| require 'capybara/dsl' | |
| module RSpec::Rails | |
| module IntegrationExampleGroup | |
| extend ActiveSupport::Concern | |
| include ActionDispatch::Integration::Runner | |
| include RSpec::Rails::TestUnitAssertionAdapter |
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 javascript_confirm(answer) | |
| page.evaluate_script 'window._confirm = window.confirm' | |
| page.evaluate_script "window.confirm = function(x) { return #{answer} }" | |
| yield | |
| page.evaluate_script 'window._confirm && (window.confirm = window._confirm)' | |
| page.evaluate_script 'window._confirm = null' | |
| end |
NewerOlder