init_model_test.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var App = require('app');
  19. require('models/stack_service_component');
  20. require('mappers/server_data_mapper');
  21. require('mappers/stack_service_mapper');
  22. module.exports = {
  23. setupStackServiceComponent: function() {
  24. /**
  25. * initialization of App.StackServiceComponent and App.StackService models
  26. * @type {*}
  27. */
  28. App.stackServiceMapper.map(require('test/service_components'));
  29. },
  30. cleanStackServiceComponent: function() {
  31. App.StackServiceComponent.find().set('content',[]);
  32. App.StackService.find().set('content',[]);
  33. },
  34. setupStackVersion: function(context, version) {
  35. context.prevStackVersion = App.get('currentStackVersion');
  36. App.set('currentStackVersion', version);
  37. },
  38. restoreStackVersion: function(context) {
  39. App.set('currentStackVersion', context.prevStackVersion);
  40. },
  41. configs: require('test/mock_data_setup/configs_mock_data'),
  42. /**
  43. * Delete record from DS.Store and set its stateManager to proper state
  44. * @param {DS.Model} record
  45. * @method deleteRecord
  46. */
  47. deleteRecord: function (record) {
  48. record.deleteRecord();
  49. record.get('stateManager').transitionTo('loading');
  50. }
  51. };