Commit 52b9cafbf2f8cc3d7be6842db1618916cacc23cd
1 parent
17cd0742
Exists in
master
and in
1 other branch
Update specs now that authentication is required
Showing
8 changed files
with
66 additions
and
2 deletions
Show diff stats
app/controllers/deploys_controller.rb
app/controllers/notices_controller.rb
spec/controllers/apps_controller_spec.rb
spec/controllers/errs_controller_spec.rb
| ... | ... | @@ -2,9 +2,18 @@ require 'spec_helper' |
| 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/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["#{File.dirname(__FILE__)}/support/**/*.rb"].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 | ... | ... |
| ... | ... | @@ -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 | ... | ... |