闭社主体 forked from https://github.com/tootsuite/mastodon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.1 KiB

  1. require 'rails_helper'
  2. RSpec.describe Auth::RegistrationsController, type: :controller do
  3. render_views
  4. describe 'GET #new' do
  5. before do
  6. Setting.open_registrations = true
  7. request.env["devise.mapping"] = Devise.mappings[:user]
  8. end
  9. it 'returns http success' do
  10. get :new
  11. expect(response).to have_http_status(:success)
  12. end
  13. end
  14. describe 'POST #create' do
  15. let(:accept_language) { Rails.application.config.i18n.available_locales.sample.to_s }
  16. before do
  17. Setting.open_registrations = true
  18. request.env["devise.mapping"] = Devise.mappings[:user]
  19. request.headers["Accept-Language"] = accept_language
  20. post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678' } }
  21. end
  22. it 'redirects to login page' do
  23. expect(response).to redirect_to new_user_session_path
  24. end
  25. it 'creates user' do
  26. user = User.find_by(email: 'test@example.com')
  27. expect(user).to_not be_nil
  28. expect(user.locale).to eq(accept_language)
  29. end
  30. end
  31. end