Commit 52b9cafbf2f8cc3d7be6842db1618916cacc23cd

Authored by Jared Pace
1 parent 17cd0742
Exists in master and in 1 other branch production

Update specs now that authentication is required

app/controllers/deploys_controller.rb
1 1 class DeploysController < ApplicationController
2 2  
  3 + skip_before_filter :authenticate_user!, :only => :create
  4 +
3 5 def create
4 6 @app = App.find_by_api_key!(params[:api_key])
5 7 @deploy = @app.deploys.create!({
... ...
app/controllers/notices_controller.rb
1 1 class NoticesController < ApplicationController
2 2 respond_to :xml
3 3  
  4 + skip_before_filter :authenticate_user!, :only => :create
  5 +
4 6 def create
5 7 @notice = Notice.from_xml(request.raw_post)
6 8 respond_with @notice
... ...
spec/controllers/apps_controller_spec.rb
... ... @@ -2,6 +2,12 @@ require &#39;spec_helper&#39;
2 2  
3 3 describe AppsController do
4 4  
  5 + it_requires_authentication
  6 +
  7 + before do
  8 + sign_in Factory(:user)
  9 + end
  10 +
5 11 describe "GET /apps" do
6 12 it 'finds all apps' do
7 13 3.times { Factory(:app) }
... ...
spec/controllers/errs_controller_spec.rb
... ... @@ -2,9 +2,18 @@ require &#39;spec_helper&#39;
2 2  
3 3 describe ErrsController do
4 4  
  5 + it_requires_authentication :for => {
  6 + :index => :get, :all => :get, :show => :get, :resolve => :put
  7 + },
  8 + :params => {:app_id => 'dummyid', :id => 'dummyid'}
  9 +
5 10 let(:app) { Factory(:app) }
6 11 let(:err) { Factory(:err, :app => app) }
7 12  
  13 + before do
  14 + sign_in Factory(:user)
  15 + end
  16 +
8 17 describe "GET /errs" do
9 18 it "gets a paginated list of unresolved errs" do
10 19 errs = WillPaginate::Collection.new(1,30)
... ...
spec/factories/user_factories.rb 0 → 100644
... ... @@ -0,0 +1,8 @@
  1 +Factory.sequence(:user_email) {|n| "user.#{n}@example.com"}
  2 +
  3 +Factory.define :user do |u|
  4 + u.name 'Clyde Frog'
  5 + u.email { Factory.next :user_email }
  6 + u.password 'password'
  7 + u.password_confirmation 'password'
  8 +end
0 9 \ No newline at end of file
... ...
spec/models/user_spec.rb
1 1 require 'spec_helper'
2 2  
3 3 describe User do
4   - pending "add some examples to (or delete) #{__FILE__}"
  4 +
  5 + context 'validations' do
  6 + it 'require that a name is present' do
  7 + user = Factory.build(:user, :name => nil)
  8 + user.should_not be_valid
  9 + user.errors[:name].should include("can't be blank")
  10 + end
  11 + end
  12 +
5 13 end
... ...
spec/spec_helper.rb
... ... @@ -11,10 +11,11 @@ Dir[&quot;#{File.dirname(__FILE__)}/support/**/*.rb&quot;].each {|f| require f}
11 11  
12 12 RSpec.configure do |config|
13 13 config.mock_with :rspec
  14 + config.include Devise::TestHelpers, :type => :controller
14 15  
15 16 config.before(:each) do
16 17 DatabaseCleaner.orm = "mongoid"
17 18 DatabaseCleaner.strategy = :truncation
18 19 DatabaseCleaner.clean
19 20 end
20 21 -end
  22 +end
21 23 \ No newline at end of file
... ...
spec/support/macros.rb 0 → 100644
... ... @@ -0,0 +1,28 @@
  1 +def it_requires_authentication(options = {})
  2 + default_options = {
  3 + :for => {
  4 + :index => :get,
  5 + :show => :get,
  6 + :new => :get,
  7 + :create => :post,
  8 + :edit => :get,
  9 + :update => :put,
  10 + :destroy => :delete
  11 + },
  12 + :params => {:id => 'dummyid'}
  13 + }
  14 + options.reverse_merge!(default_options)
  15 +
  16 + context 'when logged out' do
  17 + before do
  18 + sign_out :user
  19 + end
  20 +
  21 + options[:for].each do |action, method|
  22 + it "#{method.to_s.upcase} #{action} redirects to the sign in page" do
  23 + send(method, action, options[:params])
  24 + response.should redirect_to(new_user_session_path)
  25 + end
  26 + end
  27 + end
  28 +end
0 29 \ No newline at end of file
... ...