Commit 81dfb1aa authored by Alfredo Sumaran's avatar Alfredo Sumaran

Merge branch 'fix-u2f-fixtures' into 'master'

Replace static JavaScript fixtures for u2f

See merge request !8426
parents 76bb8ed4 df5223de
require 'spec_helper'
context 'U2F' do
include JavaScriptFixturesHelpers
let(:user) { create(:user, :two_factor_via_u2f) }
before(:all) do
clean_frontend_fixtures('u2f/')
end
describe SessionsController, '(JavaScript fixtures)', type: :controller do
render_views
before do
@request.env['devise.mapping'] = Devise.mappings[:user]
end
it 'u2f/authenticate.html.raw' do |example|
allow(controller).to receive(:find_user).and_return(user)
post :create, user: { login: user.username, password: user.password }
expect(response).to be_success
store_frontend_fixture(response, example.description)
end
end
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
expect(response).to be_success
store_frontend_fixture(response, example.description)
end
end
end
= render partial: "u2f/authenticate", locals: { new_user_session_path: "/users/sign_in", params: {}, resource_name: "user" }
- user = FactoryGirl.build(:user, :two_factor_via_otp)
= render partial: "u2f/register", locals: { create_u2f_profile_two_factor_auth_path: '/profile/two_factor_auth/create_u2f', current_user: user }
......@@ -10,8 +10,10 @@
(function() {
describe('U2FAuthenticate', function() {
fixture.load('u2f/authenticate');
fixture.preload('u2f/authenticate.html.raw');
beforeEach(function() {
fixture.load('u2f/authenticate.html.raw');
this.u2fDevice = new MockU2FDevice;
this.container = $("#js-authenticate-u2f");
this.component = new window.gl.U2FAuthenticate(
......
......@@ -10,8 +10,10 @@
(function() {
describe('U2FRegister', function() {
fixture.load('u2f/register');
fixture.preload('u2f/register.html.raw');
beforeEach(function() {
fixture.load('u2f/register.html.raw');
this.u2fDevice = new MockU2FDevice;
this.container = $("#js-register-u2f");
this.component = new U2FRegister(this.container, $("#js-register-u2f-templates"), {}, "token");
......
......@@ -26,6 +26,7 @@ module JavaScriptFixturesHelpers
def store_frontend_fixture(response, fixture_file_name)
fixture_file_name = File.expand_path(fixture_file_name, FIXTURE_PATH)
fixture = response.body
fixture.force_encoding("utf-8")
response_mime_type = Mime::Type.lookup(response.content_type)
if response_mime_type.html?
......@@ -34,7 +35,7 @@ module JavaScriptFixturesHelpers
link_tags = doc.css('link')
link_tags.remove
scripts = doc.css('script')
scripts = doc.css("script:not([type='text/template'])")
scripts.remove
fixture = doc.to_html
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment