mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/MultimediaViewer
synced 2024-11-27 17:40:06 +00:00
Use saveOption from 'mediawiki.api.options'
Change-Id: I33a60cbaf10f5d53a4e49f335ce8f16d108f9dfb
This commit is contained in:
parent
6f1bd995da
commit
61581fa905
|
@ -344,6 +344,8 @@
|
|||
"mmv/mmv.bootstrap.less"
|
||||
],
|
||||
"dependencies": [
|
||||
"mediawiki.api",
|
||||
"mediawiki.api.options",
|
||||
"mediawiki.ui.button",
|
||||
"mediawiki.ui.icon",
|
||||
"mediawiki.Title",
|
||||
|
|
|
@ -123,11 +123,7 @@
|
|||
* @return {jQuery.Promise} a deferred which resolves/rejects on success/failure respectively
|
||||
*/
|
||||
CP.setUserPreference = function ( key, value ) {
|
||||
return this.api.postWithToken( 'options', {
|
||||
action: 'options',
|
||||
optionname: key,
|
||||
optionvalue: value
|
||||
} );
|
||||
return this.api.saveOption( key, value );
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -137,14 +137,14 @@
|
|||
} ),
|
||||
mwUser = { isAnon: this.sandbox.stub() },
|
||||
mwConfig = new mw.Map(),
|
||||
api = { postWithToken: this.sandbox.stub().returns( $.Deferred().resolve() ) },
|
||||
api = { saveOption: this.sandbox.stub().returns( $.Deferred().resolve() ) },
|
||||
config = new mw.mmv.Config( {}, mwConfig, mwUser, api, localStorage );
|
||||
mwConfig.set( 'wgMediaViewerEnabledByDefault', false );
|
||||
|
||||
mwUser.isAnon.returns( false );
|
||||
api.postWithToken.returns( $.Deferred().resolve() );
|
||||
api.saveOption.returns( $.Deferred().resolve() );
|
||||
config.setMediaViewerEnabledOnClick( false );
|
||||
assert.ok( api.postWithToken.called, 'For logged-in users, pref change is via API' );
|
||||
assert.ok( api.saveOption.called, 'For logged-in users, pref change is via API' );
|
||||
|
||||
mwUser.isAnon.returns( true );
|
||||
config.setMediaViewerEnabledOnClick( false );
|
||||
|
@ -160,7 +160,7 @@
|
|||
mwConfig = new mw.Map(),
|
||||
fakeLocalStorage = mw.mmv.testHelpers.getFakeLocalStorage(),
|
||||
mwUser = { isAnon: this.sandbox.stub() },
|
||||
api = { postWithToken: this.sandbox.stub().returns( $.Deferred().resolve() ) };
|
||||
api = { saveOption: this.sandbox.stub().returns( $.Deferred().resolve() ) };
|
||||
|
||||
mwConfig.set( {
|
||||
wgMediaViewer: true,
|
||||
|
|
Loading…
Reference in a new issue