This file contains 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
Factory.define :job do |j| | |
j.title 'Supply Fan Repair' | |
j.description 'A job for testing' | |
j.association :location | |
j.starts_on Date.today | |
j.due_on 1.month.from_now | |
j.unapproved_type "quote" | |
j.user { |u| u.association(:employee_user) } | |
j.category { |c| c.association(:category) } | |
end |
This file contains 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 "PUT posts/:id" do | |
describe "with valid params" do | |
before(:each) do | |
@post = mock_model(Post, :update_attributes => true) | |
Post.stub!(:find).with("1").and_return(@post) | |
post :update, :id => "1", :post => {} | |
end | |
# This passes |
This file contains 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 "GET galleries/:id/edit" do | |
before do | |
@gallery = mock_model(Gallery).as_null_object | |
@relation = double(ActiveRecord::Relation).as_null_object | |
Gallery.should_receive(:includes).and_return(@relation) | |
@relation.should_receive(:order).and_return(@relation) | |
@relation.should_receive(:find).and_return(@gallery) | |
end | |
it "should assign @gallery" do |
This file contains 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 self.import_videos(source) | |
raise "Invalid Source" unless self.sources.include?(source) | |
# Import | |
rss = self.send("build_#{source.downcase}_feed".to_sym, source) | |
if rss | |
count = 0 | |
rss.items.each do |item| | |
video = self.send("build_#{source.downcase}_item".to_sym, item) |
This file contains 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
before_filter :check_sources, :only => :new | |
def check_sources | |
if MySettings.video_feed_source.blank? || MySettings.send("#{MySettings.video_feed_source.downcase}_channel".to_sym).blank? | |
flash[:notice] = "Fill in your settings before importing." | |
redirect_to :back rescue forge_video_feeds_path | |
end | |
end |
This file contains 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
# spec/support/integration_login.rb | |
module IntegrationLogin | |
def login_user | |
@user = Factory.create(:user) | |
visit "/users/sign_in" | |
fill_in "Email", :with => @user.email | |
fill_in "Password", :with => @user.password | |
click_button 'Sign in' | |
end | |
end |
This file contains 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
FactoryGirl.define do | |
factory :consumable, :class => METS::Consumable do | |
sequence(:price) { |n| 50.0 + n * 5 } | |
title { Faker::Company.catch_phrase } | |
unit { "Each" } | |
end | |
factory :consumed_item, :class => METS::ConsumedItem do | |
consumable | |
end |
This file contains 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
app | |
- assets | |
- images | |
- stylesheets | |
- javascripts | |
- themes | |
- theme1 | |
- images | |
- stylesheets | |
- theme2 |
This file contains 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 path_is_not_route | |
routes = Forge::Settings[:languages] ? (Forge::Settings[:languages].values << "en").map { |lang| "/#{lang}#{path} } : [path] | |
routes.each do |route| | |
match = Rails.application.routes.recognize_path(route, :method => :get) rescue nil | |
errors.add(:base, "There's already something happening at #{MySettings.site_url}#{route}. Try giving the page a different name.") if match && !match[:slugs] | |
end | |
end |
This file contains 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 JobsController | |
respond_to :html, :json | |
load_and_authorize_resources | |
# You actually have to set the flash yourself on create if you're using load_and_authorize_resources | |
def create | |
@job.approved = current_user.is_admin? ? true : false | |
if @job.save | |
flash[:notice] = "You saved a job!!" | |
end |