init_model_test.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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_component_mapper');
  22. module.exports = {
  23. setupStackServiceComponent: function() {
  24. /**
  25. * initialization of App.StackServiceComponent model
  26. * @type {*}
  27. */
  28. var data = {items: Em.A([])};
  29. require('test/service_components').items.forEach(function(i) {
  30. i.serviceComponents.forEach(function(sc) {
  31. data.items.pushObject(sc.StackServiceComponents);
  32. });
  33. });
  34. App.stackServiceComponentMapper.map(data);
  35. },
  36. cleanStackServiceComponent: function(){
  37. App.StackServiceComponent.find().set('content',[]);
  38. },
  39. setupStackVersion: function(context, version) {
  40. context.prevStackVersion = App.get('currentStackVersion');
  41. App.set('currentStackVersion', version);
  42. },
  43. restoreStackVersion: function(context) {
  44. App.set('currentStackVersion', context.prevStackVersion);
  45. },
  46. configs: require('test/mock_data_setup/configs_mock_data'),
  47. /**
  48. * Delete record from DS.Store and set its stateManager to proper state
  49. * @param {DS.Model} record
  50. * @method deleteRecord
  51. */
  52. deleteRecord: function (record) {
  53. record.deleteRecord();
  54. record.get('stateManager').transitionTo('loading');
  55. }
  56. };