diff options
author | Mike Greiling <mike@pixelcog.com> | 2017-01-03 14:48:37 -0600 |
---|---|---|
committer | Mike Greiling <mike@pixelcog.com> | 2017-01-05 14:03:32 -0600 |
commit | df5223de61253ba1511ae3ecbb7c447819177ecb (patch) | |
tree | 52ad0f88841331e60f047b9cc9f4554bab1b8e22 | |
parent | 8cee3b1d36afdb95934e8867fb60c23565c2d330 (diff) | |
download | gitlab-ce-df5223de61253ba1511ae3ecbb7c447819177ecb.tar.gz |
generate u2f frontend fixtures dynamically
-rw-r--r-- | spec/javascripts/fixtures/u2f.rb | 43 | ||||
-rw-r--r-- | spec/javascripts/fixtures/u2f/authenticate.html.haml | 1 | ||||
-rw-r--r-- | spec/javascripts/fixtures/u2f/register.html.haml | 2 | ||||
-rw-r--r-- | spec/javascripts/u2f/authenticate_spec.js | 4 | ||||
-rw-r--r-- | spec/javascripts/u2f/register_spec.js | 4 |
5 files changed, 49 insertions, 5 deletions
diff --git a/spec/javascripts/fixtures/u2f.rb b/spec/javascripts/fixtures/u2f.rb new file mode 100644 index 00000000000..c9c0b891237 --- /dev/null +++ b/spec/javascripts/fixtures/u2f.rb @@ -0,0 +1,43 @@ +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 diff --git a/spec/javascripts/fixtures/u2f/authenticate.html.haml b/spec/javascripts/fixtures/u2f/authenticate.html.haml deleted file mode 100644 index 779d6429a5f..00000000000 --- a/spec/javascripts/fixtures/u2f/authenticate.html.haml +++ /dev/null @@ -1 +0,0 @@ -= render partial: "u2f/authenticate", locals: { new_user_session_path: "/users/sign_in", params: {}, resource_name: "user" } diff --git a/spec/javascripts/fixtures/u2f/register.html.haml b/spec/javascripts/fixtures/u2f/register.html.haml deleted file mode 100644 index 5ed51be689c..00000000000 --- a/spec/javascripts/fixtures/u2f/register.html.haml +++ /dev/null @@ -1,2 +0,0 @@ -- 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 } diff --git a/spec/javascripts/u2f/authenticate_spec.js b/spec/javascripts/u2f/authenticate_spec.js index 064d18519ea..f6399b22865 100644 --- a/spec/javascripts/u2f/authenticate_spec.js +++ b/spec/javascripts/u2f/authenticate_spec.js @@ -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( diff --git a/spec/javascripts/u2f/register_spec.js b/spec/javascripts/u2f/register_spec.js index 189592ea87a..7eda2ac4c24 100644 --- a/spec/javascripts/u2f/register_spec.js +++ b/spec/javascripts/u2f/register_spec.js @@ -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"); |