Commit b27f1d9a authored by Mike Greiling's avatar Mike Greiling

Merge branch '254826-fix-csrf-failure-when-updating-theme' into 'master'

Fix CSRF exception when updating theme

See merge request gitlab-org/gitlab!43073
parents 70a2fd8b 5ee62580
import $ from 'jquery'; import $ from 'jquery';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { Rails } from '~/lib/utils/rails_ujs';
import { deprecatedCreateFlash as flash } from '../flash'; import { deprecatedCreateFlash as flash } from '../flash';
import { parseBoolean } from '~/lib/utils/common_utils'; import { parseBoolean } from '~/lib/utils/common_utils';
import TimezoneDropdown, { import TimezoneDropdown, {
...@@ -48,9 +49,13 @@ export default class Profile { ...@@ -48,9 +49,13 @@ export default class Profile {
} }
submitForm() { submitForm() {
return $(this) const $form = $(this).parents('form');
.parents('form')
.submit(); if ($form.data('remote')) {
Rails.fire($form[0], 'submit');
} else {
$form.submit();
}
} }
onSubmitForm(e) { onSubmitForm(e) {
......
...@@ -123,6 +123,10 @@ RSpec.configure do |config| ...@@ -123,6 +123,10 @@ RSpec.configure do |config|
port: session.server.port, port: session.server.port,
protocol: 'http') protocol: 'http')
# CSRF protection is disabled by default. We only enable this for JS specs because some forms
# require Javascript to set the CSRF token.
allow_any_instance_of(ActionController::Base).to receive(:protect_against_forgery?).and_return(true)
# reset window size between tests # reset window size between tests
unless session.current_window.size == CAPYBARA_WINDOW_SIZE unless session.current_window.size == CAPYBARA_WINDOW_SIZE
begin begin
......
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