.circleci
.github
app
bin
config
db
dist
lib
log
nanobox
public
spec
controllers
activitypub
admin
account_moderation_notes_controller_spec.rb
accounts_controller_spec.rb
action_logs_controller_spec.rb
base_controller_spec.rb
change_email_controller_spec.rb
confirmations_controller_spec.rb
custom_emojis_controller_spec.rb
dashboard_controller_spec.rb
domain_blocks_controller_spec.rb
email_domain_blocks_controller_spec.rb
instances_controller_spec.rb
invites_controller_spec.rb
report_notes_controller_spec.rb
reported_statuses_controller_spec.rb
reports_controller_spec.rb
resets_controller_spec.rb
roles_controller_spec.rb
settings_controller_spec.rb
statuses_controller_spec.rb
subscriptions_controller_spec.rb
tags_controller_spec.rb
two_factor_authentications_controller_spec.rb
api
auth
concerns
oauth
settings
well_known
about_controller_spec.rb
account_follow_controller_spec.rb
account_unfollow_controller_spec.rb
accounts_controller_spec.rb
application_controller_spec.rb
authorize_interactions_controller_spec.rb
emojis_controller_spec.rb
follower_accounts_controller_spec.rb
following_accounts_controller_spec.rb
home_controller_spec.rb
intents_controller_spec.rb
invites_controller_spec.rb
manifests_controller_spec.rb
media_controller_spec.rb
remote_follow_controller_spec.rb
remote_interaction_controller_spec.rb
remote_unfollows_controller_spec.rb
shares_controller_spec.rb
statuses_controller_spec.rb
stream_entries_controller_spec.rb
tags_controller_spec.rb
fabricators
features
fixtures
helpers
lib
mailers
models
policies
presenters
requests
routing
services
support
validators
views
workers
rails_helper.rb
spec_helper.rb
streaming
vendor
.buildpacks
.codeclimate.yml
.dockerignore
.editorconfig
.env.nanobox
.env.production.sample
.env.test
.env.vagrant
.eslintignore
.eslintrc.js
.foreman
.gitattributes
.gitignore
.haml-lint.yml
.nanoignore
.nvmrc
.profile
.rspec
.rubocop.yml
.ruby-version
.scss-lint.yml
.slugignore
.yarnclean
AUTHORS.md
Aptfile
CHANGELOG.md
CODE_OF_CONDUCT.md
CONTRIBUTING.md
Capfile
Dockerfile
Gemfile
Gemfile.lock
LICENSE
Procfile
Procfile.dev
README.md
Rakefile
Vagrantfile
app.json
babel.config.js
boxfile.yml
config.ru
docker-compose.yml
jest.config.js
package.json
postcss.config.js
priv-config
scalingo.json
yarn.lock
* Add confirmations_controller#resend * Add tests for confirmations_controller#resend * Add translations
65 lines
2.0 KiB
Ruby
65 lines
2.0 KiB
Ruby
require 'rails_helper'
|
|
|
|
RSpec.describe Admin::ConfirmationsController, type: :controller do
|
|
render_views
|
|
|
|
before do
|
|
sign_in Fabricate(:user, admin: true), scope: :user
|
|
end
|
|
|
|
describe 'POST #create' do
|
|
it 'confirms the user' do
|
|
account = Fabricate(:account)
|
|
user = Fabricate(:user, confirmed_at: false, account: account)
|
|
post :create, params: { account_id: account.id }
|
|
|
|
expect(response).to redirect_to(admin_accounts_path)
|
|
expect(user.reload).to be_confirmed
|
|
end
|
|
|
|
it 'raises an error when there is no account' do
|
|
post :create, params: { account_id: 'fake' }
|
|
|
|
expect(response).to have_http_status(404)
|
|
end
|
|
|
|
it 'raises an error when there is no user' do
|
|
account = Fabricate(:account, user: nil)
|
|
post :create, params: { account_id: account.id }
|
|
|
|
expect(response).to have_http_status(404)
|
|
end
|
|
end
|
|
|
|
describe 'POST #resernd' do
|
|
subject { post :resend, params: { account_id: account.id } }
|
|
|
|
let(:account) { Fabricate(:account) }
|
|
let!(:user) { Fabricate(:user, confirmed_at: confirmed_at, account: account) }
|
|
|
|
before do
|
|
allow(UserMailer).to receive(:confirmation_instructions) { double(:email, deliver_later: nil) }
|
|
end
|
|
|
|
context 'when email is not confirmed' do
|
|
let(:confirmed_at) { nil }
|
|
|
|
it 'resends confirmation mail' do
|
|
expect(subject).to redirect_to admin_accounts_path
|
|
expect(flash[:notice]).to eq I18n.t('admin.accounts.resend_confirmation.success')
|
|
expect(UserMailer).to have_received(:confirmation_instructions).once
|
|
end
|
|
end
|
|
|
|
context 'when email is confirmed' do
|
|
let(:confirmed_at) { Time.zone.now }
|
|
|
|
it 'does not resend confirmation mail' do
|
|
expect(subject).to redirect_to admin_accounts_path
|
|
expect(flash[:error]).to eq I18n.t('admin.accounts.resend_confirmation.already_confirmed')
|
|
expect(UserMailer).not_to have_received(:confirmation_instructions)
|
|
end
|
|
end
|
|
end
|
|
end
|