diff options
author | Mike Greiling <mike@pixelcog.com> | 2017-01-05 23:10:43 +0300 |
---|---|---|
committer | Mike Greiling <mike@pixelcog.com> | 2017-01-05 23:10:43 +0300 |
commit | 10d483eaaaccc336399fa83a0ac5f7ecd9cea352 (patch) | |
tree | 14d9df1251e0fd0cccccfd20a92f06fabf0a28dd /spec/javascripts/fixtures | |
parent | 5997a86e680e22454522819e1b959d18cad48d1f (diff) | |
parent | df5223de61253ba1511ae3ecbb7c447819177ecb (diff) |
Merge branch 'fix-u2f-fixtures' into 26226-generate-all-haml-fixtures-within-teaspoon-fixtures-task
* fix-u2f-fixtures:
generate u2f frontend fixtures dynamically
force utf-8 encoding for prior to fixture parsing to prevent nokogiri issues
exclude script type=text/template from dom scrubbing
Diffstat (limited to 'spec/javascripts/fixtures')
-rw-r--r-- | spec/javascripts/fixtures/u2f.rb | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/spec/javascripts/fixtures/u2f.rb b/spec/javascripts/fixtures/u2f.rb index 076c38ec4b1..c9c0b891237 100644 --- a/spec/javascripts/fixtures/u2f.rb +++ b/spec/javascripts/fixtures/u2f.rb @@ -1,35 +1,43 @@ require 'spec_helper' -describe SessionsController, '(JavaScript fixtures)', type: :controller do +context 'U2F' do include JavaScriptFixturesHelpers + let(:user) { create(:user, :two_factor_via_u2f) } + before(:all) do clean_frontend_fixtures('u2f/') end - it 'u2f/authenticate.html.raw' do |example| - fixture = render_template('u2f/_authenticate.html.haml', locals: { - new_user_session_path: "/users/sign_in", - params: {}, - resource_name: "user" - }) - store_frontend_fixture(fixture, example.description) - end + describe SessionsController, '(JavaScript fixtures)', type: :controller do + render_views + + before do + @request.env['devise.mapping'] = Devise.mappings[:user] + end - it 'u2f/register.html.raw' do |example| - user = build(:user, :two_factor_via_otp) + it 'u2f/authenticate.html.raw' do |example| + allow(controller).to receive(:find_user).and_return(user) - fixture = render_template('u2f/_register.html.haml', locals: { - create_u2f_profile_two_factor_auth_path: '/profile/two_factor_auth/create_u2f', - current_user: user - }) - store_frontend_fixture(fixture, example.description) + post :create, user: { login: user.username, password: user.password } + + expect(response).to be_success + store_frontend_fixture(response, example.description) + end end - private + describe Profiles::TwoFactorAuthsController, '(JavaScript fixtures)', type: :controller do + render_views + + before do + sign_in(user) + end + + it 'u2f/register.html.raw' do |example| + get :show - def render_template(template, **args) - controller = ApplicationController.new - controller.render_to_string(template: template, layout: false, **args) + expect(response).to be_success + store_frontend_fixture(response, example.description) + end end end |