diff options
author | ThibG <thib@sitedethib.com> | 2019-04-10 22:33:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-10 22:33:41 +0200 |
commit | 31e4fcb006c6ef2d8e1a4c765e897afa1cba1b5c (patch) | |
tree | 15a022b1b44f72fee2d83cfe6f8355b7334f9d9b /spec | |
parent | cb410f80a40d03b509cec244b0cdd4ed3957c6a0 (diff) | |
parent | 2f422b708f75bea87a49eb879ec3e0c3f35c2f9b (diff) |
Merge pull request #985 from ThibG/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/settings/identity_proofs_controller_spec.rb | 17 | ||||
-rw-r--r-- | spec/fabricators/user_invite_request_fabricator.rb | 4 | ||||
-rw-r--r-- | spec/lib/proof_provider/keybase/verifier_spec.rb | 2 | ||||
-rw-r--r-- | spec/mailers/previews/admin_mailer_preview.rb | 8 | ||||
-rw-r--r-- | spec/models/user_invite_request_spec.rb | 4 | ||||
-rw-r--r-- | spec/validators/poll_validator_spec.rb | 28 |
6 files changed, 58 insertions, 5 deletions
diff --git a/spec/controllers/settings/identity_proofs_controller_spec.rb b/spec/controllers/settings/identity_proofs_controller_spec.rb index 5c05eb83c..2a0f91088 100644 --- a/spec/controllers/settings/identity_proofs_controller_spec.rb +++ b/spec/controllers/settings/identity_proofs_controller_spec.rb @@ -28,11 +28,11 @@ describe Settings::IdentityProofsController do describe 'new proof creation' do context 'GET #new' do - context 'with all of the correct params' do - before do - allow_any_instance_of(ProofProvider::Keybase::Badge).to receive(:avatar_url) { full_pack_url('media/images/void.png') } - end + before do + allow_any_instance_of(ProofProvider::Keybase::Badge).to receive(:avatar_url) { full_pack_url('media/images/void.png') } + end + context 'with all of the correct params' do it 'renders the template' do get :new, params: new_proof_params expect(response).to render_template(:new) @@ -54,6 +54,15 @@ describe Settings::IdentityProofsController do expect(flash[:alert]).to eq I18n.t('identity_proofs.errors.wrong_user', proving: 'someone_else', current: user.account.username) end end + + context 'with params to prove the same username cased differently' do + let(:capitalized_username) { new_proof_params.merge(username: user.account.username.upcase) } + + it 'renders the new template' do + get :new, params: capitalized_username + expect(response).to render_template(:new) + end + end end context 'POST #create' do diff --git a/spec/fabricators/user_invite_request_fabricator.rb b/spec/fabricators/user_invite_request_fabricator.rb new file mode 100644 index 000000000..5cc6ae56f --- /dev/null +++ b/spec/fabricators/user_invite_request_fabricator.rb @@ -0,0 +1,4 @@ +Fabricator(:user_invite_request) do + user + text { Faker::Lorem.sentence } +end diff --git a/spec/lib/proof_provider/keybase/verifier_spec.rb b/spec/lib/proof_provider/keybase/verifier_spec.rb index 4ce67da9c..0081a735d 100644 --- a/spec/lib/proof_provider/keybase/verifier_spec.rb +++ b/spec/lib/proof_provider/keybase/verifier_spec.rb @@ -10,7 +10,7 @@ describe ProofProvider::Keybase::Verifier do token: '11111111111111111111111111' ) - described_class.new('alice', 'cryptoalice', '11111111111111111111111111') + described_class.new('alice', 'cryptoalice', '11111111111111111111111111', my_domain) end let(:query_params) do diff --git a/spec/mailers/previews/admin_mailer_preview.rb b/spec/mailers/previews/admin_mailer_preview.rb new file mode 100644 index 000000000..561a56b78 --- /dev/null +++ b/spec/mailers/previews/admin_mailer_preview.rb @@ -0,0 +1,8 @@ +# Preview all emails at http://localhost:3000/rails/mailers/admin_mailer + +class AdminMailerPreview < ActionMailer::Preview + # Preview this email at http://localhost:3000/rails/mailers/admin_mailer/new_pending_account + def new_pending_account + AdminMailer.new_pending_account(Account.first, User.pending.first) + end +end diff --git a/spec/models/user_invite_request_spec.rb b/spec/models/user_invite_request_spec.rb new file mode 100644 index 000000000..1be38d8a4 --- /dev/null +++ b/spec/models/user_invite_request_spec.rb @@ -0,0 +1,4 @@ +require 'rails_helper' + +RSpec.describe UserInviteRequest, type: :model do +end diff --git a/spec/validators/poll_validator_spec.rb b/spec/validators/poll_validator_spec.rb new file mode 100644 index 000000000..941b83401 --- /dev/null +++ b/spec/validators/poll_validator_spec.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe PollValidator, type: :validator do + describe '#validate' do + before do + validator.validate(poll) + end + + let(:validator) { described_class.new } + let(:poll) { double(options: options, expires_at: expires_at, errors: errors) } + let(:errors) { double(add: nil) } + let(:options) { %w(foo bar) } + let(:expires_at) { 1.day.from_now } + + it 'have no errors' do + expect(errors).not_to have_received(:add) + end + + context 'expires just 5 min ago' do + let(:expires_at) { 5.minutes.from_now } + it 'not calls errors add' do + expect(errors).not_to have_received(:add) + end + end + end +end |