Nenhuma Descrição http://j1x-huginn.herokuapp.com

registrations_controller_spec.rb 1.0KB

123456789101112131415161718192021222324252627282930313233343536
  1. require 'rails_helper'
  2. module Users
  3. describe RegistrationsController do
  4. include Devise::TestHelpers
  5. describe "POST create" do
  6. before do
  7. @request.env["devise.mapping"] = Devise.mappings[:user]
  8. end
  9. context 'with valid params' do
  10. it "imports the default scenario for the new user" do
  11. mock(DefaultScenarioImporter).import(is_a(User))
  12. post :create, :user => {username: 'jdoe', email: 'jdoe@example.com',
  13. password: 's3cr3t55', password_confirmation: 's3cr3t55', invitation_code: 'try-huginn'}
  14. end
  15. end
  16. context 'with invalid params' do
  17. it "does not import the default scenario" do
  18. stub(DefaultScenarioImporter).import(is_a(User)) { fail "Should not attempt import" }
  19. setup_controller_for_warden
  20. post :create, :user => {}
  21. end
  22. it 'does not allow to set the admin flag' do
  23. expect { post :create, :user => {admin: 'true'} }.to raise_error(ActionController::UnpermittedParameters)
  24. end
  25. end
  26. end
  27. end
  28. end