content_type
stringclasses 8
values | main_lang
stringclasses 7
values | message
stringlengths 1
50
| sha
stringlengths 40
40
| patch
stringlengths 52
962k
| file_count
int64 1
300
|
---|---|---|---|---|---|
Python | Python | make suggested fixes | f61357cdc5605e7d488d87caa38e9407de444cd8 | <ide><path>research/object_detection/meta_architectures/context_rcnn_lib_tf2_test.py
<ide> def test_attention_block(self, bottleneck_dimension, output_dimension,
<ide> input_features = tf.ones([2, 8, 3, 3, 3], tf.float32)
<ide> context_features = tf.ones([2, 20, 10], tf.float32)
<ide> is_training = False
<del> attention_block = context_rcnn_lib.AttentionBlock(bottleneck_dimension, attention_temperature, False, output_dimension)
<add> attention_block = context_rcnn_lib.AttentionBlock(bottleneck_dimension,
<add> attention_temperature,
<add> freeze_batchnorm=False,
<add> output_dimension=output_dimension,
<add> is_training=False)
<ide> valid_context_size = tf.random_uniform((2,),
<ide> minval=0,
<ide> maxval=10,
<ide> dtype=tf.int32)
<del> output_features = attention_block([input_features, context_features], is_training, valid_context_size)
<add> output_features = attention_block(input_features, context_features, valid_context_size)
<ide>
<ide> # Makes sure the shape is correct.
<ide> self.assertAllEqual(output_features.shape, [2, 8, 1, 1, output_dimension])
<ide><path>research/object_detection/meta_architectures/context_rcnn_lib_v2.py
<ide> def call(self, input_features, is_training=False):
<ide> class AttentionBlock(tf.keras.layers.Layer):
<ide> """Custom layer to perform all attention."""
<ide> def __init__(self, bottleneck_dimension, attention_temperature,
<del> freeze_batchnorm, output_dimension=None, **kwargs):
<add> freeze_batchnorm, output_dimension=None, is_training=False, **kwargs):
<ide> self._key_proj = ContextProjection(bottleneck_dimension, freeze_batchnorm)
<ide> self._val_proj = ContextProjection(bottleneck_dimension, freeze_batchnorm)
<ide> self._query_proj = ContextProjection(bottleneck_dimension, freeze_batchnorm)
<ide><path>research/object_detection/meta_architectures/context_rcnn_meta_arch.py
<ide> def get_side_inputs(features):
<ide> "Please make sure context_features and valid_context_size are in the "
<ide> "features")
<ide>
<del> print("In get side inputs, returning side features.")
<ide> return {
<ide> fields.InputDataFields.context_features:
<ide> features[fields.InputDataFields.context_features],
<ide> def _compute_second_stage_input_feature_maps(self, features_to_crop,
<ide> [self._initial_crop_size, self._initial_crop_size])
<ide>
<ide> attention_features = self._context_feature_extract_fn(
<del> box_features=box_features,
<del> context_features=context_features,
<add> box_features, context_features,
<ide> valid_context_size=valid_context_size)
<ide>
<ide> # Adds box features with attention features.
<ide><path>research/object_detection/meta_architectures/context_rcnn_meta_arch_test.py
<ide> def graph_fn():
<ide> }
<ide>
<ide> side_inputs = model.get_side_inputs(features)
<del> print('preprocessed', preprocessed_inputs.shape)
<del> print('context', context_features.shape)
<ide> prediction_dict = model.predict(preprocessed_inputs, true_image_shapes,
<ide> **side_inputs)
<ide> return (prediction_dict['rpn_box_predictor_features'], | 4 |
PHP | PHP | skip consoleinput tests on windows/appveyor | 03f60e83fa956abe2acce90b93e8dffa42894f39 | <ide><path>tests/TestCase/Console/ConsoleInputTest.php
<ide> public function setUp()
<ide> */
<ide> public function testDataAvailable()
<ide> {
<add> $this->skipIf(
<add> DS === '\\',
<add> 'Skip ConsoleInput tests on Windows as they fail on AppVeyor.'
<add> );
<add>
<ide> $this->assertFalse($this->in->dataAvailable());
<ide> }
<ide> } | 1 |
Ruby | Ruby | avoid unnecessary sql query when calling cache_key | 76bb9712f2536ab18b413c45990a6b3fc042c18c | <ide><path>activerecord/lib/active_record/relation.rb
<ide> def compute_cache_key(timestamp_column = :updated_at) # :nodoc:
<ide> query_signature = ActiveSupport::Digest.hexdigest(to_sql)
<ide> key = "#{klass.model_name.cache_key}/query-#{query_signature}"
<ide>
<del> if cache_version(timestamp_column)
<add> if collection_cache_versioning
<ide> key
<ide> else
<ide> "#{key}-#{compute_cache_version(timestamp_column)}"
<ide><path>activerecord/test/cases/collection_cache_key_test.rb
<ide> class CollectionCacheKeyTest < ActiveRecord::TestCase
<ide> assert_no_queries { developers.cache_key }
<ide> end
<ide>
<add> test "it doesn't trigger any query if collection_cache_versioning is enabled" do
<add> with_collection_cache_versioning do
<add> developers = Developer.where(name: "David")
<add> assert_no_queries { developers.cache_key }
<add> end
<add> end
<add>
<ide> test "relation cache_key changes when the sql query changes" do
<ide> developers = Developer.where(name: "David")
<ide> other_relation = Developer.where(name: "David").where("1 = 1") | 2 |
PHP | PHP | fix boolean check | 57787cbc3aa853701b42bf9a5d9017b4e13ac823 | <ide><path>src/Illuminate/Database/Connectors/SqlServerConnector.php
<ide> protected function getSqlSrvDsn(array $config)
<ide> $arguments['ApplicationIntent'] = 'ReadOnly';
<ide> }
<ide>
<del> if (isset($config['pooling']) && $config['pooling'] == false) {
<add> if (isset($config['pooling']) && $config['pooling'] === false) {
<ide> $arguments['ConnectionPooling'] = '0';
<ide> }
<ide> | 1 |
Text | Text | fix typo in changelog.md | d9325e102cd449645a208fa83cfd2b8cb29ab0d2 | <ide><path>CHANGELOG.md
<ide> Upgrading from Docker 1.13.1 to 17.03.0 is expected to be simple and low-risk.
<ide>
<ide> * Fix a deadlock in docker logs [#30223](https://github.com/docker/docker/pull/30223)
<ide> * Fix cpu spin waiting for log write events [#31070](https://github.com/docker/docker/pull/31070)
<del>* Fix a possible crash when using journald [#31231](https://github.com/docker/docker/pull/31231) [#31263](https://github.com/docker/docker/pull/31231)
<add>* Fix a possible crash when using journald [#31231](https://github.com/docker/docker/pull/31231) [#31263](https://github.com/docker/docker/pull/31263)
<ide> * Fix a panic on close of nil channel [#31274](https://github.com/docker/docker/pull/31274)
<ide> * Fix duplicate mount point for `--volumes-from` in `docker run` [#29563](https://github.com/docker/docker/pull/29563)
<ide> * Fix `--cache-from` does not cache last step [#31189](https://github.com/docker/docker/pull/31189) | 1 |
Ruby | Ruby | use full path to environment | 39de112e7b902176434a1d0ebc1d6741247e50de | <ide><path>railties/lib/commands/about.rb
<del>require 'environment'
<add>require "#{RAILS_ROOT}/config/environment"
<ide> require 'rails/info'
<ide> puts Rails::Info | 1 |
PHP | PHP | fix styleci warnings | 67cb3a4695c71112810c0e010e7f35e3b439ac2c | <ide><path>src/Illuminate/Auth/Access/Gate.php
<ide> public function any($abilities, $arguments = [])
<ide> public function none($abilities, $arguments = [])
<ide> {
<ide> return ! $this->any($abilities, $arguments);
<del> }
<add> }
<ide>
<ide> /**
<ide> * Determine if the given ability should be granted for the current user. | 1 |
PHP | PHP | remove check for defunct view options | c35ffc9ff267ba8c4e0cee010f626e0c9beb180f | <ide><path>src/View/View.php
<ide> public function __construct(
<ide> ?EventManager $eventManager = null,
<ide> array $viewOptions = []
<ide> ) {
<del> if (isset($viewOptions['view'])) {
<del> $this->setTemplate($viewOptions['view']);
<del> }
<del> if (isset($viewOptions['viewPath'])) {
<del> $this->setTemplatePath($viewOptions['viewPath']);
<del> }
<ide> foreach ($this->_passedVars as $var) {
<ide> if (isset($viewOptions[$var])) {
<ide> $this->{$var} = $viewOptions[$var];
<ide><path>tests/TestCase/View/ViewTest.php
<ide> public function testGetTemplate()
<ide> $viewOptions = [
<ide> 'plugin' => null,
<ide> 'name' => 'Pages',
<del> 'viewPath' => 'Pages',
<add> 'templatePath' => 'Pages',
<ide> ];
<ide>
<ide> $ThemeView = new TestView(null, null, null, $viewOptions);
<ide> public function testPluginGetTemplate()
<ide> {
<ide> $viewOptions = ['plugin' => 'TestPlugin',
<ide> 'name' => 'TestPlugin',
<del> 'viewPath' => 'Tests',
<del> 'view' => 'index',
<add> 'templatePath' => 'Tests',
<add> 'template' => 'index',
<ide> ];
<ide>
<ide> $View = new TestView(null, null, null, $viewOptions);
<ide> public function testPluginThemedGetTemplate()
<ide> {
<ide> $viewOptions = ['plugin' => 'TestPlugin',
<ide> 'name' => 'TestPlugin',
<del> 'viewPath' => 'Tests',
<del> 'view' => 'index',
<add> 'templatePath' => 'Tests',
<add> 'template' => 'index',
<ide> 'theme' => 'TestTheme',
<ide> ];
<ide>
<ide> public function testCamelCasePluginGetTemplate()
<ide> {
<ide> $viewOptions = ['plugin' => 'TestPlugin',
<ide> 'name' => 'TestPlugin',
<del> 'viewPath' => 'Tests',
<del> 'view' => 'index',
<add> 'templatePath' => 'Tests',
<add> 'template' => 'index',
<ide> ];
<ide>
<ide> $View = new TestView(null, null, null, $viewOptions);
<ide> public function testGetViewFileNames()
<ide> $viewOptions = [
<ide> 'plugin' => null,
<ide> 'name' => 'Pages',
<del> 'viewPath' => 'Pages',
<add> 'templatePath' => 'Pages',
<ide> ];
<ide> $request = $this->getMockBuilder('Cake\Http\ServerRequest')->getMock();
<ide> $response = $this->getMockBuilder('Cake\Http\Response')->getMock();
<ide> public function testGetViewFileNameDirectoryTraversal()
<ide> $viewOptions = [
<ide> 'plugin' => null,
<ide> 'name' => 'Pages',
<del> 'viewPath' => 'Pages',
<add> 'templatePath' => 'Pages',
<ide> ];
<ide> $request = $this->getMockBuilder('Cake\Http\ServerRequest')->getMock();
<ide> $response = $this->getMockBuilder('Cake\Http\Response')->getMock();
<ide> public function testGetViewFileNameSubDir()
<ide> $viewOptions = [
<ide> 'plugin' => null,
<ide> 'name' => 'Posts',
<del> 'viewPath' => 'Posts/json',
<add> 'templatePath' => 'Posts/json',
<ide> 'layoutPath' => 'json',
<ide> ];
<ide> $view = new TestView(null, null, null, $viewOptions);
<ide> public function testGetViewFileNameSubDirLength()
<ide> $viewOptions = [
<ide> 'plugin' => null,
<ide> 'name' => 'Jobs',
<del> 'viewPath' => 'Jobs',
<add> 'templatePath' => 'Jobs',
<ide> 'layoutPath' => 'json',
<ide> ];
<ide> $view = new TestView(null, null, null, $viewOptions); | 2 |
Ruby | Ruby | replace backticks with rdoc markup [ci-skip] | 07bee949c48db267fed9cee25c56951473c391e1 | <ide><path>actionpack/lib/action_controller/metal/redirecting.rb
<ide> class UnsafeRedirectError < StandardError; end
<ide> #
<ide> # Raises UnsafeRedirectError in the case of an unsafe redirect.
<ide> #
<del> # To allow any external redirects pass `allow_other_host: true`, though using a user-provided param in that case is unsafe.
<add> # To allow any external redirects pass <tt>allow_other_host: true</tt>, though using a user-provided param in that case is unsafe.
<ide> #
<ide> # redirect_to "https://rubyonrails.org", allow_other_host: true
<ide> #
<ide><path>actionpack/lib/action_controller/metal/strong_parameters.rb
<ide> class Parameters
<ide> # By default, never raise an UnpermittedParameters exception if these
<ide> # params are present. The default includes both 'controller' and 'action'
<ide> # because they are added by Rails and should be of no concern. One way
<del> # to change these is to specify `always_permitted_parameters` in your
<add> # to change these is to specify +always_permitted_parameters+ in your
<ide> # config. For instance:
<ide> #
<ide> # config.action_controller.always_permitted_parameters = %w( controller action format )
<ide><path>actionview/lib/action_view/helpers/form_options_helper.rb
<ide> def time_zone_options_for_select(selected = nil, priority_zones = nil, model = :
<ide> #
<ide> # Options:
<ide> # * <tt>:index_as_value</tt> - Defaults to false, set to true to use the indexes from
<del> # `I18n.translate("date.day_names")` as the values. By default, Sunday is always 0.
<add> # <tt>I18n.translate("date.day_names")</tt> as the values. By default, Sunday is always 0.
<ide> # * <tt>:day_format</tt> - The I18n key of the array to use for the weekday options.
<ide> # Defaults to :day_names, set to :abbr_day_names for abbreviations.
<ide> # * <tt>:beginning_of_week</tt> - Defaults to Date.beginning_of_week.
<ide><path>actionview/lib/action_view/helpers/tag_helper.rb
<ide> def method_missing(called, *args, **options, &block)
<ide> # Transforms a Hash into HTML attributes, ready to be interpolated into
<ide> # ERB. Includes or omits boolean attributes based on their truthiness.
<ide> # Transforms keys nested within
<del> # <tt>aria:</tt> or <tt>data:</tt> objects into `aria-` and `data-`
<add> # <tt>aria:</tt> or <tt>data:</tt> objects into <tt>aria-</tt> and <tt>data-</tt>
<ide> # prefixed attributes:
<ide> #
<ide> # <input <%= tag.attributes(type: :text, aria: { label: "Search" }) %>>
<ide><path>activerecord/lib/active_record/associations.rb
<ide> module ClassMethods
<ide> # [:disable_joins]
<ide> # Specifies whether joins should be skipped for an association. If set to true, two or more queries
<ide> # will be generated. Note that in some cases, if order or limit is applied, it will be done in-memory
<del> # due to database limitations. This option is only applicable on `has_many :through` associations as
<del> # `has_many` alone do not perform a join.
<add> # due to database limitations. This option is only applicable on <tt>has_many :through</tt> associations as
<add> # +has_many+ alone do not perform a join.
<ide> # [:source]
<ide> # Specifies the source association name used by #has_many <tt>:through</tt> queries.
<ide> # Only use it if the name cannot be inferred from the association.
<ide> def has_many(name, scope = nil, **options, &extension)
<ide> # [:disable_joins]
<ide> # Specifies whether joins should be skipped for an association. If set to true, two or more queries
<ide> # will be generated. Note that in some cases, if order or limit is applied, it will be done in-memory
<del> # due to database limitations. This option is only applicable on `has_one :through` associations as
<del> # `has_one` alone does not perform a join.
<add> # due to database limitations. This option is only applicable on <tt>has_one :through</tt> associations as
<add> # +has_one+ alone does not perform a join.
<ide> # [:source]
<ide> # Specifies the source association name used by #has_one <tt>:through</tt> queries.
<ide> # Only use it if the name cannot be inferred from the association.
<ide><path>activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
<ide> def connection_class # :nodoc:
<ide> end
<ide>
<ide> # The role (e.g. +:writing+) for the current connection. In a
<del> # non-multi role application, `:writing` is returned.
<add> # non-multi role application, +:writing+ is returned.
<ide> def role
<ide> @pool.role
<ide> end
<ide>
<ide> # The shard (e.g. +:default+) for the current connection. In
<del> # a non-sharded application, `:default` is returned.
<add> # a non-sharded application, +:default+ is returned.
<ide> def shard
<ide> @pool.shard
<ide> end
<ide><path>activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
<ide> def new_client(conn_params)
<ide>
<ide> ##
<ide> # :singleton-method:
<del> # PostgreSQL supports multiple types for DateTimes. By default, if you use `datetime`
<add> # PostgreSQL supports multiple types for DateTimes. By default, if you use +datetime+
<ide> # in migrations, Rails will translate this to a PostgreSQL "timestamp without time zone".
<ide> # Change this in an initializer to use another NATIVE_DATABASE_TYPES. For example, to
<ide> # store DateTimes as "timestamp with time zone":
<ide><path>activerecord/lib/active_record/core.rb
<ide> def self.configurations
<ide> ##
<ide> # :singleton-method:
<ide> # Force enumeration of all columns in SELECT statements.
<del> # e.g. `SELECT first_name, last_name FROM ...` instead of `SELECT * FROM ...`
<add> # e.g. <tt>SELECT first_name, last_name FROM ...</tt> instead of <tt>SELECT * FROM ...</tt>
<ide> # This avoids +PreparedStatementCacheExpired+ errors when a column is added
<ide> # to the database while the app is running.
<ide> class_attribute :enumerate_columns_in_select_statements, instance_accessor: false, default: false
<ide><path>activerecord/lib/active_record/encryption/encryptable_record.rb
<ide> module EncryptableRecord
<ide> # * <tt>:key</tt> - A password to derive the key from. It's a shorthand for a +:key_provider+ that
<ide> # serves derivated keys. Both options can't be used at the same time.
<ide> # * <tt>:key_provider</tt> - Set a +:key_provider+ to provide encryption and decryption keys. If not
<del> # provided, it will default to the key provider set with `config.key_provider`.
<add> # provided, it will default to the key provider set with +config.key_provider+.
<ide> # * <tt>:deterministic</tt> - By default, encryption is not deterministic. It will use a random
<ide> # initialization vector for each encryption operation. This means that encrypting the same content
<ide> # with the same key twice will generate different ciphertexts. When set to +true+, it will generate the
<ide><path>activerecord/lib/active_record/encryption/envelope_encryption_key_provider.rb
<ide> module Encryption
<ide> #
<ide> # This provider can work with multiple master keys. It will use the last one for encrypting.
<ide> #
<del> # When `config.store_key_references` is true, it will also store a reference to
<add> # When +config.store_key_references+ is true, it will also store a reference to
<ide> # the specific master key that was used to encrypt the data-encryption key. When not set,
<ide> # it will try all the configured master keys looking for the right one, in order to
<ide> # return the right decryption key.
<ide><path>activerecord/lib/active_record/middleware/shard_selector.rb
<ide> module Middleware
<ide> # shard to switch to and allows for applications to write custom strategies
<ide> # for swapping if needed.
<ide> #
<del> # The ShardSelector takes a set of options (currently only `lock` is supported)
<del> # that can be used by the middleware to alter behavior. `lock` is
<add> # The ShardSelector takes a set of options (currently only +lock+ is supported)
<add> # that can be used by the middleware to alter behavior. +lock+ is
<ide> # true by default and will prohibit the request from switching shards once
<del> # inside the block. If `lock` is false, then shard swapping will be allowed.
<del> # For tenant based sharding, `lock` should always be true to prevent application
<add> # inside the block. If +lock+ is false, then shard swapping will be allowed.
<add> # For tenant based sharding, +lock+ should always be true to prevent application
<ide> # code from mistakenly switching between tenants.
<ide> #
<ide> # Options can be set in the config:
<ide><path>activestorage/app/models/active_storage/variant_with_record.rb
<ide> # frozen_string_literal: true
<ide>
<ide> # Like an ActiveStorage::Variant, but keeps detail about the variant in the database as an
<del># ActiveStorage::VariantRecord. This is only used if `ActiveStorage.track_variants` is enabled.
<add># ActiveStorage::VariantRecord. This is only used if +ActiveStorage.track_variants+ is enabled.
<ide> class ActiveStorage::VariantWithRecord
<ide> attr_reader :blob, :variation
<ide> delegate :service, to: :blob
<ide><path>activesupport/lib/active_support/core_ext/date_and_time/compatibility.rb
<ide> module Compatibility
<ide>
<ide> # Change the output of <tt>ActiveSupport::TimeZone.utc_to_local</tt>.
<ide> #
<del> # When `true`, it returns local times with a UTC offset, with `false` local
<add> # When +true+, it returns local times with a UTC offset, with +false+ local
<ide> # times are returned as UTC.
<ide> #
<ide> # # Given this zone:
<ide><path>activesupport/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb
<ide> # of the module.
<ide> #
<ide> # Note that it can also be scoped per-fiber if Rails.application.config.active_support.isolation_level
<del># is set to `:fiber`.
<add># is set to +:fiber+.
<ide> class Module
<ide> # Defines a per-thread class attribute and creates class and instance reader methods.
<ide> # The underlying per-thread class variable is set to +nil+, if it is not previously defined.
<ide> def #{sym}=(obj)
<ide> # Account.user # => "DHH"
<ide> # Account.new.user # => "DHH"
<ide> #
<del> # Unlike `mattr_accessor`, values are *not* shared with subclasses or parent classes.
<add> # Unlike +mattr_accessor+, values are *not* shared with subclasses or parent classes.
<ide> # If a subclass changes the value, the parent class' value is not changed.
<ide> # If the parent class changes the value, the value of subclasses is not changed.
<ide> #
<ide><path>activesupport/lib/active_support/testing/constant_stubbing.rb
<ide> module ConstantStubbing
<ide> #
<ide> # assert_equal 5000, World::List::Import::LARGE_IMPORT_THRESHOLD = 5000
<ide> #
<del> # Using this method rather than forcing `World::List::Import::LARGE_IMPORT_THRESHOLD = 5000` prevents
<add> # Using this method rather than forcing <tt>World::List::Import::LARGE_IMPORT_THRESHOLD = 5000</tt> prevents
<ide> # warnings from being thrown, and ensures that the old value is returned after the test has completed.
<ide> #
<ide> # Note: Stubbing a const will stub it across all threads. So if you have concurrent threads | 15 |
PHP | PHP | remove useless reference operator | 247d8361748c3cc936d136feed7fe77ae70d5735 | <ide><path>lib/Cake/Utility/File.php
<ide> public function lastChange() {
<ide> * @return Folder Current folder
<ide> * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::Folder
<ide> */
<del> public function &folder() {
<add> public function folder() {
<ide> return $this->Folder;
<ide> }
<ide> | 1 |
Python | Python | add test for connection method thing | 36ee4efa531b25b7f50fa373f17bfa91a671b796 | <ide><path>libcloud/test/compute/test_indosat.py
<add># Licensed to the Apache Software Foundation (ASF) under one or more
<add># contributor license agreements. See the NOTICE file distributed with
<add># this work for additional information regarding copyright ownership.
<add># The ASF licenses this file to You under the Apache License, Version 2.0
<add># (the "License"); you may not use this file except in compliance with
<add># the License. You may obtain a copy of the License at
<add>#
<add># http://www.apache.org/licenses/LICENSE-2.0
<add>#
<add># Unless required by applicable law or agreed to in writing, software
<add># distributed under the License is distributed on an "AS IS" BASIS,
<add># WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<add># See the License for the specific language governing permissions and
<add># limitations under the License.
<add>
<add>import unittest
<add>
<add>from libcloud.compute.drivers.indosat import IndosatNodeDriver
<add>from libcloud.test.compute.test_dimensiondata_v2_3 import DimensionDataMockHttp, DimensionData_v2_3_Tests
<add>
<add>
<add>class IndosatNodeDriverTests(DimensionData_v2_3_Tests, unittest.TestCase):
<add>
<add> def setUp(self):
<add> IndosatNodeDriver.connectionCls.conn_class = DimensionDataMockHttp
<add> IndosatNodeDriver.connectionCls.active_api_version = '2.3'
<add> DimensionDataMockHttp.type = None
<add> self.driver = IndosatNodeDriver('user', 'password')
<ide><path>libcloud/test/compute/test_internetsolutions.py
<add># Licensed to the Apache Software Foundation (ASF) under one or more
<add># contributor license agreements. See the NOTICE file distributed with
<add># this work for additional information regarding copyright ownership.
<add># The ASF licenses this file to You under the Apache License, Version 2.0
<add># (the "License"); you may not use this file except in compliance with
<add># the License. You may obtain a copy of the License at
<add>#
<add># http://www.apache.org/licenses/LICENSE-2.0
<add>#
<add># Unless required by applicable law or agreed to in writing, software
<add># distributed under the License is distributed on an "AS IS" BASIS,
<add># WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<add># See the License for the specific language governing permissions and
<add># limitations under the License.
<add>
<add>import unittest
<add>
<add>from libcloud.compute.drivers.internetsolutions import InternetSolutionsNodeDriver
<add>from libcloud.test.compute.test_dimensiondata_v2_3 import DimensionDataMockHttp, DimensionData_v2_3_Tests
<add>
<add>
<add>class InternetSolutionsNodeDriverTests(DimensionData_v2_3_Tests, unittest.TestCase):
<add>
<add> def setUp(self):
<add> InternetSolutionsNodeDriver.connectionCls.conn_class = DimensionDataMockHttp
<add> InternetSolutionsNodeDriver.connectionCls.active_api_version = '2.3'
<add> DimensionDataMockHttp.type = None
<add> self.driver = InternetSolutionsNodeDriver('user', 'password')
<ide><path>libcloud/test/test_utils.py
<ide> import unittest
<ide> import warnings
<ide> import os.path
<del>
<add>import requests_mock
<ide> from itertools import chain
<ide>
<ide> # In Python > 2.7 DeprecationWarnings are disabled by default
<ide> from libcloud.utils.networking import join_ipv4_segments
<ide> from libcloud.utils.networking import increment_ipv4_segments
<ide> from libcloud.utils.decorators import wrap_non_libcloud_exceptions
<add>from libcloud.utils.connection import get_response_object
<ide> from libcloud.common.types import LibcloudError
<ide> from libcloud.storage.drivers.dummy import DummyIterator
<ide>
<ide> def foo():
<ide> with pytest.raises(LibcloudError):
<ide> foo()
<ide>
<add>
<add>def test_get_response_object():
<add> with requests_mock.mock() as m:
<add> m.get('http://test.com/test', text='data')
<add> response = get_response_object('http://test.com/test')
<add> assert response.body == 'data'
<add>
<ide> if __name__ == '__main__':
<ide> sys.exit(unittest.main()) | 3 |
Javascript | Javascript | adapt test-repl to v8 9.5 | 842fd234b7634200ed55141fc77d4e96c3c593bd | <ide><path>test/parallel/test-repl.js
<ide> async function runReplTests(socket, prompt, tests) {
<ide>
<ide> console.error('in:', JSON.stringify(actualLine));
<ide>
<del> // Match a string directly, or a RegExp through .test().
<add> // Match a string directly, or a RegExp.
<ide> if (typeof expectedLine === 'string') {
<ide> assert.strictEqual(actualLine, expectedLine);
<ide> } else {
<ide> const errorTests = [
<ide> // should throw
<ide> {
<ide> send: '/(/;',
<del> expect: [/^Uncaught SyntaxError: /]
<add> expect: [
<add> kSource,
<add> kArrow,
<add> '',
<add> /^Uncaught SyntaxError: /,
<add> ]
<ide> },
<ide> // invalid RegExp modifiers are a special case of syntax error,
<ide> // should throw (GH-4012) | 1 |
Javascript | Javascript | remove extra comma | 1b18f8c7730fc6285c2a07389e74655c0e4ce08f | <ide><path>packages/ember-metal/lib/property_events.js
<ide> import {
<del> guidFor,
<add> guidFor
<ide> } from 'ember-metal/utils';
<ide> import {
<ide> peekMeta | 1 |
Python | Python | fix next sentence output | 069b63844c9255cb0a56c632de281a3688834190 | <ide><path>src/transformers/modeling_tf_outputs.py
<ide> class TFNextSentencePredictorOutput(ModelOutput):
<ide> heads.
<ide> """
<ide>
<del> loss: tf.Tensor = None
<add> loss: Optional[tf.Tensor] = None
<ide> logits: tf.Tensor = None
<ide> hidden_states: Optional[Tuple[tf.Tensor]] = None
<ide> attentions: Optional[Tuple[tf.Tensor]] = None | 1 |
Ruby | Ruby | touch updated_at when upsert_all modifies a record | 3a8668bd7389c2bfa8c7c0b0ec17dc078734852a | <ide><path>activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
<ide> def build_insert_sql(insert) # :nodoc:
<ide> sql << " ON DUPLICATE KEY UPDATE #{no_op_column}=#{no_op_column}"
<ide> elsif insert.update_duplicates?
<ide> sql << " ON DUPLICATE KEY UPDATE "
<add> sql << insert.touch_model_timestamps_unless { |column| "#{column}<=>VALUES(#{column})" }
<ide> sql << insert.updatable_columns.map { |column| "#{column}=VALUES(#{column})" }.join(",")
<ide> end
<ide>
<ide><path>activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
<ide> def build_insert_sql(insert) # :nodoc:
<ide> sql << " ON CONFLICT #{insert.conflict_target} DO NOTHING"
<ide> elsif insert.update_duplicates?
<ide> sql << " ON CONFLICT #{insert.conflict_target} DO UPDATE SET "
<add> sql << insert.touch_model_timestamps_unless { |column| "#{insert.model.quoted_table_name}.#{column} IS NOT DISTINCT FROM excluded.#{column}" }
<ide> sql << insert.updatable_columns.map { |column| "#{column}=excluded.#{column}" }.join(",")
<ide> end
<ide>
<ide><path>activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
<ide> def build_insert_sql(insert) # :nodoc:
<ide> sql << " ON CONFLICT #{insert.conflict_target} DO NOTHING"
<ide> elsif insert.update_duplicates?
<ide> sql << " ON CONFLICT #{insert.conflict_target} DO UPDATE SET "
<add> sql << insert.touch_model_timestamps_unless { |column| "#{column} IS excluded.#{column}" }
<ide> sql << insert.updatable_columns.map { |column| "#{column}=excluded.#{column}" }.join(",")
<ide> end
<ide>
<ide><path>activerecord/lib/active_record/insert_all.rb
<ide> def updatable_columns
<ide> quote_columns(insert_all.updatable_columns)
<ide> end
<ide>
<add> def touch_model_timestamps_unless(&block)
<add> model.send(:timestamp_attributes_for_update_in_model).map do |column_name|
<add> if touch_timestamp_attribute?(column_name)
<add> "#{column_name}=(CASE WHEN (#{updatable_columns.map(&block).join(" AND ")}) THEN #{model.quoted_table_name}.#{column_name} ELSE CURRENT_TIMESTAMP END),"
<add> end
<add> end.compact.join
<add> end
<add>
<ide> private
<ide> attr_reader :connection, :insert_all
<ide>
<add> def touch_timestamp_attribute?(column_name)
<add> update_duplicates? && !insert_all.updatable_columns.include?(column_name)
<add> end
<add>
<ide> def columns_list
<ide> format_columns(insert_all.keys)
<ide> end
<ide><path>activerecord/test/cases/insert_all_test.rb
<ide> def test_upsert_all_does_not_perform_an_upsert_if_a_partial_index_doesnt_apply
<ide> assert_equal ["Out of the Silent Planet", "Perelandra"], Book.where(isbn: "1974522598").order(:name).pluck(:name)
<ide> end
<ide>
<add> def test_upsert_all_does_not_touch_updated_at_when_values_do_not_change
<add> skip unless supports_insert_on_duplicate_update?
<add>
<add> updated_at = Time.now.utc - 5.years
<add> Book.insert_all [{ id: 101, name: "Out of the Silent Planet", published_on: Date.new(1938, 4, 1), updated_at: updated_at }]
<add> Book.upsert_all [{ id: 101, name: "Out of the Silent Planet", published_on: Date.new(1938, 4, 1) }]
<add>
<add> assert_in_delta updated_at, Book.find(101).updated_at, 1
<add> end
<add>
<add> def test_upsert_all_touches_updated_at_and_updated_on_when_values_change
<add> skip unless supports_insert_on_duplicate_update?
<add>
<add> Book.insert_all [{ id: 101, name: "Out of the Silent Planet", published_on: Date.new(1938, 4, 1), updated_at: 5.years.ago, updated_on: 5.years.ago }]
<add> Book.upsert_all [{ id: 101, name: "Out of the Silent Planet", published_on: Date.new(1938, 4, 8) }]
<add>
<add> assert_equal Time.now.year, Book.find(101).updated_at.year
<add> assert_equal Time.now.year, Book.find(101).updated_on.year
<add> end
<add>
<add> def test_upsert_all_uses_given_updated_at_over_implicit_updated_at
<add> skip unless supports_insert_on_duplicate_update?
<add>
<add> updated_at = Time.now.utc - 1.year
<add> Book.insert_all [{ id: 101, name: "Out of the Silent Planet", published_on: Date.new(1938, 4, 1), updated_at: 5.years.ago }]
<add> Book.upsert_all [{ id: 101, name: "Out of the Silent Planet", published_on: Date.new(1938, 4, 8), updated_at: updated_at }]
<add>
<add> assert_in_delta updated_at, Book.find(101).updated_at, 1
<add> end
<add>
<add> def test_upsert_all_uses_given_updated_on_over_implicit_updated_on
<add> skip unless supports_insert_on_duplicate_update?
<add>
<add> updated_on = Time.now.utc.to_date - 30
<add> Book.insert_all [{ id: 101, name: "Out of the Silent Planet", published_on: Date.new(1938, 4, 1), updated_on: 5.years.ago }]
<add> Book.upsert_all [{ id: 101, name: "Out of the Silent Planet", published_on: Date.new(1938, 4, 8), updated_on: updated_on }]
<add>
<add> assert_equal updated_on, Book.find(101).updated_on
<add> end
<add>
<ide> def test_insert_all_raises_on_unknown_attribute
<ide> assert_raise ActiveRecord::UnknownAttributeError do
<ide> Book.insert_all! [{ unknown_attribute: "Test" }]
<ide><path>activerecord/test/schema/schema.rb
<ide> t.datetime :published_on
<ide> t.index [:author_id, :name], unique: true
<ide> t.index :isbn, where: "published_on IS NOT NULL", unique: true
<add>
<add> t.datetime :created_at
<add> t.datetime :updated_at
<add> t.date :updated_on
<ide> end
<ide>
<ide> create_table :booleans, force: true do |t| | 6 |
PHP | PHP | change default value of consoleinputoption to null | c02dbade4cdd6ca9213911d93a230b5de1beb79b | <ide><path>src/Console/ConsoleInputOption.php
<ide> class ConsoleInputOption
<ide> /**
<ide> * Default value for the option
<ide> *
<del> * @var string|bool
<add> * @var string|bool|null
<ide> */
<ide> protected $_default;
<ide>
<ide> class ConsoleInputOption
<ide> * @param string $short The short alias for this option
<ide> * @param string $help The help text for this option
<ide> * @param bool $boolean Whether this option is a boolean option. Boolean options don't consume extra tokens
<del> * @param string|bool $default The default value for this option.
<add> * @param string|bool|null $default The default value for this option.
<ide> * @param string[] $choices Valid choices for this option.
<ide> * @param bool $multiple Whether this option can accept multiple value definition.
<ide> * @throws \Cake\Console\Exception\ConsoleException
<ide> public function __construct(
<ide> string $short = '',
<ide> string $help = '',
<ide> bool $boolean = false,
<del> $default = '',
<add> $default = null,
<ide> array $choices = [],
<ide> bool $multiple = false
<ide> ) {
<ide> $this->_name = $name;
<ide> $this->_short = $short;
<ide> $this->_help = $help;
<ide> $this->_boolean = $boolean;
<del> $this->_default = is_bool($default) ? $default : (string)$default;
<ide> $this->_choices = $choices;
<ide> $this->_multiple = $multiple;
<ide>
<add> if ($boolean) {
<add> $this->_default = (bool)$default;
<add> } elseif ($default !== null) {
<add> $this->_default = (string)$default;
<add> }
<add>
<ide> if (strlen($this->_short) > 1) {
<ide> throw new ConsoleException(
<ide> sprintf('Short option "%s" is invalid, short options must be one letter.', $this->_short)
<ide> public function usage(): string
<ide> {
<ide> $name = strlen($this->_short) > 0 ? ('-' . $this->_short) : ('--' . $this->_name);
<ide> $default = '';
<del> if (!is_bool($this->_default) && strlen($this->_default) > 0) {
<add> if ($this->_default !== null && !is_bool($this->_default) && strlen($this->_default) > 0) {
<ide> $default = ' ' . $this->_default;
<ide> }
<ide> if ($this->_choices) {
<ide> public function usage(): string
<ide> /**
<ide> * Get the default value for this option
<ide> *
<del> * @return string|bool
<add> * @return string|bool|null
<ide> */
<ide> public function defaultValue()
<ide> {
<ide> public function defaultValue()
<ide> */
<ide> public function isBoolean(): bool
<ide> {
<del> return (bool)$this->_boolean;
<add> return $this->_boolean;
<ide> }
<ide>
<ide> /**
<ide> public function isBoolean(): bool
<ide> */
<ide> public function acceptsMultiple(): bool
<ide> {
<del> return (bool)$this->_multiple;
<add> return $this->_multiple;
<ide> }
<ide>
<ide> /**
<ide> public function xml(SimpleXMLElement $parent): SimpleXMLElement
<ide> $option->addAttribute('short', $short);
<ide> $option->addAttribute('help', $this->_help);
<ide> $option->addAttribute('boolean', (string)(int)$this->_boolean);
<del> $option->addChild('default', $default);
<add> $option->addChild('default', (string)$default);
<ide> $choices = $option->addChild('choices');
<ide> foreach ($this->_choices as $valid) {
<ide> $choices->addChild('choice', $valid);
<ide><path>src/Console/ConsoleOptionParser.php
<ide> protected function _parseOption(string $name, array $params): array
<ide> } elseif ($isBoolean) {
<ide> $value = true;
<ide> } else {
<del> $value = $option->defaultValue();
<add> $value = (string)$option->defaultValue();
<ide> }
<ide>
<ide> $option->validChoice($value);
<ide><path>tests/TestCase/Console/ConsoleOptionParserTest.php
<ide> public function testAddOptionLongEquals()
<ide> public function testAddOptionDefault()
<ide> {
<ide> $parser = new ConsoleOptionParser('test', false);
<del> $parser->addOption('test', [
<del> 'default' => 'default value',
<del> ]);
<add> $parser
<add> ->addOption('test', [
<add> 'default' => 'default value',
<add> ])
<add> ->addOption('no-default', [
<add> ]);
<ide> $result = $parser->parse(['--test']);
<del> $this->assertEquals(['test' => 'default value', 'help' => false], $result[0], 'Default value did not parse out');
<add> $this->assertEquals(
<add> ['test' => 'default value', 'help' => false, 'no-default' => null],
<add> $result[0],
<add> 'Default value did not parse out'
<add> );
<ide>
<ide> $parser = new ConsoleOptionParser('test', false);
<ide> $parser->addOption('test', [ | 3 |
Text | Text | improve typescript documentation. | 175e081e862b503d2daf4c2d07d589f86d037f06 | <ide><path>docs/api-reference/next.config.js/ignoring-typescript-errors.md
<ide> Next.js fails your **production build** (`next build`) when TypeScript errors ar
<ide>
<ide> If you'd like Next.js to dangerously produce production code even when your application has errors, you can disable the built-in type checking step.
<ide>
<del>> Be sure you are running type checks as part of your build or deploy process, otherwise this can be very dangerous.
<add>If disabled, be sure you are running type checks as part of your build or deploy process, otherwise this can be very dangerous.
<ide>
<ide> Open `next.config.js` and enable the `ignoreBuildErrors` option in the `typescript` config:
<ide>
<ide><path>docs/basic-features/typescript.md
<ide> description: Next.js supports TypeScript by default and has built-in types for p
<ide> # TypeScript
<ide>
<ide> <details>
<del> <summary><b>Examples</b></summary>
<del> <ul>
<del> <li><a href="https://github.com/vercel/next.js/tree/canary/examples/with-typescript">TypeScript</a></li>
<del> </ul>
<add> <summary><b>Version History</b></summary>
<add>
<add>| Version | Changes |
<add>| --------- | ------------------------------------------------------------------------------------------------------------------------------------ |
<add>| `v12.0.0` | [SWC](https://nextjs.org/docs/advanced-features/compiler) is now used by default to compile TypeScript and TSX for faster builds. |
<add>| `v10.2.1` | [Incremental type checking](https://www.typescriptlang.org/tsconfig#incremental) support added when enabled in your `tsconfig.json`. |
<add>
<ide> </details>
<ide>
<del>Next.js provides an integrated [TypeScript](https://www.typescriptlang.org/)
<del>experience out of the box, similar to an IDE.
<add>Next.js provides an integrated [TypeScript](https://www.typescriptlang.org/) experience, including zero-configuration set up and built-in types for Pages, APIs, and more.
<add>
<add>- [Clone and deploy the TypeScript starter](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fvercel%2Fnext.js%2Ftree%2Fcanary%2Fexamples%2Fwith-typescript&project-name=with-typescript&repository-name=with-typescript)
<add>- [View an example application](https://github.com/vercel/next.js/tree/canary/examples/with-typescript)
<ide>
<ide> ## `create-next-app` support
<ide>
<ide> export default (req: NextApiRequest, res: NextApiResponse<Data>) => {
<ide> If you have a [custom `App`](/docs/advanced-features/custom-app.md), you can use the built-in type `AppProps` and change file name to `./pages/_app.tsx` like so:
<ide>
<ide> ```ts
<del>// import App from "next/app";
<del>import type { AppProps /*, AppContext */ } from 'next/app'
<add>import type { AppProps } from 'next/app'
<ide>
<del>function MyApp({ Component, pageProps }: AppProps) {
<add>export default function MyApp({ Component, pageProps }: AppProps) {
<ide> return <Component {...pageProps} />
<ide> }
<del>
<del>// Only uncomment this method if you have blocking data requirements for
<del>// every single page in your application. This disables the ability to
<del>// perform automatic static optimization, causing every page in your app to
<del>// be server-side rendered.
<del>//
<del>// MyApp.getInitialProps = async (appContext: AppContext) => {
<del>// // calls page's `getInitialProps` and fills `appProps.pageProps`
<del>// const appProps = await App.getInitialProps(appContext);
<del>
<del>// return { ...appProps }
<del>// }
<del>
<del>export default MyApp
<ide> ```
<ide>
<ide> ## Path aliases and baseUrl
<ide> module.exports = nextConfig
<ide> Since `v10.2.1` Next.js supports [incremental type checking](https://www.typescriptlang.org/tsconfig#incremental) when enabled in your `tsconfig.json`, this can help speed up type checking in larger applications.
<ide>
<ide> It is highly recommended to be on at least `v4.3.2` of TypeScript to experience the [best performance](https://devblogs.microsoft.com/typescript/announcing-typescript-4-3/#lazier-incremental) when leveraging this feature.
<add>
<add>## Ignoring TypeScript Errors
<add>
<add>Next.js fails your **production build** (`next build`) when TypeScript errors are present in your project.
<add>
<add>If you'd like Next.js to dangerously produce production code even when your application has errors, you can disable the built-in type checking step.
<add>
<add>If disabled, be sure you are running type checks as part of your build or deploy process, otherwise this can be very dangerous.
<add>
<add>Open `next.config.js` and enable the `ignoreBuildErrors` option in the `typescript` config:
<add>
<add>```js
<add>module.exports = {
<add> typescript: {
<add> // !! WARN !!
<add> // Dangerously allow production builds to successfully complete even if
<add> // your project has type errors.
<add> // !! WARN !!
<add> ignoreBuildErrors: true,
<add> },
<add>}
<add>``` | 2 |
Python | Python | update compatibility with google-cloud-kms>=2.0 | b26b0df5b03c4cd826fd7b2dff5771d64e18e6b7 | <ide><path>airflow/providers/google/cloud/hooks/kms.py
<ide> def encrypt(
<ide> :rtype: str
<ide> """
<ide> response = self.get_conn().encrypt(
<del> name=key_name,
<del> plaintext=plaintext,
<del> additional_authenticated_data=authenticated_data,
<add> request={
<add> 'name': key_name,
<add> 'plaintext': plaintext,
<add> 'additional_authenticated_data': authenticated_data,
<add> },
<ide> retry=retry,
<ide> timeout=timeout,
<del> metadata=metadata,
<add> metadata=metadata or (),
<ide> )
<ide>
<ide> ciphertext = _b64encode(response.ciphertext)
<ide> def decrypt(
<ide> :rtype: bytes
<ide> """
<ide> response = self.get_conn().decrypt(
<del> name=key_name,
<del> ciphertext=_b64decode(ciphertext),
<del> additional_authenticated_data=authenticated_data,
<add> request={
<add> 'name': key_name,
<add> 'ciphertext': _b64decode(ciphertext),
<add> 'additional_authenticated_data': authenticated_data,
<add> },
<ide> retry=retry,
<ide> timeout=timeout,
<del> metadata=metadata,
<add> metadata=metadata or (),
<ide> )
<ide>
<ide> return response.plaintext
<ide><path>setup.py
<ide> def write_version(filename: str = os.path.join(*[my_dir, "airflow", "git_version
<ide> 'google-cloud-datacatalog>=1.0.0,<2.0.0',
<ide> 'google-cloud-dataproc>=1.0.1,<2.0.0',
<ide> 'google-cloud-dlp>=0.11.0,<2.0.0',
<del> 'google-cloud-kms>=1.2.1,<2.0.0',
<add> 'google-cloud-kms>=2.0.0,<3.0.0',
<ide> 'google-cloud-language>=1.1.1,<2.0.0',
<ide> 'google-cloud-logging>=1.14.0,<2.0.0',
<ide> 'google-cloud-memcache>=0.2.0',
<ide><path>tests/providers/google/cloud/hooks/test_kms.py
<ide> def test_encrypt(self, mock_get_conn):
<ide> result = self.kms_hook.encrypt(TEST_KEY_ID, PLAINTEXT)
<ide> mock_get_conn.assert_called_once_with()
<ide> mock_get_conn.return_value.encrypt.assert_called_once_with(
<del> name=TEST_KEY_ID,
<del> plaintext=PLAINTEXT,
<del> additional_authenticated_data=None,
<add> request=dict(
<add> name=TEST_KEY_ID,
<add> plaintext=PLAINTEXT,
<add> additional_authenticated_data=None,
<add> ),
<ide> retry=None,
<ide> timeout=None,
<del> metadata=None,
<add> metadata=(),
<ide> )
<ide> self.assertEqual(PLAINTEXT_b64, result)
<ide>
<ide> def test_encrypt_with_auth_data(self, mock_get_conn):
<ide> result = self.kms_hook.encrypt(TEST_KEY_ID, PLAINTEXT, AUTH_DATA)
<ide> mock_get_conn.assert_called_once_with()
<ide> mock_get_conn.return_value.encrypt.assert_called_once_with(
<del> name=TEST_KEY_ID,
<del> plaintext=PLAINTEXT,
<del> additional_authenticated_data=AUTH_DATA,
<add> request=dict(
<add> name=TEST_KEY_ID,
<add> plaintext=PLAINTEXT,
<add> additional_authenticated_data=AUTH_DATA,
<add> ),
<ide> retry=None,
<ide> timeout=None,
<del> metadata=None,
<add> metadata=(),
<ide> )
<ide> self.assertEqual(PLAINTEXT_b64, result)
<ide>
<ide> def test_decrypt(self, mock_get_conn):
<ide> result = self.kms_hook.decrypt(TEST_KEY_ID, CIPHERTEXT_b64)
<ide> mock_get_conn.assert_called_once_with()
<ide> mock_get_conn.return_value.decrypt.assert_called_once_with(
<del> name=TEST_KEY_ID,
<del> ciphertext=CIPHERTEXT,
<del> additional_authenticated_data=None,
<add> request=dict(
<add> name=TEST_KEY_ID,
<add> ciphertext=CIPHERTEXT,
<add> additional_authenticated_data=None,
<add> ),
<ide> retry=None,
<ide> timeout=None,
<del> metadata=None,
<add> metadata=(),
<ide> )
<ide> self.assertEqual(PLAINTEXT, result)
<ide>
<ide> def test_decrypt_with_auth_data(self, mock_get_conn):
<ide> result = self.kms_hook.decrypt(TEST_KEY_ID, CIPHERTEXT_b64, AUTH_DATA)
<ide> mock_get_conn.assert_called_once_with()
<ide> mock_get_conn.return_value.decrypt.assert_called_once_with(
<del> name=TEST_KEY_ID,
<del> ciphertext=CIPHERTEXT,
<del> additional_authenticated_data=AUTH_DATA,
<add> request=dict(
<add> name=TEST_KEY_ID,
<add> ciphertext=CIPHERTEXT,
<add> additional_authenticated_data=AUTH_DATA,
<add> ),
<ide> retry=None,
<ide> timeout=None,
<del> metadata=None,
<add> metadata=(),
<ide> )
<ide> self.assertEqual(PLAINTEXT, result) | 3 |
Javascript | Javascript | add some types for plugins | 9ad9abdd2ac50cb788dc9c003e5f48f8224e127c | <ide><path>lib/dependencies/HarmonyModulesPlugin.js
<ide> const HarmonyExportDependencyParserPlugin = require("./HarmonyExportDependencyPa
<ide> const HarmonyImportDependencyParserPlugin = require("./HarmonyImportDependencyParserPlugin");
<ide> const HarmonyTopLevelThisParserPlugin = require("./HarmonyTopLevelThisParserPlugin");
<ide>
<add>/** @typedef {import("../Compiler")} Compiler */
<add>
<ide> class HarmonyModulesPlugin {
<ide> constructor(options) {
<ide> this.options = options;
<ide> }
<ide>
<add> /**
<add> * @param {Compiler} compiler webpack compiler
<add> * @returns {void}
<add> */
<ide> apply(compiler) {
<ide> compiler.hooks.compilation.tap(
<ide> "HarmonyModulesPlugin",
<ide><path>lib/dependencies/ImportPlugin.js
<ide> const ImportEagerDependency = require("./ImportEagerDependency");
<ide> const ImportParserPlugin = require("./ImportParserPlugin");
<ide> const ImportWeakDependency = require("./ImportWeakDependency");
<ide>
<add>/** @typedef {import("../Compiler")} Compiler */
<add>
<ide> class ImportPlugin {
<ide> constructor(options) {
<ide> this.options = options;
<ide> }
<ide>
<add> /**
<add> * Apply the plugin
<add> * @param {Compiler} compiler the compiler instance
<add> * @returns {void}
<add> */
<ide> apply(compiler) {
<ide> const options = this.options;
<ide> compiler.hooks.compilation.tap(
<ide><path>lib/dependencies/SystemPlugin.js
<ide> const WebpackError = require("../WebpackError");
<ide> const ConstDependency = require("./ConstDependency");
<ide> const SystemRuntimeModule = require("./SystemRuntimeModule");
<ide>
<add>/** @typedef {import("../Compiler")} Compiler */
<add>
<ide> class SystemPlugin {
<ide> constructor(options) {
<ide> this.options = options;
<ide> }
<ide>
<add> /**
<add> * Apply the plugin
<add> * @param {Compiler} compiler the compiler instance
<add> * @returns {void}
<add> */
<ide> apply(compiler) {
<ide> compiler.hooks.compilation.tap(
<ide> "SystemPlugin", | 3 |
Go | Go | create panic.log file without readonly flag | b865204042237d3cf620d04f7a8cb3215f87fcea | <ide><path>cmd/dockerd/service_windows.go
<ide> Loop:
<ide>
<ide> func initPanicFile(path string) error {
<ide> var err error
<del> panicFile, err = os.OpenFile(path, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0)
<add> panicFile, err = os.OpenFile(path, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0o200)
<ide> if err != nil {
<ide> return err
<ide> } | 1 |
Ruby | Ruby | use formula helper in tests | e651e7662aec9ffdb864e883d54b9204b60181a4 | <ide><path>Library/Homebrew/test/test_formula.rb
<ide> def test_class_naming
<ide> end
<ide>
<ide> def test_formula_spec_integration
<del> f = Class.new(Formula) do
<add> f = formula do
<ide> homepage 'http://example.com'
<ide> url 'http://example.com/test-0.1.tbz'
<ide> mirror 'http://example.org/test-0.1.tbz'
<ide> def test_formula_spec_integration
<ide> mirror 'http://example.org/test-0.2.tbz'
<ide> sha256 TEST_SHA256
<ide> end
<del> end.new("test", Pathname.new(__FILE__).expand_path, :stable)
<add> end
<ide>
<ide> assert_equal 'http://example.com', f.homepage
<ide> assert_version_equal '0.1', f.version
<ide><path>Library/Homebrew/test/test_formula_validation.rb
<ide> def assert_invalid(attr, &block)
<ide> end
<ide>
<ide> def test_cant_override_brew
<del> e = assert_raises(RuntimeError) { Class.new(Formula) { def brew; end } }
<add> e = assert_raises(RuntimeError) { formula { def brew; end } }
<ide> assert_match %r{You cannot override Formula#brew}, e.message
<ide> end
<ide> | 2 |
Ruby | Ruby | remove unused require | bd01f9831cb6416b34f566167237697e666e5e41 | <ide><path>activestorage/lib/active_storage/service/gcs_service.rb
<ide> require "google/cloud/storage"
<ide> require "net/http"
<ide>
<del>require "active_support/core_ext/object/to_query"
<del>
<ide> module ActiveStorage
<ide> # Wraps the Google Cloud Storage as an Active Storage service. See ActiveStorage::Service for the generic API
<ide> # documentation that applies to all services. | 1 |
Javascript | Javascript | fix warning of root metro config | 0f3f6c0938411a9dc8a08c6cdcc93988a875fb91 | <ide><path>metro.config.js
<ide> const getPolyfills = require('./rn-get-polyfills');
<ide> * integration tests during local development or on CI services.
<ide> */
<ide> module.exports = {
<del> extraNodeModules: {
<del> 'react-native': __dirname,
<add> resolver: {
<add> extraNodeModules: {
<add> 'react-native': __dirname,
<add> },
<add> },
<add> serializer: {
<add> getPolyfills,
<ide> },
<del> getPolyfills,
<ide> }; | 1 |
PHP | PHP | remove tab in realtion.php | 05e96ce203f403f99da5634fc7c155ce5208a7d9 | <ide><path>src/Illuminate/Database/Eloquent/Relations/Relation.php
<ide> public function __call($method, $parameters)
<ide>
<ide> return $result;
<ide> }
<del>
<add>
<ide> /**
<ide> * Force a clone of the underlying query builder when cloning.
<ide> * | 1 |
Ruby | Ruby | allow redacting secrets in the log | 9232ca4508184505f140b3810823872299b480df | <ide><path>Library/Homebrew/exceptions.rb
<ide> # frozen_string_literal: true
<ide>
<ide> require "shellwords"
<add>require "utils"
<ide>
<ide> class UsageError < RuntimeError
<ide> attr_reader :reason
<ide> class ErrorDuringExecution < RuntimeError
<ide> attr_reader :status
<ide> attr_reader :output
<ide>
<del> def initialize(cmd, status:, output: nil)
<add> def initialize(cmd, status:, output: nil, secrets: [])
<ide> @cmd = cmd
<ide> @status = status
<ide> @output = output
<ide> def initialize(cmd, status:, output: nil)
<ide> status
<ide> end
<ide>
<del> s = +"Failure while executing; `#{cmd.shelljoin.gsub(/\\=/, "=")}` exited with #{exitstatus}."
<add> redacted_cmd = redact_secrets(cmd.shelljoin.gsub('\=', "="), secrets)
<add> s = +"Failure while executing; `#{redacted_cmd}` exited with #{exitstatus}."
<ide>
<ide> unless [*output].empty?
<ide> format_output_line = lambda do |type_line|
<ide><path>Library/Homebrew/system_command.rb
<ide> def self.run!(command, **options)
<ide> end
<ide>
<ide> def run!
<del> puts command.shelljoin.gsub(/\\=/, "=") if verbose? || ARGV.debug?
<add> puts redact_secrets(command.shelljoin.gsub('\=', "="), @secrets) if verbose? || ARGV.debug?
<ide>
<ide> @output = []
<ide>
<ide> def run!
<ide> end
<ide>
<ide> def initialize(executable, args: [], sudo: false, env: {}, input: [], must_succeed: false,
<del> print_stdout: false, print_stderr: true, verbose: false, **options)
<add> print_stdout: false, print_stderr: true, verbose: false, secrets: [], **options)
<ide>
<ide> @executable = executable
<ide> @args = args
<ide> def initialize(executable, args: [], sudo: false, env: {}, input: [], must_succe
<ide> @print_stdout = print_stdout
<ide> @print_stderr = print_stderr
<ide> @verbose = verbose
<add> @secrets = Array(secrets)
<ide> @must_succeed = must_succeed
<ide> options.assert_valid_keys!(:chdir)
<ide> @options = options
<ide> def sudo_prefix
<ide> def assert_success
<ide> return if @status.success?
<ide>
<del> raise ErrorDuringExecution.new(command,
<del> status: @status,
<del> output: @output)
<add> raise ErrorDuringExecution.new(command, status: @status, output: @output, secrets: @secrets)
<ide> end
<ide>
<ide> def expanded_args
<ide><path>Library/Homebrew/test/system_command_spec.rb
<ide> expect(system_command(executable)).to be_a_success
<ide> end
<ide> end
<add>
<add> context "when given arguments with secrets" do
<add> it "does not leak the secrets" do
<add> redacted_msg = /#{Regexp.escape("username:******")}/
<add> expect do
<add> described_class.run! "curl",
<add> args: %w[--user username:hunter2],
<add> verbose: true,
<add> secrets: %w[hunter2]
<add> end.to raise_error.with_message(redacted_msg).and output(redacted_msg).to_stdout
<add> end
<add> end
<ide> end
<ide> end
<ide><path>Library/Homebrew/utils.rb
<ide> def tap_and_name_comparison
<ide> def command_help_lines(path)
<ide> path.read.lines.grep(/^#:/).map { |line| line.slice(2..-1) }
<ide> end
<add>
<add>def redact_secrets(input, secrets)
<add> secrets.reduce(input) { |str, secret| str.gsub secret, "******" }.freeze
<add>end | 4 |
Text | Text | remove datetime fields from helper list [ci skip] | 2b82e96597d4d9a6054bdeea86e51477565ac449 | <ide><path>guides/source/form_helpers.md
<ide> make it easier for users to click the inputs.
<ide>
<ide> Other form controls worth mentioning are textareas, password fields,
<ide> hidden fields, search fields, telephone fields, date fields, time fields,
<del>color fields, datetime fields, datetime-local fields, month fields, week fields,
<add>color fields, datetime-local fields, month fields, week fields,
<ide> URL fields, email fields, number fields and range fields:
<ide>
<ide> ```erb | 1 |
Ruby | Ruby | use instance_exec to invoke the lambda callback | 76c230e7d80d72352da76f5c95b786b183cdfa09 | <ide><path>lib/action_cable/channel/base.rb
<ide> def broadcast(data)
<ide> def start_periodic_timers
<ide> self.class.periodic_timers.each do |callback, options|
<ide> @_active_periodic_timers << EventMachine::PeriodicTimer.new(options[:every]) do
<del> callback.respond_to?(:call) ? callback.call : send(callback)
<add> callback.respond_to?(:call) ? instance_exec(&callback) : send(callback)
<ide> end
<ide> end
<ide> end | 1 |
Javascript | Javascript | add test for d3.version | 8986f76af67963b906e9729a671a50ea3c070090 | <ide><path>test/core/version-test.js
<add>require("../env");
<add>require("../../d3");
<add>
<add>var vows = require("vows"),
<add> assert = require("assert");
<add>
<add>var suite = vows.describe("d3.version");
<add>
<add>suite.addBatch({
<add> "semantic versioning": {
<add> topic: d3.version,
<add> "has the form major.minor.patch": function(version) {
<add> assert.match(version, /^[0-9]+\.[0-9]+\.[0-9]+$/);
<add> }
<add> }
<add>});
<add>
<add>suite.export(module); | 1 |
Python | Python | use random_attention_mask for tf tests | 2199382dfd6c1e010518acdd5732adc114a6a7f0 | <ide><path>templates/adding_a_new_model/cookiecutter-template-{{cookiecutter.modelname}}/test_modeling_tf_{{cookiecutter.lowercase_modelname}}.py
<ide> from transformers.testing_utils import require_tf, slow
<ide>
<ide> from ..test_configuration_common import ConfigTester
<del>from ..test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor
<add>from ..test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask
<ide>
<ide>
<ide> if is_tf_available():
<ide> def prepare_config_and_inputs(self):
<ide>
<ide> input_mask = None
<ide> if self.use_input_mask:
<del> input_mask = ids_tensor([self.batch_size, self.seq_length], vocab_size=2)
<add> input_mask = random_attention_mask([self.batch_size, self.seq_length])
<ide>
<ide> token_type_ids = None
<ide> if self.use_token_type_ids:
<ide><path>tests/albert/test_modeling_tf_albert.py
<ide> from transformers.testing_utils import require_tf, slow
<ide>
<ide> from ..test_configuration_common import ConfigTester
<del>from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor
<add>from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
<ide>
<ide>
<ide> if is_tf_available():
<ide> def prepare_config_and_inputs(self):
<ide>
<ide> input_mask = None
<ide> if self.use_input_mask:
<del> input_mask = ids_tensor([self.batch_size, self.seq_length], vocab_size=2)
<add> input_mask = random_attention_mask([self.batch_size, self.seq_length])
<ide>
<ide> token_type_ids = None
<ide> if self.use_token_type_ids:
<ide><path>tests/bert/test_modeling_tf_bert.py
<ide> from transformers.testing_utils import require_tf, slow
<ide>
<ide> from ..test_configuration_common import ConfigTester
<del>from ..test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor
<add>from ..test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask
<ide> from ..utils.test_modeling_tf_core import TFCoreModelTesterMixin
<ide>
<ide>
<ide> def prepare_config_and_inputs(self):
<ide>
<ide> input_mask = None
<ide> if self.use_input_mask:
<del> input_mask = ids_tensor([self.batch_size, self.seq_length], vocab_size=2)
<add> input_mask = random_attention_mask([self.batch_size, self.seq_length])
<ide>
<ide> token_type_ids = None
<ide> if self.use_token_type_ids:
<ide><path>tests/clip/test_modeling_tf_clip.py
<ide> def prepare_config_and_inputs(self):
<ide> input_mask = None
<ide> if self.use_input_mask:
<ide> input_mask = random_attention_mask([self.batch_size, self.seq_length])
<add> # make sure the first token has attention mask `1` to ensure that, after combining the causal mask, there
<add> # is still at least one token being attended to for each batch.
<add> # TODO: Change `random_attention_mask` in PT/TF/Flax common test file, after a discussion with the team.
<add> input_mask = tf.concat(
<add> [tf.ones_like(input_mask[:, :1], dtype=input_mask.dtype), input_mask[:, 1:]], axis=-1
<add> )
<ide>
<ide> config = self.get_config()
<ide>
<ide><path>tests/convbert/test_modeling_tf_convbert.py
<ide> from transformers.testing_utils import require_tf, slow
<ide>
<ide> from ..test_configuration_common import ConfigTester
<del>from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor
<add>from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
<ide>
<ide>
<ide> if is_tf_available():
<ide> def prepare_config_and_inputs(self):
<ide>
<ide> input_mask = None
<ide> if self.use_input_mask:
<del> input_mask = ids_tensor([self.batch_size, self.seq_length], vocab_size=2)
<add> input_mask = random_attention_mask([self.batch_size, self.seq_length])
<ide>
<ide> token_type_ids = None
<ide> if self.use_token_type_ids:
<ide><path>tests/ctrl/test_modeling_tf_ctrl.py
<ide> from transformers.testing_utils import require_tf, slow
<ide>
<ide> from ..test_configuration_common import ConfigTester
<del>from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor
<add>from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
<ide>
<ide>
<ide> if is_tf_available():
<ide> def prepare_config_and_inputs(self):
<ide>
<ide> input_mask = None
<ide> if self.use_input_mask:
<del> input_mask = ids_tensor([self.batch_size, self.seq_length], vocab_size=2)
<add> input_mask = random_attention_mask([self.batch_size, self.seq_length])
<ide>
<ide> token_type_ids = None
<ide> if self.use_token_type_ids:
<ide><path>tests/deberta/test_modeling_tf_deberta.py
<ide> from transformers.testing_utils import require_tf, slow
<ide>
<ide> from ..test_configuration_common import ConfigTester
<del>from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor
<add>from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
<ide>
<ide>
<ide> if is_tf_available():
<ide> def prepare_config_and_inputs(self):
<ide>
<ide> input_mask = None
<ide> if self.use_input_mask:
<del> input_mask = ids_tensor([self.batch_size, self.seq_length], vocab_size=2)
<add> input_mask = random_attention_mask([self.batch_size, self.seq_length])
<ide>
<ide> token_type_ids = None
<ide> if self.use_token_type_ids:
<ide><path>tests/deberta_v2/test_modeling_tf_deberta_v2.py
<ide> from transformers.testing_utils import require_tf, slow
<ide>
<ide> from ..test_configuration_common import ConfigTester
<del>from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor
<add>from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
<ide>
<ide>
<ide> if is_tf_available():
<ide> def prepare_config_and_inputs(self):
<ide>
<ide> input_mask = None
<ide> if self.use_input_mask:
<del> input_mask = ids_tensor([self.batch_size, self.seq_length], vocab_size=2)
<add> input_mask = random_attention_mask([self.batch_size, self.seq_length])
<ide>
<ide> token_type_ids = None
<ide> if self.use_token_type_ids:
<ide><path>tests/distilbert/test_modeling_tf_distilbert.py
<ide> from transformers.testing_utils import require_tf, slow
<ide>
<ide> from ..test_configuration_common import ConfigTester
<del>from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor
<add>from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
<ide>
<ide>
<ide> if is_tf_available():
<ide> def prepare_config_and_inputs(self):
<ide>
<ide> input_mask = None
<ide> if self.use_input_mask:
<del> input_mask = ids_tensor([self.batch_size, self.seq_length], vocab_size=2)
<add> input_mask = random_attention_mask([self.batch_size, self.seq_length])
<ide>
<ide> sequence_labels = None
<ide> token_labels = None
<ide><path>tests/dpr/test_modeling_tf_dpr.py
<ide> from transformers.testing_utils import require_tf, slow
<ide>
<ide> from ..test_configuration_common import ConfigTester
<del>from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor
<add>from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
<ide>
<ide>
<ide> if is_tf_available():
<ide> def prepare_config_and_inputs(self):
<ide>
<ide> input_mask = None
<ide> if self.use_input_mask:
<del> input_mask = ids_tensor(
<del> [self.batch_size, self.seq_length], vocab_size=2
<del> ) # follow test_modeling_tf_ctrl.py
<add> # follow test_modeling_tf_ctrl.py
<add> input_mask = random_attention_mask([self.batch_size, self.seq_length])
<ide>
<ide> token_type_ids = None
<ide> if self.use_token_type_ids:
<ide><path>tests/electra/test_modeling_tf_electra.py
<ide> from transformers.testing_utils import require_tf, slow
<ide>
<ide> from ..test_configuration_common import ConfigTester
<del>from ..test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor
<add>from ..test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask
<ide>
<ide>
<ide> if is_tf_available():
<ide> def prepare_config_and_inputs(self):
<ide>
<ide> input_mask = None
<ide> if self.use_input_mask:
<del> input_mask = ids_tensor([self.batch_size, self.seq_length], vocab_size=2)
<add> input_mask = random_attention_mask([self.batch_size, self.seq_length])
<ide>
<ide> token_type_ids = None
<ide> if self.use_token_type_ids:
<ide><path>tests/flaubert/test_modeling_tf_flaubert.py
<ide> from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow
<ide>
<ide> from ..test_configuration_common import ConfigTester
<del>from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor
<add>from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
<ide>
<ide>
<ide> if is_tf_available():
<ide> def __init__(
<ide>
<ide> def prepare_config_and_inputs(self):
<ide> input_ids = ids_tensor([self.batch_size, self.seq_length], self.vocab_size)
<del> input_mask = ids_tensor([self.batch_size, self.seq_length], 2, dtype=tf.float32)
<add> input_mask = random_attention_mask([self.batch_size, self.seq_length], dtype=tf.float32)
<ide>
<ide> input_lengths = None
<ide> if self.use_input_lengths:
<ide><path>tests/funnel/test_modeling_tf_funnel.py
<ide> from transformers.testing_utils import require_tf
<ide>
<ide> from ..test_configuration_common import ConfigTester
<del>from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor
<add>from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
<ide>
<ide>
<ide> if is_tf_available():
<ide> def prepare_config_and_inputs(self):
<ide>
<ide> input_mask = None
<ide> if self.use_input_mask:
<del> input_mask = ids_tensor([self.batch_size, self.seq_length], vocab_size=2)
<add> input_mask = random_attention_mask([self.batch_size, self.seq_length])
<ide>
<ide> token_type_ids = None
<ide> if self.use_token_type_ids:
<ide><path>tests/gpt2/test_modeling_tf_gpt2.py
<ide> from transformers.testing_utils import require_tf, slow
<ide>
<ide> from ..test_configuration_common import ConfigTester
<del>from ..test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor
<add>from ..test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask
<ide> from ..utils.test_modeling_tf_core import TFCoreModelTesterMixin
<ide>
<ide>
<ide> def prepare_config_and_inputs(self):
<ide>
<ide> input_mask = None
<ide> if self.use_input_mask:
<del> input_mask = ids_tensor([self.batch_size, self.seq_length], vocab_size=2)
<add> input_mask = random_attention_mask([self.batch_size, self.seq_length])
<ide>
<ide> token_type_ids = None
<ide> if self.use_token_type_ids:
<ide><path>tests/gptj/test_modeling_tf_gptj.py
<ide> from transformers.testing_utils import require_tf, slow, tooslow
<ide>
<ide> from ..test_configuration_common import ConfigTester
<del>from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor
<add>from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
<ide> from ..utils.test_modeling_tf_core import TFCoreModelTesterMixin
<ide>
<ide>
<ide> def prepare_config_and_inputs(self):
<ide>
<ide> input_mask = None
<ide> if self.use_input_mask:
<del> input_mask = ids_tensor([self.batch_size, self.seq_length], vocab_size=2)
<add> input_mask = random_attention_mask([self.batch_size, self.seq_length])
<ide>
<ide> token_type_ids = None
<ide> if self.use_token_type_ids:
<ide><path>tests/layoutlm/test_modeling_tf_layoutlm.py
<ide> from transformers.testing_utils import require_tf, slow
<ide>
<ide> from ..test_configuration_common import ConfigTester
<del>from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor
<add>from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
<ide>
<ide>
<ide> if is_tf_available():
<ide> def prepare_config_and_inputs(self):
<ide>
<ide> input_mask = None
<ide> if self.use_input_mask:
<del> input_mask = ids_tensor([self.batch_size, self.seq_length], vocab_size=2)
<add> input_mask = random_attention_mask([self.batch_size, self.seq_length])
<ide>
<ide> token_type_ids = None
<ide> if self.use_token_type_ids:
<ide><path>tests/longformer/test_modeling_tf_longformer.py
<ide> from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow
<ide>
<ide> from ..test_configuration_common import ConfigTester
<del>from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor
<add>from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
<ide>
<ide>
<ide> if is_tf_available():
<ide> def prepare_config_and_inputs(self):
<ide>
<ide> input_mask = None
<ide> if self.use_input_mask:
<del> input_mask = ids_tensor([self.batch_size, self.seq_length], vocab_size=2)
<add> input_mask = random_attention_mask([self.batch_size, self.seq_length])
<ide>
<ide> token_type_ids = None
<ide> if self.use_token_type_ids:
<ide><path>tests/lxmert/test_modeling_tf_lxmert.py
<ide> from transformers.testing_utils import require_tf, slow
<ide>
<ide> from ..test_configuration_common import ConfigTester
<del>from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor
<add>from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
<ide>
<ide>
<ide> if is_tf_available():
<ide> def prepare_config_and_inputs(self):
<ide>
<ide> input_mask = None
<ide> if self.use_lang_mask:
<del> input_mask = ids_tensor([self.batch_size, self.seq_length], vocab_size=2)
<add> input_mask = random_attention_mask([self.batch_size, self.seq_length])
<ide> token_type_ids = None
<ide> if self.use_token_type_ids:
<ide> token_type_ids = ids_tensor([self.batch_size, self.seq_length], self.type_vocab_size)
<ide><path>tests/mobilebert/test_modeling_tf_mobilebert.py
<ide> from transformers.testing_utils import require_tf, slow
<ide>
<ide> from ..test_configuration_common import ConfigTester
<del>from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor
<add>from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
<ide>
<ide>
<ide> if is_tf_available():
<ide> def prepare_config_and_inputs(self):
<ide>
<ide> input_mask = None
<ide> if self.use_input_mask:
<del> input_mask = ids_tensor([self.batch_size, self.seq_length], vocab_size=2)
<add> input_mask = random_attention_mask([self.batch_size, self.seq_length])
<ide>
<ide> token_type_ids = None
<ide> if self.use_token_type_ids:
<ide><path>tests/mpnet/test_modeling_tf_mpnet.py
<ide> from transformers.testing_utils import require_tf, slow
<ide>
<ide> from ..test_configuration_common import ConfigTester
<del>from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor
<add>from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
<ide>
<ide>
<ide> if is_tf_available():
<ide> def prepare_config_and_inputs(self):
<ide>
<ide> input_mask = None
<ide> if self.use_input_mask:
<del> input_mask = ids_tensor([self.batch_size, self.seq_length], vocab_size=2)
<add> input_mask = random_attention_mask([self.batch_size, self.seq_length])
<ide>
<ide> sequence_labels = None
<ide> token_labels = None
<ide><path>tests/openai/test_modeling_tf_openai.py
<ide> from transformers.testing_utils import require_tf, slow
<ide>
<ide> from ..test_configuration_common import ConfigTester
<del>from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor
<add>from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
<ide>
<ide>
<ide> if is_tf_available():
<ide> def prepare_config_and_inputs(self):
<ide>
<ide> input_mask = None
<ide> if self.use_input_mask:
<del> input_mask = ids_tensor([self.batch_size, self.seq_length], vocab_size=2)
<add> input_mask = random_attention_mask([self.batch_size, self.seq_length])
<ide>
<ide> token_type_ids = None
<ide> if self.use_token_type_ids:
<ide><path>tests/rembert/test_modeling_tf_rembert.py
<ide> from transformers.testing_utils import require_tf, slow
<ide>
<ide> from ..test_configuration_common import ConfigTester
<del>from ..test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor
<add>from ..test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask
<ide>
<ide>
<ide> if is_tf_available():
<ide> def prepare_config_and_inputs(self):
<ide>
<ide> input_mask = None
<ide> if self.use_input_mask:
<del> input_mask = ids_tensor([self.batch_size, self.seq_length], vocab_size=2)
<add> input_mask = random_attention_mask([self.batch_size, self.seq_length])
<ide>
<ide> token_type_ids = None
<ide> if self.use_token_type_ids:
<ide><path>tests/roberta/test_modeling_tf_roberta.py
<ide> from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow
<ide>
<ide> from ..test_configuration_common import ConfigTester
<del>from ..test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor
<add>from ..test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask
<ide>
<ide>
<ide> if is_tf_available():
<ide> def prepare_config_and_inputs(self):
<ide>
<ide> input_mask = None
<ide> if self.use_input_mask:
<del> input_mask = ids_tensor([self.batch_size, self.seq_length], vocab_size=2)
<add> input_mask = random_attention_mask([self.batch_size, self.seq_length])
<ide>
<ide> token_type_ids = None
<ide> if self.use_token_type_ids:
<ide><path>tests/roformer/test_modeling_tf_roformer.py
<ide> from transformers.testing_utils import require_tf, slow
<ide>
<ide> from ..test_configuration_common import ConfigTester
<del>from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor
<add>from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
<ide>
<ide>
<ide> if is_tf_available():
<ide> def prepare_config_and_inputs(self):
<ide>
<ide> input_mask = None
<ide> if self.use_input_mask:
<del> input_mask = ids_tensor([self.batch_size, self.seq_length], vocab_size=2)
<add> input_mask = random_attention_mask([self.batch_size, self.seq_length])
<ide>
<ide> token_type_ids = None
<ide> if self.use_token_type_ids:
<ide><path>tests/t5/test_modeling_tf_t5.py
<ide> from transformers.utils import cached_property
<ide>
<ide> from ..test_configuration_common import ConfigTester
<del>from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor
<add>from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
<ide>
<ide>
<ide> if is_tf_available():
<ide> def prepare_config_and_inputs(self):
<ide>
<ide> input_mask = None
<ide> if self.use_input_mask:
<del> input_mask = ids_tensor([self.batch_size, self.seq_length], vocab_size=2)
<add> input_mask = random_attention_mask([self.batch_size, self.seq_length])
<ide>
<ide> token_labels = None
<ide> if self.use_labels:
<ide><path>tests/tapas/test_modeling_tf_tapas.py
<ide> from transformers.utils import cached_property
<ide>
<ide> from ..test_configuration_common import ConfigTester
<del>from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor
<add>from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
<ide>
<ide>
<ide> if is_tf_available():
<ide> def prepare_config_and_inputs(self):
<ide>
<ide> input_mask = None
<ide> if self.use_input_mask:
<del> input_mask = ids_tensor([self.batch_size, self.seq_length], vocab_size=2)
<add> input_mask = random_attention_mask([self.batch_size, self.seq_length])
<ide>
<ide> token_type_ids = []
<ide> for type_vocab_size in self.type_vocab_sizes:
<ide><path>tests/test_modeling_tf_common.py
<ide> def ids_tensor(shape, vocab_size, rng=None, name=None, dtype=None):
<ide> def random_attention_mask(shape, rng=None, name=None, dtype=None):
<ide> attn_mask = ids_tensor(shape, vocab_size=2, rng=None, name=None, dtype=dtype)
<ide> # make sure that at least one token is attended to for each batch
<del> attn_mask = tf.concat([tf.constant(value=1, shape=(shape[0], 1), dtype=dtype), attn_mask[:, 1:]], axis=1)
<add> attn_mask = tf.concat([attn_mask[:, :-1], tf.ones_like(attn_mask[:, -1:], dtype=dtype)], axis=-1)
<ide> return attn_mask
<ide>
<ide>
<ide><path>tests/xlm/test_modeling_tf_xlm.py
<ide> from transformers.testing_utils import require_tf, slow
<ide>
<ide> from ..test_configuration_common import ConfigTester
<del>from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor
<add>from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
<ide>
<ide>
<ide> if is_tf_available():
<ide> def __init__(
<ide>
<ide> def prepare_config_and_inputs(self):
<ide> input_ids = ids_tensor([self.batch_size, self.seq_length], self.vocab_size)
<del> input_mask = ids_tensor([self.batch_size, self.seq_length], 2, dtype=tf.float32)
<add> input_mask = random_attention_mask([self.batch_size, self.seq_length], dtype=tf.float32)
<ide>
<ide> input_lengths = None
<ide> if self.use_input_lengths:
<ide><path>tests/xlnet/test_modeling_tf_xlnet.py
<ide> from transformers.testing_utils import require_tf, slow
<ide>
<ide> from ..test_configuration_common import ConfigTester
<del>from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor
<add>from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
<ide>
<ide>
<ide> if is_tf_available():
<ide> def prepare_config_and_inputs(self):
<ide> input_ids_1 = ids_tensor([self.batch_size, self.seq_length], self.vocab_size)
<ide> input_ids_2 = ids_tensor([self.batch_size, self.seq_length], self.vocab_size)
<ide> segment_ids = ids_tensor([self.batch_size, self.seq_length], self.type_vocab_size)
<del> input_mask = ids_tensor([self.batch_size, self.seq_length], 2, dtype=tf.float32)
<add> input_mask = random_attention_mask([self.batch_size, self.seq_length], dtype=tf.float32)
<ide>
<ide> input_ids_q = ids_tensor([self.batch_size, self.seq_length + 1], self.vocab_size)
<ide> perm_mask = tf.zeros((self.batch_size, self.seq_length + 1, self.seq_length), dtype=tf.float32) | 29 |
Text | Text | change command_task.rb to commands_task.rb in docs | ac1427d6ca8afbf2cd4245f994084b30ed256581 | <ide><path>guides/source/initialization.md
<ide> snippet.
<ide> If we had used `s` rather than `server`, Rails would have used the `aliases`
<ide> defined here to find the matching command.
<ide>
<del>### `rails/commands/command_tasks.rb`
<add>### `rails/commands/commands_tasks.rb`
<ide>
<ide> When one types a valid Rails command, `run_command!` a method of the same name
<ide> is called. If Rails doesn't recognize the command, it tries to run a Rake task | 1 |
Ruby | Ruby | fix deprecate! and disable! message | e7cf1f4497431ed80dfefb3cb2c8082c66365b20 | <ide><path>Library/Homebrew/formula_installer.rb
<ide> def check_install_sanity
<ide> reason = if deprecate_disable_reasons.key? formula.deprecation_reason
<ide> deprecate_disable_reasons[formula.deprecation_reason]
<ide> else
<del> deprecate_disable_reasons
<add> formula.deprecation_reason
<ide> end
<ide>
<ide> opoo "#{formula.full_name} has been deprecated because it #{reason}!"
<ide> def check_install_sanity
<ide> reason = if deprecate_disable_reasons.key? formula.disable_reason
<ide> deprecate_disable_reasons[formula.disable_reason]
<ide> else
<del> deprecate_disable_reasons
<add> formula.disable_reason
<ide> end
<ide>
<ide> odie "#{formula.full_name} has been disabled because it #{reason}!" | 1 |
Text | Text | add 3.2.0 to changelog | 5154db427be5cbc722600b5344eb1802ebd2e3b4 | <ide><path>CHANGELOG.md
<ide> # Ember Changelog
<ide>
<del>### v3.2.0-beta.5 (May 14, 2018)
<del>- [#16613](https://github.com/emberjs/ember.js/pull/16613) [BUGFIX] Prevent errors in ember-engines + 3.1 + proxies.
<add>### v3.2.0 (May 31, 2018)
<ide>
<del>### v3.2.0-beta.4 (May 7, 2018)
<add>- [#16613](https://github.com/emberjs/ember.js/pull/16613) [BUGFIX] Prevent errors in ember-engines + 3.1 + proxies.
<ide> - [#16597](https://github.com/emberjs/ember.js/pull/16597) [BUGFIX] Ensure `Ember.run.cancelTimers` is present.
<ide> - [#16605](https://github.com/emberjs/ember.js/pull/16605) [BUGFIX] Use resetCache on container destroy
<ide> - [#16615](https://github.com/emberjs/ember.js/pull/16615) [BUGFIX] Fix NAMESPACES_BY_ID leaks
<del>
<del>### v3.2.0-beta.3 (April 23, 2018)
<ide> - [#16539](https://github.com/emberjs/ember.js/pull/16539) [BUGFIX] Ember is already registered by the libraries registry already.
<ide> - [#16559](https://github.com/emberjs/ember.js/pull/16559) [BUGFIX] Fix property normalization, Update glimmer-vm to 0.34.0
<ide> - [#16563](https://github.com/emberjs/ember.js/pull/16563) [BUGFIX] Ensure `ariaRole` can be initially false.
<ide> - [#16560](https://github.com/emberjs/ember.js/pull/16560) [BUGFIX] avoid strict assertion when object proxy calls thru for function
<ide> - [#16564](https://github.com/emberjs/ember.js/pull/16564) [BUGFIX] Ensure Ember.isArray does not trigger proxy assertion.
<ide> - [#16572](https://github.com/emberjs/ember.js/pull/16572) [BUGFIX] Fix curly component class reference setup
<del>
<del>### v3.2.0-beta.2 (April 16, 2018)
<del>
<ide> - [#16493](https://github.com/emberjs/ember.js/pull/16493) [BUGFIX] Ensure proxies have access to `getOwner(this)`.
<ide> - [#16494](https://github.com/emberjs/ember.js/pull/16494) [BUGFIX] Adjust assertion to allow for either undefined or null
<ide> - [#16499](https://github.com/emberjs/ember.js/pull/16499) [BUGFIX] Object to string serialization
<ide> - [#16514](https://github.com/emberjs/ember.js/pull/16514) [BUGFIX] Bring back (with deprecation) Ember.EXTEND_PROTOTYPES.
<ide> - [#16520](https://github.com/emberjs/ember.js/pull/16520) [BUGFIX] Adds options checking ability to debug/deprecation test helpers
<ide> - [#16526](https://github.com/emberjs/ember.js/pull/16526) [BUGFIX] Ensure setting a `NAME_KEY` does not error.
<ide> - [#16527](https://github.com/emberjs/ember.js/pull/16527) [BUGFIX] Update glimmer-vm to 0.33.5.
<del>
<del>### v3.2.0-beta.1 (April 10, 2018)
<del>
<ide> - [#16250](https://github.com/emberjs/ember.js/pull/16250) [DEPRECATION] Deprecation of `Ember.Logger`
<ide> - [#16436](https://github.com/emberjs/ember.js/pull/16436) [BUGFIX] Refactor `CoreObject` to leverage native JS semantics.
<ide> - [#16382](https://github.com/emberjs/ember.js/pull/16382) Upgrade `backburner.js` to 2.2.2. | 1 |
Python | Python | fix syntax error | f3b7c5e5371acbd0a2126fee4dbb791845c44ebb | <ide><path>spacy/language.py
<ide> def __call__(self, text, disable=[]):
<ide> "the parser or NER, it's probably safe to increase the "
<ide> "nlp.max_length limit. The limit is in number of characters, "
<ide> "so you can check whether your inputs are too long by checking "
<del> "len(text)".)
<add> "len(text).")
<ide> raise ValueError(msg.format(length=len(text), max_length=self.max_length))
<ide> doc = self.make_doc(text)
<ide> for name, proc in self.pipeline: | 1 |
Ruby | Ruby | remove parent on transaction object | dac9c92e3096ae196d7ea4b58e7141f4a36007ea | <ide><path>activerecord/lib/active_record/connection_adapters/abstract/transaction.rb
<ide> def initialize(connection)
<ide>
<ide> def begin_transaction(options = {})
<ide> transaction_class = @stack.empty? ? RealTransaction : SavepointTransaction
<del> transaction = transaction_class.new(@connection, current_transaction, "active_record_#{@stack.size}", options)
<add> transaction = transaction_class.new(@connection, "active_record_#{@stack.size}", options)
<ide>
<ide> @stack.push(transaction)
<ide> transaction
<ide> def closed_transaction
<ide> end
<ide>
<ide> class Transaction #:nodoc:
<del> attr_reader :connection
<add> attr_reader :connection, :state
<ide>
<ide> def initialize(connection)
<ide> @connection = connection
<ide> @state = TransactionState.new
<ide> end
<ide>
<del> def state
<del> @state
<del> end
<del>
<ide> def savepoint_name
<ide> nil
<ide> end
<ide> def add_record(record)
<ide> end
<ide>
<ide> class OpenTransaction < Transaction #:nodoc:
<del> attr_reader :parent, :records
<add> attr_reader :records
<ide> attr_writer :joinable
<ide>
<del> def initialize(connection, parent, options = {})
<add> def initialize(connection, options = {})
<ide> super connection
<ide>
<del> @parent = parent
<ide> @records = []
<ide> @joinable = options.fetch(:joinable, true)
<ide> end
<ide> def joinable?
<ide>
<ide> def rollback
<ide> perform_rollback
<del> parent
<ide> end
<ide>
<ide> def commit
<ide> perform_commit
<del> parent
<ide> end
<ide>
<ide> def add_record(record)
<ide> def rollback_records
<ide> @state.set_state(:rolledback)
<ide> records.uniq.each do |record|
<ide> begin
<del> record.rolledback!(parent.closed?)
<add> record.rolledback!(self.is_a?(RealTransaction))
<ide> rescue => e
<ide> record.logger.error(e) if record.respond_to?(:logger) && record.logger
<ide> end
<ide> def open?
<ide> end
<ide>
<ide> class RealTransaction < OpenTransaction #:nodoc:
<del> def initialize(connection, parent, _, options = {})
<del> super(connection, parent, options)
<add> def initialize(connection, _, options = {})
<add> super(connection, options)
<ide>
<ide> if options[:isolation]
<ide> connection.begin_isolated_db_transaction(options[:isolation])
<ide> def perform_commit
<ide> class SavepointTransaction < OpenTransaction #:nodoc:
<ide> attr_reader :savepoint_name
<ide>
<del> def initialize(connection, parent, savepoint_name, options = {})
<add> def initialize(connection, savepoint_name, options = {})
<ide> if options[:isolation]
<ide> raise ActiveRecord::TransactionIsolationError, "cannot set transaction isolation in a nested transaction"
<ide> end
<ide>
<del> super(connection, parent, options)
<add> super(connection, options)
<ide> connection.create_savepoint(@savepoint_name = savepoint_name)
<ide> end
<ide> | 1 |
Python | Python | fix docstrings for loading with docfilesuite | b860a39925a5e0a49d54fa363ccdf6113dfef12d | <ide><path>numpy/core/numerictypes.py
<ide> 'ScalarType', 'obj2sctype', 'cast', 'nbytes', 'sctype2char',
<ide> 'maximum_sctype', 'issctype', 'typecodes']
<ide>
<del>from multiarray import typeinfo, ndarray, array, empty, dtype
<add>from numpy.core.multiarray import typeinfo, ndarray, array, empty, dtype
<ide> import types as _types
<ide>
<ide> # we don't export these for import *, but we do want them accessible
<ide><path>numpy/distutils/ccompiler.py
<ide> from distutils.sysconfig import customize_compiler
<ide> from distutils.version import LooseVersion
<ide>
<del>import log
<del>from exec_command import exec_command
<del>from misc_util import cyg2win32, is_sequence, mingw32
<add>from numpy.distutils import log
<add>from numpy.distutils.exec_command import exec_command
<add>from numpy.distutils.misc_util import cyg2win32, is_sequence, mingw32
<ide> from distutils.spawn import _nt_quote_args
<ide>
<ide> # hack to set compiler optimizing options. Needs to integrated with something.
<ide><path>numpy/lib/function_base.py
<ide> def histogramdd(sample, bins=10, range=None, normed=False):
<ide> H, edges = histogramdd(x, bins = (5, 6, 7))
<ide>
<ide> See also: histogram
<add>
<ide> """
<ide>
<ide> try:
<ide> def average(a, axis=None, weights=None, returned=False):
<ide>
<ide> Raises ZeroDivisionError if appropriate. (The version in MA does
<ide> not -- it returns masked values).
<add>
<ide> """
<ide> if axis is None:
<ide> a = array(a).ravel()
<ide> def piecewise(x, condlist, funclist, *args, **kw):
<ide>
<ide> def select(condlist, choicelist, default=0):
<ide> """ Return an array composed of different elements of choicelist
<del> depending on the list of conditions.
<del>
<del> condlist is a list of condition arrays containing ones or zeros
<del>
<del> choicelist is a list of choice arrays (of the "same" size as the
<del> arrays in condlist). The result array has the "same" size as the
<del> arrays in choicelist. If condlist is [c0, ..., cN-1] then choicelist
<del> must be of length N. The elements of the choicelist can then be
<del> represented as [v0, ..., vN-1]. The default choice if none of the
<del> conditions are met is given as the default argument.
<del>
<del> The conditions are tested in order and the first one statisfied is
<del> used to select the choice. In other words, the elements of the
<del> output array are found from the following tree (notice the order of
<del> the conditions matters):
<del>
<del> if c0: v0
<del> elif c1: v1
<del> elif c2: v2
<del> ...
<del> elif cN-1: vN-1
<del> else: default
<del>
<del> Note that one of the condition arrays must be large enough to handle
<del> the largest array in the choice list.
<add> depending on the list of conditions.
<add>
<add> condlist is a list of condition arrays containing ones or zeros
<add>
<add> choicelist is a list of choice arrays (of the "same" size as the
<add> arrays in condlist). The result array has the "same" size as the
<add> arrays in choicelist. If condlist is [c0, ..., cN-1] then choicelist
<add> must be of length N. The elements of the choicelist can then be
<add> represented as [v0, ..., vN-1]. The default choice if none of the
<add> conditions are met is given as the default argument.
<add>
<add> The conditions are tested in order and the first one statisfied is
<add> used to select the choice. In other words, the elements of the
<add> output array are found from the following tree (notice the order of
<add> the conditions matters):
<add>
<add> if c0: v0
<add> elif c1: v1
<add> elif c2: v2
<add> ...
<add> elif cN-1: vN-1
<add> else: default
<add>
<add> Note that one of the condition arrays must be large enough to handle
<add> the largest array in the choice list.
<add>
<ide> """
<ide> n = len(condlist)
<ide> n2 = len(choicelist)
<ide> def gradient(f, *varargs):
<ide> Outputs:
<ide>
<ide> N arrays of the same shape as f giving the derivative of f with respect
<del> to each dimension.
<add> to each dimension.
<add>
<ide> """
<ide> N = len(f.shape) # number of dimensions
<ide> n = len(varargs)
<ide> def diff(a, n=1, axis=-1):
<ide> bins is monotonically decreasing.
<ide>
<ide> Beyond the bounds of the bins 0 or len(bins) is returned as appropriate.
<add>
<ide> """)
<ide> except RuntimeError:
<ide> pass
<ide> def diff(a, n=1, axis=-1):
<ide> weights[p] instead of 1.
<ide>
<ide> See also: histogram, digitize, unique.
<add>
<ide> """)
<ide> except RuntimeError:
<ide> pass
<ide> def diff(a, n=1, axis=-1):
<ide> If the obj already has a docstring raise a RuntimeError
<ide> If this routine does not know how to add a docstring to the object
<ide> raise a TypeError
<add>
<ide> """)
<ide> except RuntimeError:
<ide> pass
<ide> def sort_complex(a):
<ide> the imaginary part if the real part is equal (the default sort order
<ide> for complex arrays). This function is a wrapper ensuring a complex
<ide> return type.
<add>
<ide> """
<ide> b = array(a,copy=True)
<ide> b.sort()
<ide> def trim_zeros(filt, trim='fb'):
<ide> >>> a = array((0, 0, 0, 1, 2, 3, 2, 1, 0))
<ide> >>> numpy.trim_zeros(a)
<ide> array([1, 2, 3, 2, 1])
<add>
<ide> """
<ide> first = 0
<ide> trim = trim.upper()
<ide> def unique(x):
<ide> Example:
<ide> >>> unique([5,2,4,0,4,4,2,2,1])
<ide> array([0,1,2,4,5])
<add>
<ide> """
<ide> try:
<ide> tmp = x.flatten()
<ide> def place(arr, mask, vals):
<ide> """Similar to putmask arr[mask] = vals but the 1D array vals has the
<ide> same number of elements as the non-zero values of mask. Inverse of
<ide> extract.
<add>
<ide> """
<ide> return _insert(arr, mask, vals)
<ide>
<ide><path>numpy/lib/index_tricks.py
<ide> class nd_grid(object):
<ide> >>> ogrid = nd_grid(sparse=True)
<ide> >>> ogrid[0:5,0:5]
<ide> [array([[0],[1],[2],[3],[4]]), array([[0, 1, 2, 3, 4]])]
<add>
<ide> """
<ide> def __init__(self, sparse=False):
<ide> self.sparse = sparse
<ide> class r_class(concatenator):
<ide> For example:
<ide> >>> r_[array([1,2,3]), 0, 0, array([4,5,6])]
<ide> array([1, 2, 3, 0, 0, 4, 5, 6])
<add>
<ide> """
<ide> def __init__(self):
<ide> concatenator.__init__(self, 0)
<ide><path>numpy/lib/polynomial.py
<ide> def _lstsq(X, y, rcond):
<ide> def poly(seq_of_zeros):
<ide> """ Return a sequence representing a polynomial given a sequence of roots.
<ide>
<del> If the input is a matrix, return the characteristic polynomial.
<del>
<del> Example:
<del>
<del> >>> b = roots([1,3,1,5,6])
<del> >>> poly(b)
<del> array([1., 3., 1., 5., 6.])
<add> If the input is a matrix, return the characteristic polynomial.
<add>
<add> Example:
<add>
<add> >>> b = roots([1,3,1,5,6])
<add> >>> poly(b)
<add> array([1., 3., 1., 5., 6.])
<add>
<ide> """
<ide> seq_of_zeros = atleast_1d(seq_of_zeros)
<ide> sh = seq_of_zeros.shape
<ide><path>numpy/lib/shape_base.py
<ide> def column_stack(tup):
<ide> def dstack(tup):
<ide> """ Stack arrays in sequence depth wise (along third dimension)
<ide>
<del> Description:
<del> Take a sequence of arrays and stack them along the third axis.
<del> All arrays in the sequence must have the same shape along all
<del> but the third axis. This is a simple way to stack 2D arrays
<del> (images) into a single 3D array for processing.
<del> dstack will rebuild arrays divided by dsplit.
<del> Arguments:
<del> tup -- sequence of arrays. All arrays must have the same
<del> shape.
<del> Examples:
<del> >>> import numpy
<del> >>> a = array((1,2,3))
<del> >>> b = array((2,3,4))
<del> >>> numpy.dstack((a,b))
<del> array([ [[1, 2],
<del> [2, 3],
<del> [3, 4]]])
<del> >>> a = array([[1],[2],[3]])
<del> >>> b = array([[2],[3],[4]])
<del> >>> numpy.dstack((a,b))
<del> array([[ [1, 2]],
<del> [ [2, 3]],
<del> [ [3, 4]]])
<add> Description:
<add> Take a sequence of arrays and stack them along the third axis.
<add> All arrays in the sequence must have the same shape along all
<add> but the third axis. This is a simple way to stack 2D arrays
<add> (images) into a single 3D array for processing.
<add> dstack will rebuild arrays divided by dsplit.
<add> Arguments:
<add> tup -- sequence of arrays. All arrays must have the same
<add> shape.
<add> Examples:
<add> >>> import numpy
<add> >>> a = array((1,2,3))
<add> >>> b = array((2,3,4))
<add> >>> numpy.dstack((a,b))
<add> array([ [[1, 2],
<add> [2, 3],
<add> [3, 4]]])
<add> >>> a = array([[1],[2],[3]])
<add> >>> b = array([[2],[3],[4]])
<add> >>> numpy.dstack((a,b))
<add> array([[ [1, 2]],
<add> [ [2, 3]],
<add> [ [3, 4]]])
<add>
<ide> """
<ide> return _nx.concatenate(map(atleast_3d,tup),2)
<ide> | 6 |
Javascript | Javascript | add connectcontrollers convenience | 396c08b1322f4b642a65005cc89cdd7bb8acce06 | <ide><path>packages/ember-views/lib/system/controller.js
<ide> Ember.ControllerMixin.reopen({
<ide> set(this, outletName, view);
<ide>
<ide> return view;
<add> },
<add>
<add> /**
<add> Convenience method to connect controllers. This method makes other controllers
<add> available on the controller the method was invoked on.
<add>
<add> For example, to make the `personController` and the `postController` available
<add> on the `overviewController`, you would call:
<add>
<add> overviewController.connectControllers('person', 'post');
<add>
<add> @param {String...} controllerNames the controllers to make available
<add> */
<add> connectControllers: function() {
<add> var controllers = get(this, 'controllers'),
<add> controllerNames = Array.prototype.slice.apply(arguments),
<add> controllerName;
<add>
<add> for (var i=0, l=controllerNames.length; i<l; i++) {
<add> controllerName = controllerNames[i] + 'Controller';
<add> set(this, controllerName, get(controllers, controllerName));
<add> }
<ide> }
<ide> });
<ide>
<ide><path>packages/ember-views/tests/system/controller_test.js
<ide> test("if the controller is not given while connecting an outlet, the instantiate
<ide> equal(view.get('controller'), postController, "the controller was inherited from the parent");
<ide> });
<ide>
<add>
<add>test("connectControllers injects other controllers", function() {
<add> var postController = {}, commentController = {};
<add>
<add> var controller = Ember.Controller.create({
<add> controllers: {
<add> postController: postController,
<add> commentController: commentController
<add> }
<add> });
<add>
<add> controller.connectControllers('post', 'comment');
<add>
<add> equal(controller.get('postController'), postController, "should connect postController");
<add> equal(controller.get('commentController'), commentController, "should connect commentController");
<add>}); | 2 |
Ruby | Ruby | remove xquartz handling | 4836ea0ba2119619697af87edf5fdb2280e90238 | <ide><path>Library/Homebrew/cask/exceptions.rb
<ide> def to_s
<ide> end
<ide> end
<ide>
<del> # Error when a cask depends on X11.
<del> #
<del> # @api private
<del> class CaskX11DependencyError < AbstractCaskErrorWithToken
<del> extend T::Sig
<del>
<del> sig { returns(String) }
<del> def to_s
<del> <<~EOS
<del> Cask '#{token}' requires XQuartz/X11, which can be installed using Homebrew Cask by running:
<del> #{Formatter.identifier("brew install --cask xquartz")}
<del>
<del> or manually, by downloading the package from:
<del> #{Formatter.url("https://www.xquartz.org/")}
<del> EOS
<del> end
<del> end
<del>
<ide> # Error when there is a cyclic cask dependency.
<ide> #
<ide> # @api private
<ide><path>Library/Homebrew/extend/ENV/super.rb
<ide> module Superenv
<ide> include SharedEnvExtension
<ide>
<ide> # @private
<del> attr_accessor :keg_only_deps, :deps, :run_time_deps, :x11
<add> attr_accessor :keg_only_deps, :deps, :run_time_deps
<ide>
<ide> sig { params(base: Superenv).void }
<ide> def self.extended(base)
<ide> def determine_pkg_config_libdir
<ide> ).existing
<ide> end
<ide>
<del> sig { returns(T::Array[Pathname]) }
<del> def homebrew_extra_aclocal_paths
<del> []
<del> end
<del>
<ide> sig { returns(T.nilable(PATH)) }
<ide> def determine_aclocal_path
<ide> PATH.new(
<ide> keg_only_deps.map { |d| d.opt_share/"aclocal" },
<ide> HOMEBREW_PREFIX/"share/aclocal",
<del> homebrew_extra_aclocal_paths,
<ide> ).existing
<ide> end
<ide>
<ide><path>Library/Homebrew/extend/os/mac/diagnostic.rb
<ide> def check_xcode_license_approved
<ide> EOS
<ide> end
<ide>
<del> def check_xquartz_up_to_date
<del> return unless MacOS::XQuartz.outdated?
<del>
<del> <<~EOS
<del> Your XQuartz (#{MacOS::XQuartz.version}) is outdated.
<del> Please install XQuartz #{MacOS::XQuartz.latest_version} (or delete the current version).
<del> XQuartz can be updated using Homebrew Cask by running:
<del> brew reinstall xquartz
<del> EOS
<del> end
<del>
<ide> def check_filesystem_case_sensitive
<ide> dirs_to_check = [
<ide> HOMEBREW_PREFIX,
<ide><path>Library/Homebrew/extend/os/mac/extend/ENV/super.rb
<ide> def bin
<ide> end
<ide> end
<ide>
<del> alias x11? x11
<del>
<del> undef homebrew_extra_paths,
<del> homebrew_extra_pkg_config_paths, homebrew_extra_aclocal_paths,
<add> undef homebrew_extra_pkg_config_paths,
<ide> homebrew_extra_isystem_paths, homebrew_extra_library_paths,
<ide> homebrew_extra_cmake_include_paths,
<ide> homebrew_extra_cmake_library_paths,
<ide> homebrew_extra_cmake_frameworks_paths,
<ide> determine_cccfg
<ide>
<del> def homebrew_extra_paths
<del> paths = []
<del> paths << MacOS::XQuartz.bin if x11?
<del> paths
<del> end
<del>
<ide> # @private
<ide> def homebrew_extra_pkg_config_paths
<del> paths = \
<del> ["/usr/lib/pkgconfig", "#{HOMEBREW_LIBRARY}/Homebrew/os/mac/pkgconfig/#{MacOS.version}"]
<del> paths << "#{MacOS::XQuartz.lib}/pkgconfig" << "#{MacOS::XQuartz.share}/pkgconfig" if x11?
<del> paths
<del> end
<del>
<del> def homebrew_extra_aclocal_paths
<del> paths = []
<del> paths << "#{MacOS::XQuartz.share}/aclocal" if x11?
<del> paths
<add> ["/usr/lib/pkgconfig", "#{HOMEBREW_LIBRARY}/Homebrew/os/mac/pkgconfig/#{MacOS.version}"]
<ide> end
<ide>
<ide> # @private
<ide> def homebrew_extra_isystem_paths
<ide> paths = []
<ide> paths << "#{self["HOMEBREW_SDKROOT"]}/usr/include/libxml2" if libxml2_include_needed?
<ide> paths << "#{self["HOMEBREW_SDKROOT"]}/usr/include/apache2" if MacOS::Xcode.without_clt?
<del> paths << MacOS::XQuartz.include.to_s << "#{MacOS::XQuartz.include}/freetype2" if x11?
<ide> paths << "#{self["HOMEBREW_SDKROOT"]}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers"
<ide> paths
<ide> end
<ide> def homebrew_extra_library_paths
<ide> paths << "#{self["HOMEBREW_SDKROOT"]}/usr/lib"
<ide> paths << Formula["llvm"].opt_lib.to_s
<ide> end
<del> paths << MacOS::XQuartz.lib.to_s if x11?
<ide> paths << "#{self["HOMEBREW_SDKROOT"]}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Libraries"
<ide> paths
<ide> end
<ide> def homebrew_extra_cmake_include_paths
<ide> paths = []
<ide> paths << "#{self["HOMEBREW_SDKROOT"]}/usr/include/libxml2" if libxml2_include_needed?
<ide> paths << "#{self["HOMEBREW_SDKROOT"]}/usr/include/apache2" if MacOS::Xcode.without_clt?
<del> paths << MacOS::XQuartz.include.to_s << "#{MacOS::XQuartz.include}/freetype2" if x11?
<ide> paths << "#{self["HOMEBREW_SDKROOT"]}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers"
<ide> paths
<ide> end
<ide>
<ide> def homebrew_extra_cmake_library_paths
<del> paths = []
<del> paths << MacOS::XQuartz.lib.to_s if x11?
<del> paths << "#{self["HOMEBREW_SDKROOT"]}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Libraries"
<del> paths
<add> ["#{self["HOMEBREW_SDKROOT"]}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Libraries"]
<ide> end
<ide>
<ide> def homebrew_extra_cmake_frameworks_paths
<ide><path>Library/Homebrew/extend/os/mac/system_config.rb
<ide> def clt
<ide> @clt ||= MacOS::CLT.version if MacOS::CLT.installed?
<ide> end
<ide>
<del> def xquartz
<del> @xquartz ||= "#{MacOS::XQuartz.version} => #{describe_path(MacOS::XQuartz.prefix)}" if MacOS::XQuartz.installed?
<del> end
<del>
<ide> def dump_verbose_config(f = $stdout)
<ide> dump_generic_verbose_config(f)
<ide> f.puts "macOS: #{MacOS.full_version}-#{kernel}"
<ide> f.puts "CLT: #{clt || "N/A"}"
<ide> f.puts "Xcode: #{xcode || "N/A"}"
<del> f.puts "XQuartz: #{xquartz}" if xquartz
<ide> f.puts "Rosetta 2: #{Hardware::CPU.in_rosetta2?}" if Hardware::CPU.physical_cpu_arm64?
<ide> end
<ide> end
<ide><path>Library/Homebrew/os/mac.rb
<ide>
<ide> require "os/mac/version"
<ide> require "os/mac/xcode"
<del>require "os/mac/xquartz"
<ide> require "os/mac/sdk"
<ide> require "os/mac/keg"
<ide>
<ide><path>Library/Homebrew/os/mac/xquartz.rb
<del># typed: true
<del># frozen_string_literal: true
<del>
<del>module OS
<del> module Mac
<del> # Helper module for querying XQuartz information.
<del> #
<del> # @api private
<del> module XQuartz
<del> extend T::Sig
<del>
<del> module_function
<del>
<del> DEFAULT_BUNDLE_PATH = Pathname("/Applications/Utilities/XQuartz.app").freeze
<del> NEW_BUNDLE_PKG_ID = "org.xquartz.X11"
<del> FORGE_BUNDLE_ID = "org.macosforge.xquartz.X11"
<del> FORGE_PKG_ID = "org.macosforge.xquartz.pkg"
<del>
<del> PKGINFO_VERSION_MAP = {
<del> "2.6.34" => "2.6.3",
<del> "2.7.4" => "2.7.0",
<del> "2.7.14" => "2.7.1",
<del> "2.7.28" => "2.7.2",
<del> "2.7.32" => "2.7.3",
<del> "2.7.43" => "2.7.4",
<del> "2.7.50" => "2.7.5_rc1",
<del> "2.7.51" => "2.7.5_rc2",
<del> "2.7.52" => "2.7.5_rc3",
<del> "2.7.53" => "2.7.5_rc4",
<del> "2.7.54" => "2.7.5",
<del> "2.7.61" => "2.7.6",
<del> "2.7.73" => "2.7.7",
<del> "2.7.86" => "2.7.8",
<del> "2.7.94" => "2.7.9",
<del> "2.7.108" => "2.7.10",
<del> "2.7.112" => "2.7.11",
<del> }.freeze
<del>
<del> # This returns the version number of XQuartz, not of the upstream X.org.
<del> # The X11.app distributed by Apple is also XQuartz, and therefore covered
<del> # by this method.
<del> def version
<del> if @version ||= detect_version
<del> ::Version.new @version
<del> else
<del> ::Version::NULL
<del> end
<del> end
<del>
<del> def detect_version
<del> if (path = bundle_path) && path.exist? && (version = version_from_mdls(path))
<del> version
<del> else
<del> version_from_pkgutil
<del> end
<del> end
<del>
<del> sig { returns(String) }
<del> def minimum_version
<del> # Update this a little later than latest_version to give people
<del> # time to upgrade.
<del> "2.7.11"
<del> end
<del>
<del> # @see https://www.xquartz.org/releases/index.html
<del> sig { returns(String) }
<del> def latest_version
<del> "2.7.11"
<del> end
<del>
<del> def bundle_path
<del> # Use the default location if it exists.
<del> return DEFAULT_BUNDLE_PATH if DEFAULT_BUNDLE_PATH.exist?
<del>
<del> # Ask Spotlight where XQuartz is. If the user didn't install XQuartz
<del> # in the conventional place, this is our only option.
<del> MacOS.app_with_bundle_id(NEW_BUNDLE_PKG_ID, FORGE_BUNDLE_ID)
<del> end
<del>
<del> def version_from_mdls(path)
<del> version = Utils.popen_read(
<del> "/usr/bin/mdls", "-raw", "-nullMarker", "", "-name", "kMDItemVersion", path.to_s
<del> ).strip
<del> version unless version.empty?
<del> end
<del>
<del> # Upstream XQuartz *does* have a pkg-info entry, so if we can't get it
<del> # from mdls, we can try pkgutil. This is very slow.
<del> def version_from_pkgutil
<del> [NEW_BUNDLE_PKG_ID, FORGE_PKG_ID].each do |id|
<del> str = MacOS.pkgutil_info(id)[/version: (\d\.\d\.\d+)$/, 1]
<del> return PKGINFO_VERSION_MAP.fetch(str, str) if str
<del> end
<del>
<del> nil
<del> end
<del>
<del> def prefix
<del> @prefix ||= Pathname.new("/opt/X11") if Pathname.new("/opt/X11/lib/libpng.dylib").exist?
<del> end
<del>
<del> def installed?
<del> !version.null? && !prefix.nil?
<del> end
<del>
<del> def outdated?
<del> return false unless installed?
<del>
<del> version < latest_version
<del> end
<del>
<del> def bin
<del> prefix/"bin"
<del> end
<del>
<del> def include
<del> prefix/"include"
<del> end
<del>
<del> def lib
<del> prefix/"lib"
<del> end
<del>
<del> def share
<del> prefix/"share"
<del> end
<del> end
<del> end
<del>end
<ide><path>Library/Homebrew/rubocops/lines.rb
<ide> def audit_formula(_node, _class_node, _parent_class_node, _body_node)
<ide> "# if this fails, try separate make/make install steps",
<ide> "# The URL of the archive",
<ide> "## Naming --",
<del> "# if your formula requires any X11/XQuartz components",
<ide> "# if your formula fails when building in parallel",
<ide> "# Remove unrecognized options if warned by configure",
<ide> '# system "cmake',
<ide><path>Library/Homebrew/test/cask/dsl_spec.rb
<ide> def caveats
<ide> end
<ide> end
<ide>
<del> describe "depends_on x11" do
<del> context "with invalid depends_on x11 value" do
<del> let(:token) { "invalid/invalid-depends-on-x11-value" }
<del>
<del> it "refuses to load" do
<del> expect { cask }.to raise_error(Cask::CaskInvalidError)
<del> end
<del> end
<del> end
<del>
<ide> describe "conflicts_with stanza" do
<ide> context "when valid" do
<ide> let(:token) { "with-conflicts-with" }
<ide><path>Library/Homebrew/test/cask/installer_spec.rb
<ide> describe Cask::Installer, :cask do
<ide> describe "install" do
<ide> let(:empty_depends_on_stub) {
<del> double(formula: [], cask: [], macos: nil, arch: nil, x11: nil)
<add> double(formula: [], cask: [], macos: nil, arch: nil)
<ide> }
<ide>
<ide> it "downloads and installs a nice fresh Cask" do
<ide><path>Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-x11-value.rb
<del>cask "invalid-depends-on-x11-value" do
<del> version "1.2.3"
<del> sha256 "67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94"
<del>
<del> url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip"
<del> homepage "https://brew.sh/invalid-depends-on-x11-value"
<del>
<del> depends_on x11: :no_such_value
<del>
<del> app "Caffeine.app"
<del>end | 11 |
Ruby | Ruby | build fix for ruby 1.9.3 syntax | e23c77f12b2ba38240c0b4367e6b1964a1698d16 | <ide><path>railties/test/application/initializers/notifications_test.rb
<ide> def wait
<ide> app_file 'config/initializers/foo.rb', ''
<ide>
<ide> events = []
<del> callback = -> (*_) { events << _ }
<add> callback = ->(*_) { events << _ }
<ide> ActiveSupport::Notifications.subscribed(callback, 'load_config_initializer.railties') do
<ide> app
<ide> end | 1 |
Javascript | Javascript | remove trailing whitespace | 88e330d5774fd4c161deb9e689306403472d82c4 | <ide><path>spec/window-event-handler-spec.js
<ide> describe('WindowEventHandler', () => {
<ide> spyOn(atom, 'close')
<ide> window.dispatchEvent(new CustomEvent('window:close'))
<ide> expect(atom.close).toHaveBeenCalled()
<del> })
<add> })
<ide> )
<ide>
<ide> describe('when a link is clicked', () => | 1 |
Mixed | Python | update helm chart release docs | 316632e63bf1ef79446ed2cd9587b2d3d666bf1a | <ide><path>dev/README_RELEASE_HELM_CHART.md
<ide> - [Publish documentation](#publish-documentation)
<ide> - [Notify developers of release](#notify-developers-of-release)
<ide> - [Update Announcements page](#update-announcements-page)
<add> - [Create release on GitHub](#create-release-on-github)
<add> - [Close the milestone](#close-the-milestone)
<add> - [Announce the release on the community slack](#announce-the-release-on-the-community-slack)
<add> - [Tweet about the release](#tweet-about-the-release)
<add> - [Bump chart version in Chart.yaml](#bump-chart-version-in-chartyaml)
<ide> - [Remove old releases](#remove-old-releases)
<ide>
<ide> <!-- END doctoc generated TOC please keep comment here to allow auto update -->
<ide> svn checkout https://dist.apache.org/repos/dist/release/airflow airflow-release
<ide>
<ide> # Create new folder for the release
<ide> cd airflow-release/helm-chart
<add>export AIRFLOW_SVN_RELEASE_HELM=$(pwd)
<ide> svn mkdir ${VERSION}
<ide> cd ${VERSION}
<ide>
<ide> Create and push the release tag:
<ide> ```shell
<ide> cd "${AIRFLOW_REPO_ROOT}"
<ide> git checkout helm-chart/${RC}
<del>git tag -s helm-chart/${VERSION}
<add>git tag -s helm-chart/${VERSION} -m "Apache Airflow Helm Chart ${VERSION}"
<ide> git push origin helm-chart/${VERSION}
<ide> ```
<ide>
<ide> In our cases, documentation for the released versions is published in a separate
<ide> build tools are available in the `apache/airflow` repository, so you have to coordinate
<ide> between the two repositories to be able to build the documentation.
<ide>
<del>- First, copy the airflow-site repository and set the environment variable ``AIRFLOW_SITE_DIRECTORY``.
<add>- First, copy the airflow-site repository, create branch, and set the environment variable ``AIRFLOW_SITE_DIRECTORY``.
<ide>
<ide> ```shell
<ide> git clone https://github.com/apache/airflow-site.git airflow-site
<ide> cd airflow-site
<add> git checkout -b helm-${VERSION}-docs
<ide> export AIRFLOW_SITE_DIRECTORY="$(pwd)"
<ide> ```
<ide>
<ide> between the two repositories to be able to build the documentation.
<ide> ./breeze build-docs -- --package-filter helm-chart --for-production
<ide> ```
<ide>
<del>- Update `index.yaml`
<del>
<del> We upload `index.yaml` to the Airflow website to allow: `helm repo add https://airflow.apache.org`.
<del>
<del> ```shell
<del> cd "${AIRFLOW_SITE_DIRECTORY}"
<del> curl https://dist.apache.org/repos/dist/dev/airflow/helm-chart/${RC}/index.yaml -o index.yaml
<del> https://dist.apache.org/repos/dist/dev/airflow/helm-chart/${VERSION}
<del> sed -i "s|https://dist.apache.org/repos/dist/dev/airflow/helm-chart/$RC|https://downloads.apache.org/airflow/helm-chart/$VERSION|" index.yaml
<del>
<del> git commit -m "Add documentation for Apache Airflow Helm Chart ${VERSION}"
<del> git push
<del> ```
<del>
<ide> - Now you can preview the documentation.
<ide>
<ide> ```shell
<ide> between the two repositories to be able to build the documentation.
<ide>
<ide> ```shell
<ide> ./docs/publish_docs.py --package-filter helm-chart
<add> ```
<add>
<add>- Update `index.yaml`
<add>
<add> Regenerate `index.yaml` so it can be added to the Airflow website to allow: `helm repo add https://airflow.apache.org`.
<add>
<add> ```shell
<ide> cd "${AIRFLOW_SITE_DIRECTORY}"
<add> curl https://dist.apache.org/repos/dist/dev/airflow/helm-chart/$RC/index.yaml -o index.yaml
<add> cp ${AIRFLOW_SVN_RELEASE_HELM}/${VERSION}/airflow-${VERSION}.tgz .
<add> helm repo index --merge ./index.yaml . --url "https://downloads.apache.org/airflow/helm-chart/$VERSION"
<add> rm airflow-${VERSION}.tgz
<add> mv index.yaml landing-pages/site/static/index.yaml
<add> ```
<add>
<add>- Commit new docs, push, and open PR
<add>
<add> ```shell
<add> git add .
<ide> git commit -m "Add documentation for Apache Airflow Helm Chart ${VERSION}"
<ide> git push
<add> # and finally open a PR
<ide> ```
<ide>
<ide> ## Notify developers of release
<ide>
<del>- Notify [email protected] (cc'ing [email protected] and [email protected]) that
<add>- Notify [email protected] (cc'ing [email protected]) that
<ide> the artifacts have been published:
<ide>
<ide> Subject:
<ide> I am pleased to announce that we have released Apache Airflow Helm chart $VERSIO
<ide>
<ide> The source release, as well as the "binary" Helm Chart release, are available:
<ide>
<del>📦 Official Sources: https://airflow.apache.org/helm-chart/installing-helm-chart-from-sources.html
<add>📦 Official Sources: https://airflow.apache.org/docs/helm-chart/$VERSION/installing-helm-chart-from-sources.html
<ide> 📦 ArtifactHub: https://artifacthub.io/packages/helm/apache-airflow/airflow
<ide> 📚 Docs: https://airflow.apache.org/docs/helm-chart/$VERSION/
<ide> 🚀 Quick Start Installation Guide: https://airflow.apache.org/docs/helm-chart/$VERSION/quick-start.html
<ide> Cheers,
<ide> EOF
<ide> ```
<ide>
<add>Send the same email to [email protected], except change the opening line to `Dear community,`.
<add>It is more reliable to set it via the web ui at https://lists.apache.org/[email protected]
<add>
<ide> ## Update Announcements page
<ide>
<ide> Update "Announcements" page at the [Official Airflow website](https://airflow.apache.org/announcements/)
<ide>
<add>## Create release on GitHub
<add>
<add>Create a new release on GitHub with the changelog and assets from the release svn.
<add>
<add>## Close the milestone
<add>
<add>Close the milestone on GitHub. Create the next one if it hasn't been already (it probably has been).
<add>
<add>## Announce the release on the community slack
<add>
<add>Post this in the #announce channel:
<add>
<add>```shell
<add>cat <<EOF
<add>We’ve just released Apache Airflow Helm Chart ${VERSION} 🎉
<add>
<add>📦 ArtifactHub: https://artifacthub.io/packages/helm/apache-airflow/airflow
<add>📚 Docs: https://airflow.apache.org/docs/helm-chart/$VERSION/
<add>🚀 Quick Start Installation Guide: https://airflow.apache.org/docs/helm-chart/$VERSION/quick-start.html
<add>🛠 Changelog: https://airflow.apache.org/docs/helm-chart/$VERSION/changelog.html
<add>
<add>Thanks to all the contributors who made this possible.
<add>EOF
<add>```
<add>
<add>## Tweet about the release
<add>
<add>Tweet about the release:
<add>
<add>```shell
<add>cat <<EOF
<add>We've just released Apache Airflow Helm chart $VERSION 🎉
<add>
<add>📦 ArtifactHub: https://artifacthub.io/packages/helm/apache-airflow/airflow
<add>📚 Docs: https://airflow.apache.org/docs/helm-chart/$VERSION/
<add>🛠️ Changelog: https://airflow.apache.org/docs/helm-chart/$VERSION/changelog.html
<add>
<add>Thanks to all the contributors who made this possible.
<add>EOF
<add>```
<add>
<add>## Bump chart version in Chart.yaml
<add>
<add>Bump the chart version to the next version in `chart/Chart.yaml` in main.
<add>
<add>
<ide> ## Remove old releases
<ide>
<ide> We should keep the old version a little longer than a day or at least until the updated
<ide><path>docs/publish_docs.py
<del>#!/usr/bin/env python
<add>#!/usr/bin/env python3
<ide>
<ide> # Licensed to the Apache Software Foundation (ASF) under one
<ide> # or more contributor license agreements. See the NOTICE file | 2 |
Python | Python | avoid duplication of version info | 85b20f8d491ae02278e720c961024e837cc64b0e | <ide><path>setup.py
<ide> def hello():
<ide> <http://github.com/mitsuhiko/flask/zipball/master#egg=Flask-dev>`_
<ide>
<ide> """
<del>from __future__ import print_function
<del>from setuptools import Command, setup
<add>import re
<add>import ast
<add>from setuptools import setup
<add>
<add>
<add>_version_re = re.compile(r'__version__\s+=\s+(.*)')
<add>
<add>with open('flask/__init__.py', 'rb') as f:
<add> version = str(ast.literal_eval(_version_re.search(
<add> f.read().decode('utf-8')).group(1)))
<ide>
<ide>
<ide> setup(
<ide> name='Flask',
<del> version='0.11.dev0',
<add> version=version,
<ide> url='http://github.com/mitsuhiko/flask/',
<ide> license='BSD',
<ide> author='Armin Ronacher', | 1 |
Java | Java | support mutable headers in messagingtemplate | fda9c633c4a9457300cbfcf0780683ae770b1d84 | <ide><path>spring-messaging/src/main/java/org/springframework/messaging/converter/AbstractMessageConverter.java
<ide> import org.springframework.messaging.Message;
<ide> import org.springframework.messaging.MessageHeaders;
<ide> import org.springframework.messaging.support.MessageBuilder;
<add>import org.springframework.messaging.support.MessageHeaderAccessor;
<ide> import org.springframework.util.Assert;
<ide> import org.springframework.util.MimeType;
<ide>
<ide> protected boolean canConvertFrom(Message<?> message, Class<?> targetClass) {
<ide>
<ide> @Override
<ide> public final Message<?> toMessage(Object payload, MessageHeaders headers) {
<add>
<ide> if (!canConvertTo(payload, headers)) {
<ide> return null;
<ide> }
<add>
<ide> payload = convertToInternal(payload, headers);
<add> MimeType mimeType = getDefaultContentType(payload);
<add>
<add> if (headers != null) {
<add> MessageHeaderAccessor accessor = MessageHeaderAccessor.getAccessor(headers, MessageHeaderAccessor.class);
<add> if (accessor != null && accessor.isMutable()) {
<add> accessor.setHeaderIfAbsent(MessageHeaders.CONTENT_TYPE, mimeType);
<add> return MessageBuilder.createMessage(payload, accessor.getMessageHeaders());
<add> }
<add> }
<add>
<ide> MessageBuilder<?> builder = MessageBuilder.withPayload(payload);
<ide> if (headers != null) {
<ide> builder.copyHeaders(headers);
<ide> }
<del> MimeType mimeType = getDefaultContentType(payload);
<del> if (mimeType != null) {
<del> builder.setHeaderIfAbsent(MessageHeaders.CONTENT_TYPE, mimeType);
<del> }
<add> builder.setHeaderIfAbsent(MessageHeaders.CONTENT_TYPE, mimeType);
<ide> return builder.build();
<ide> }
<ide>
<ide><path>spring-messaging/src/main/java/org/springframework/messaging/converter/SimpleMessageConverter.java
<ide> import org.springframework.messaging.Message;
<ide> import org.springframework.messaging.MessageHeaders;
<ide> import org.springframework.messaging.support.MessageBuilder;
<add>import org.springframework.messaging.support.MessageHeaderAccessor;
<ide> import org.springframework.util.ClassUtils;
<ide>
<ide> /**
<ide> public Object fromMessage(Message<?> message, Class<?> targetClass) {
<ide>
<ide> @Override
<ide> public Message<?> toMessage(Object payload, MessageHeaders headers) {
<del> return (payload != null ? MessageBuilder.withPayload(payload).copyHeaders(headers).build() : null);
<add> if (payload == null) {
<add> return null;
<add> }
<add> if (headers != null) {
<add> MessageHeaderAccessor accessor = MessageHeaderAccessor.getAccessor(headers, MessageHeaderAccessor.class);
<add> if (accessor != null && accessor.isMutable()) {
<add> return MessageBuilder.createMessage(payload, accessor.getMessageHeaders());
<add> }
<add> }
<add> return MessageBuilder.withPayload(payload).copyHeaders(headers).build();
<ide> }
<ide>
<ide> }
<ide><path>spring-messaging/src/main/java/org/springframework/messaging/core/AbstractMessageSendingTemplate.java
<ide> import org.springframework.messaging.converter.MessageConversionException;
<ide> import org.springframework.messaging.converter.MessageConverter;
<ide> import org.springframework.messaging.converter.SimpleMessageConverter;
<del>import org.springframework.messaging.support.MessageHeaderAccessor;
<ide> import org.springframework.util.Assert;
<ide>
<ide> /**
<ide> public void convertAndSend(D destination, Object payload) throws MessagingExcept
<ide>
<ide> @Override
<ide> public void convertAndSend(D destination, Object payload, Map<String, Object> headers) throws MessagingException {
<del> MessagePostProcessor postProcessor = null;
<del> this.convertAndSend(destination, payload, headers, postProcessor);
<add> this.convertAndSend(destination, payload, headers, null);
<ide> }
<ide>
<ide> @Override
<ide> public void convertAndSend(Object payload, MessagePostProcessor postProcessor) t
<ide> public void convertAndSend(D destination, Object payload, MessagePostProcessor postProcessor)
<ide> throws MessagingException {
<ide>
<del> Map<String, Object> headers = null;
<del> this.convertAndSend(destination, payload, headers, postProcessor);
<add> this.convertAndSend(destination, payload, null, postProcessor);
<ide> }
<ide>
<ide> @Override
<ide> public void convertAndSend(D destination, Object payload, Map<String, Object> headers,
<ide> MessagePostProcessor postProcessor) throws MessagingException {
<ide>
<del> headers = processHeadersToSend(headers);
<del>
<del> MessageHeaders messageHeaders;
<del> if (headers != null && headers instanceof MessageHeaders) {
<del> MessageHeaderAccessor.getAccessor()
<add> MessageHeaders messageHeaders = null;
<ide>
<add> headers = processHeadersToSend(headers);
<add> if (headers != null) {
<add> if (headers instanceof MessageHeaders) {
<add> messageHeaders = (MessageHeaders) headers;
<add> }
<add> else {
<add> messageHeaders = new MessageHeaders(headers);
<add> }
<ide> }
<ide>
<del> MessageHeaders messageHeaders = (headers != null) ? new MessageHeaders(headers) : null;
<ide> Message<?> message = this.converter.toMessage(payload, messageHeaders);
<ide>
<ide> if (message == null) {
<ide> String payloadType = (payload != null) ? payload.getClass().getName() : null;
<add> Object contentType = (messageHeaders != null) ? messageHeaders.get(MessageHeaders.CONTENT_TYPE) : null;
<ide> throw new MessageConversionException("Unable to convert payload type '"
<del> + payloadType + "', Content-Type=" + messageHeaders.get(MessageHeaders.CONTENT_TYPE)
<del> + ", converter=" + this.converter, null);
<add> + payloadType + "', Content-Type=" + contentType + ", converter=" + this.converter, null);
<ide> }
<ide>
<ide> if (postProcessor != null) {
<ide> message = postProcessor.postProcessMessage(message);
<ide> }
<add>
<ide> this.send(destination, message);
<ide> }
<ide>
<ide> /**
<del> * Provides access to the map of headers before a send operation.
<del> * Implementations can modify the headers by returning a different map.
<del> * This implementation returns the map that was passed in (i.e. without any changes).
<add> * Provides access to the map of input headers before a send operation. Sub-classes
<add> * can modify the headers and then return the same or a different map.
<add> *
<add> * <p>This default implementation in this class returns the input map.
<ide> *
<del> * @param headers the headers to send, possibly {@code null}
<del> * @return the actual headers to send
<add> * @param headers the headers to send or {@code null}.
<add> * @return the actual headers to send or {@code null}.
<ide> */
<ide> protected Map<String, Object> processHeadersToSend(Map<String, Object> headers) {
<ide> return headers;
<ide><path>spring-messaging/src/main/java/org/springframework/messaging/core/GenericMessagingTemplate.java
<ide> import org.springframework.messaging.MessageHeaders;
<ide> import org.springframework.messaging.PollableChannel;
<ide> import org.springframework.messaging.support.MessageBuilder;
<add>import org.springframework.messaging.support.MessageHeaderAccessor;
<ide> import org.springframework.util.Assert;
<ide>
<ide> /**
<ide> protected final void doSend(MessageChannel channel, Message<?> message) {
<ide>
<ide> Assert.notNull(channel, "channel must not be null");
<ide>
<add> MessageHeaderAccessor accessor = MessageHeaderAccessor.getAccessor(message, MessageHeaderAccessor.class);
<add> if (accessor != null && accessor.isMutable()) {
<add> accessor.setImmutable();
<add> }
<add>
<ide> long timeout = this.sendTimeout;
<ide> boolean sent = (timeout >= 0) ? channel.send(message, timeout) : channel.send(message);
<ide>
<ide><path>spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/AbstractMethodMessageHandler.java
<ide> protected HandlerMethod createHandlerMethod(Object handler, Method method) {
<ide>
<ide> @Override
<ide> public void handleMessage(Message<?> message) throws MessagingException {
<add>
<ide> String destination = getDestination(message);
<ide> if (destination == null) {
<ide> logger.trace("Ignoring message, no destination");
<ide> public void handleMessage(Message<?> message) throws MessagingException {
<ide>
<ide> MessageHeaderAccessor headerAccessor = MessageHeaderAccessor.getMutableAccessor(message);
<ide> headerAccessor.setHeader(DestinationPatternsMessageCondition.LOOKUP_DESTINATION_HEADER, lookupDestination);
<add> headerAccessor.setLeaveMutable(true);
<ide> message = MessageBuilder.createMessage(message.getPayload(), headerAccessor.getMessageHeaders());
<ide>
<ide> handleMessageInternal(message, lookupDestination);
<add> headerAccessor.setImmutable();
<ide> }
<ide>
<ide> protected abstract String getDestination(Message<?> message);
<ide><path>spring-messaging/src/main/java/org/springframework/messaging/simp/SimpMessageSendingOperations.java
<ide> /*
<del> * Copyright 2002-2013 the original author or authors.
<add> * Copyright 2002-2014 the original author or authors.
<ide> *
<ide> * Licensed under the Apache License, Version 2.0 (the "License");
<ide> * you may not use this file except in compliance with the License.
<ide>
<ide> /**
<ide> * A specialization of {@link MessageSendingOperations} with methods for use with
<del> * the Spring Framework support for simple messaging protocols (like STOMP).
<add> * the Spring Framework support for Simple Messaging Protocols (like STOMP).
<add> *
<add> * <p>For more on user destinations see
<add> * {@link org.springframework.messaging.simp.user.UserDestinationResolver}.
<ide> *
<ide> * @author Rossen Stoyanchev
<ide> * @since 4.0
<ide> */
<ide> public interface SimpMessageSendingOperations extends MessageSendingOperations<String> {
<ide>
<ide> /**
<del> * Send a message to a specific user.
<add> * Send a message to the given user.
<add> *
<ide> * @param user the user that should receive the message.
<ide> * @param destination the destination to send the message to.
<ide> * @param payload the payload to send
<ide> */
<ide> void convertAndSendToUser(String user, String destination, Object payload) throws MessagingException;
<ide>
<ide> /**
<del> * Send a message to a specific user.
<del> * @param user the user that should receive the message.
<del> * @param destination the destination to send the message to.
<del> * @param payload the payload to send
<del> * @param headers the message headers
<add> * Send a message to the given user.
<add> *
<add> * <p>By default headers are interpreted as native headers (e.g. STOMP) and
<add> * are saved under a special key in the resulting Spring
<add> * {@link org.springframework.messaging.Message Message}. In effect when the
<add> * message leaves the application, the provided headers are included with it
<add> * and delivered to the destination (e.g. the STOMP client or broker).
<add> *
<add> * <p>If the map already contains the key
<add> * {@link org.springframework.messaging.support.NativeMessageHeaderAccessor#NATIVE_HEADERS "nativeHeaders"}
<add> * or was prepared with
<add> * {@link org.springframework.messaging.simp.SimpMessageHeaderAccessor SimpMessageHeaderAccessor}
<add> * then the headers are used directly. A common expected case is providing a
<add> * content type (to influence the message conversion) and native headers.
<add> * This may be done as follows:
<add> *
<add> * <pre class="code">
<add> * SimpMessageHeaderAccessor accessor = SimpMessageHeaderAccessor.create();
<add> * accessor.setContentType(MimeTypeUtils.TEXT_PLAIN);
<add> * accessor.setNativeHeader("foo", "bar");
<add> * accessor.setLeaveMutable(true);
<add> * MessageHeaders headers = accessor.getMessageHeaders();
<add> *
<add> * messagingTemplate.convertAndSendToUser(user, destination, payload, headers);
<add> * </pre>
<add> *
<add> * <p><strong>Note:</strong> if the {@code MessageHeaders} are mutable as in
<add> * the above example, implementations of this interface should take notice and
<add> * update the headers in the same instance (rather than copy or re-create it)
<add> * and then set it immutable before sending the final message.
<add> *
<add> * @param user the user that should receive the message, must not be {@code null}
<add> * @param destination the destination to send the message to, must not be {@code null}
<add> * @param payload the payload to send, may be {@code null}
<add> * @param headers the message headers, may be {@code null}
<ide> */
<ide> void convertAndSendToUser(String user, String destination, Object payload, Map<String, Object> headers)
<ide> throws MessagingException;
<ide>
<ide> /**
<del> * Send a message to a specific user.
<del> * @param user the user that should receive the message.
<del> * @param destination the destination to send the message to.
<del> * @param payload the payload to send
<add> * Send a message to the given user.
<add> *
<add> * @param user the user that should receive the message, must not be {@code null}
<add> * @param destination the destination to send the message to, must not be {@code null}
<add> * @param payload the payload to send, may be {@code null}
<ide> * @param postProcessor a postProcessor to post-process or modify the created message
<ide> */
<ide> void convertAndSendToUser(String user, String destination, Object payload,
<ide> MessagePostProcessor postProcessor) throws MessagingException;
<ide>
<ide> /**
<del> * Send a message to a specific user.
<add> * Send a message to the given user.
<add> *
<add> * <p>See {@link #convertAndSend(Object, Object, java.util.Map)} for important
<add> * notes regarding the input headers.
<add> *
<ide> * @param user the user that should receive the message.
<ide> * @param destination the destination to send the message to.
<ide> * @param payload the payload to send
<ide><path>spring-messaging/src/main/java/org/springframework/messaging/simp/SimpMessagingTemplate.java
<ide>
<ide> package org.springframework.messaging.simp;
<ide>
<del>import java.util.HashMap;
<ide> import java.util.Map;
<ide>
<ide> import org.springframework.messaging.Message;
<ide> import org.springframework.messaging.MessageChannel;
<ide> import org.springframework.messaging.MessageDeliveryException;
<add>import org.springframework.messaging.MessageHeaders;
<ide> import org.springframework.messaging.MessagingException;
<ide> import org.springframework.messaging.core.AbstractMessageSendingTemplate;
<ide> import org.springframework.messaging.core.MessagePostProcessor;
<ide> import org.springframework.messaging.support.MessageBuilder;
<add>import org.springframework.messaging.support.MessageHeaderAccessor;
<ide> import org.springframework.messaging.support.NativeMessageHeaderAccessor;
<ide> import org.springframework.util.Assert;
<del>import org.springframework.util.LinkedMultiValueMap;
<del>import org.springframework.util.MultiValueMap;
<ide> import org.springframework.util.StringUtils;
<ide>
<ide> /**
<del> * A specialization of {@link AbstractMessageSendingTemplate} that interprets a
<del> * String-based destination as the
<del> * {@link org.springframework.messaging.simp.SimpMessageHeaderAccessor#DESTINATION_HEADER DESTINATION_HEADER}
<del> * to be added to the headers of sent messages.
<del> * <p>
<del> * Also provides methods for sending messages to a user. See
<add> * An implementation of {@link org.springframework.messaging.simp.SimpMessageSendingOperations}.
<add> *
<add> * <p>Also provides methods for sending messages to a user. See
<ide> * {@link org.springframework.messaging.simp.user.UserDestinationResolver UserDestinationResolver}
<ide> * for more on user destinations.
<ide> *
<ide> public long getSendTimeout() {
<ide> }
<ide>
<ide>
<add> /**
<add> * If the headers of the given message already contain a
<add> * {@link org.springframework.messaging.simp.SimpMessageHeaderAccessor#DESTINATION_HEADER
<add> * SimpMessageHeaderAccessor#DESTINATION_HEADER} then the message is sent without
<add> * further changes.
<add> *
<add> * <p>If a destination header is not already present ,the message is sent
<add> * to the configured {@link #setDefaultDestination(Object) defaultDestination}
<add> * or an exception an {@code IllegalStateException} is raised if that isn't
<add> * configured.
<add> *
<add> * @param message the message to send, never {@code null}
<add> */
<ide> @Override
<ide> public void send(Message<?> message) {
<add> Assert.notNull(message, "'message' is required");
<ide> String destination = SimpMessageHeaderAccessor.getDestination(message.getHeaders());
<del> destination = (destination != null) ? destination : getRequiredDefaultDestination();
<del> doSend(destination, message);
<add> if (destination != null) {
<add> sendInternal(message);
<add> return;
<add> }
<add> doSend(getRequiredDefaultDestination(), message);
<ide> }
<ide>
<add> @SuppressWarnings("unchecked")
<ide> @Override
<ide> protected void doSend(String destination, Message<?> message) {
<add>
<ide> Assert.notNull(destination, "Destination must not be null");
<ide>
<del> SimpMessageHeaderAccessor headerAccessor = SimpMessageHeaderAccessor.wrap(message);
<del> headerAccessor.setDestination(destination);
<del> headerAccessor.setMessageTypeIfNotSet(SimpMessageType.MESSAGE);
<del> message = MessageBuilder.createMessage(message.getPayload(), headerAccessor.getMessageHeaders());
<add> SimpMessageHeaderAccessor simpAccessor =
<add> MessageHeaderAccessor.getAccessor(message, SimpMessageHeaderAccessor.class);
<add>
<add> if (simpAccessor != null) {
<add> if (simpAccessor.isMutable()) {
<add> simpAccessor.setDestination(destination);
<add> simpAccessor.setMessageTypeIfNotSet(SimpMessageType.MESSAGE);
<add> simpAccessor.setImmutable();
<add> sendInternal(message);
<add> return;
<add> }
<add> else {
<add> // Try and keep the original accessor type
<add> simpAccessor = (SimpMessageHeaderAccessor) MessageHeaderAccessor.getMutableAccessor(message);
<add> }
<add> }
<add> else {
<add> simpAccessor = SimpMessageHeaderAccessor.wrap(message);
<add> }
<add>
<add> simpAccessor.setDestination(destination);
<add> simpAccessor.setMessageTypeIfNotSet(SimpMessageType.MESSAGE);
<add> message = MessageBuilder.createMessage(message.getPayload(), simpAccessor.getMessageHeaders());
<add> sendInternal(message);
<add> }
<add>
<add> private void sendInternal(Message<?> message) {
<add>
<add> String destination = SimpMessageHeaderAccessor.getDestination(message.getHeaders());
<add> Assert.notNull(destination);
<ide>
<ide> long timeout = this.sendTimeout;
<ide> boolean sent = (timeout >= 0)
<ide> protected void doSend(String destination, Message<?> message) {
<ide>
<ide> if (!sent) {
<ide> throw new MessageDeliveryException(message,
<del> "failed to send message to destination '" + destination + "' within timeout: " + timeout);
<add> "Failed to send message to destination '" + destination + "' within timeout: " + timeout);
<ide> }
<ide> }
<ide>
<ide>
<del>
<ide> @Override
<ide> public void convertAndSendToUser(String user, String destination, Object payload) throws MessagingException {
<ide> this.convertAndSendToUser(user, destination, payload, (MessagePostProcessor) null);
<ide> public void convertAndSendToUser(String user, String destination, Object payload
<ide>
<ide> /**
<ide> * Creates a new map and puts the given headers under the key
<del> * {@link org.springframework.messaging.support.NativeMessageHeaderAccessor#NATIVE_HEADERS NATIVE_HEADERS}.
<del> * Effectively this treats all given headers as headers to be sent out to the
<del> * external source.
<del> * <p>
<del> * If the given headers already contain the key
<del> * {@link org.springframework.messaging.support.NativeMessageHeaderAccessor#NATIVE_HEADERS NATIVE_HEADERS}
<del> * then the same header map is returned (i.e. without any changes).
<add> * {@link org.springframework.messaging.support.NativeMessageHeaderAccessor#NATIVE_HEADERS NATIVE_HEADERS NATIVE_HEADERS NATIVE_HEADERS}.
<add> * effectively treats the input header map as headers to be sent out to the
<add> * destination.
<add> *
<add> * <p>However if the given headers already contain the key
<add> * {@code NATIVE_HEADERS NATIVE_HEADERS} then the same headers instance is
<add> * returned without changes.
<add> *
<add> * <p>Also if the given headers were prepared and obtained with
<add> * {@link SimpMessageHeaderAccessor#getMessageHeaders()} then the same headers
<add> * instance is also returned without changes.
<ide> */
<ide> @Override
<ide> protected Map<String, Object> processHeadersToSend(Map<String, Object> headers) {
<ide>
<ide> if (headers == null) {
<del> return null;
<add> SimpMessageHeaderAccessor headerAccessor = SimpMessageHeaderAccessor.create(SimpMessageType.MESSAGE);
<add> headerAccessor.setLeaveMutable(true);
<add> return headerAccessor.getMessageHeaders();
<ide> }
<del> else if (headers.containsKey(NativeMessageHeaderAccessor.NATIVE_HEADERS)) {
<add>
<add> if (headers.containsKey(NativeMessageHeaderAccessor.NATIVE_HEADERS)) {
<ide> return headers;
<ide> }
<del> else {
<del> MultiValueMap<String, String> nativeHeaders = new LinkedMultiValueMap<String, String>(headers.size());
<del> for (String key : headers.keySet()) {
<del> Object value = headers.get(key);
<del> nativeHeaders.set(key, (value != null ? value.toString() : null));
<add>
<add> if (headers instanceof MessageHeaders) {
<add> SimpMessageHeaderAccessor accessor =
<add> MessageHeaderAccessor.getAccessor((MessageHeaders) headers, SimpMessageHeaderAccessor.class);
<add> if (accessor != null) {
<add> return headers;
<ide> }
<add> }
<ide>
<del> headers = new HashMap<String, Object>(1);
<del> headers.put(NativeMessageHeaderAccessor.NATIVE_HEADERS, nativeHeaders);
<del> return headers;
<add> SimpMessageHeaderAccessor headerAccessor = SimpMessageHeaderAccessor.create(SimpMessageType.MESSAGE);
<add> for (String key : headers.keySet()) {
<add> Object value = headers.get(key);
<add> headerAccessor.setNativeHeader(key, (value != null ? value.toString() : null));
<ide> }
<add> return headerAccessor.getMessageHeaders();
<ide> }
<ide>
<ide> }
<ide><path>spring-messaging/src/main/java/org/springframework/messaging/simp/annotation/support/SendToMethodReturnValueHandler.java
<ide> import org.springframework.messaging.Message;
<ide> import org.springframework.messaging.MessageChannel;
<ide> import org.springframework.messaging.MessageHeaders;
<del>import org.springframework.messaging.core.MessagePostProcessor;
<ide> import org.springframework.messaging.handler.DestinationPatternsMessageCondition;
<ide> import org.springframework.messaging.handler.annotation.SendTo;
<ide> import org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandler;
<ide> import org.springframework.messaging.simp.SimpMessageHeaderAccessor;
<ide> import org.springframework.messaging.simp.SimpMessageSendingOperations;
<add>import org.springframework.messaging.simp.SimpMessageType;
<ide> import org.springframework.messaging.simp.annotation.SendToUser;
<ide> import org.springframework.messaging.simp.user.DestinationUserNameProvider;
<del>import org.springframework.messaging.support.MessageBuilder;
<ide> import org.springframework.util.Assert;
<ide> import org.springframework.util.ObjectUtils;
<ide>
<ide> public void handleReturnValue(Object returnValue, MethodParameter returnType, Me
<ide>
<ide> MessageHeaders headers = message.getHeaders();
<ide> String sessionId = SimpMessageHeaderAccessor.getSessionId(headers);
<del> MessagePostProcessor postProcessor = new SessionHeaderPostProcessor(sessionId);
<ide>
<ide> SendToUser sendToUser = returnType.getMethodAnnotation(SendToUser.class);
<ide> if (sendToUser != null) {
<del> Principal principal = SimpMessageHeaderAccessor.getUser(headers);
<del> if (principal == null) {
<del> throw new MissingSessionUserException(message);
<del> }
<del> String userName = principal.getName();
<del> if (principal instanceof DestinationUserNameProvider) {
<del> userName = ((DestinationUserNameProvider) principal).getDestinationUserName();
<del> }
<add> String user = getUserName(message, headers);
<ide> String[] destinations = getTargetDestinations(sendToUser, message, this.defaultUserDestinationPrefix);
<ide> for (String destination : destinations) {
<del> this.messagingTemplate.convertAndSendToUser(userName, destination, returnValue, postProcessor);
<add> this.messagingTemplate.convertAndSendToUser(user, destination, returnValue, createHeaders(sessionId));
<ide> }
<ide> return;
<ide> }
<ide> else {
<ide> SendTo sendTo = returnType.getMethodAnnotation(SendTo.class);
<ide> String[] destinations = getTargetDestinations(sendTo, message, this.defaultDestinationPrefix);
<ide> for (String destination : destinations) {
<del> this.messagingTemplate.convertAndSend(destination, returnValue, postProcessor);
<add> this.messagingTemplate.convertAndSend(destination, returnValue, createHeaders(sessionId));
<ide> }
<ide> }
<ide> }
<ide>
<del> protected String[] getTargetDestinations(Annotation annot, Message<?> message, String defaultPrefix) {
<add> protected String getUserName(Message<?> message, MessageHeaders headers) {
<add> Principal principal = SimpMessageHeaderAccessor.getUser(headers);
<add> if (principal == null) {
<add> throw new MissingSessionUserException(message);
<add> }
<add> if (principal instanceof DestinationUserNameProvider) {
<add> return ((DestinationUserNameProvider) principal).getDestinationUserName();
<add> }
<add> return principal.getName();
<add> }
<add>
<add> protected String[] getTargetDestinations(Annotation annotation, Message<?> message, String defaultPrefix) {
<ide>
<del> if (annot != null) {
<del> String[] value = (String[]) AnnotationUtils.getValue(annot);
<add> if (annotation != null) {
<add> String[] value = (String[]) AnnotationUtils.getValue(annotation);
<ide> if (!ObjectUtils.isEmpty(value)) {
<ide> return value;
<ide> }
<ide> protected String[] getTargetDestinations(Annotation annot, Message<?> message, S
<ide> return new String[] { defaultPrefix + message.getHeaders().get(name) };
<ide> }
<ide>
<del>
<del> private final class SessionHeaderPostProcessor implements MessagePostProcessor {
<del>
<del> private final String sessionId;
<del>
<del> public SessionHeaderPostProcessor(String sessionId) {
<del> this.sessionId = sessionId;
<del> }
<del>
<del> @Override
<del> public Message<?> postProcessMessage(Message<?> message) {
<del> SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor.wrap(message);
<del> headers.setSessionId(this.sessionId);
<del> return MessageBuilder.createMessage(message.getPayload(), headers.getMessageHeaders());
<del> }
<add> private MessageHeaders createHeaders(String sessionId) {
<add> SimpMessageHeaderAccessor headerAccessor = SimpMessageHeaderAccessor.create(SimpMessageType.MESSAGE);
<add> headerAccessor.setSessionId(sessionId);
<add> headerAccessor.setLeaveMutable(true);
<add> return headerAccessor.getMessageHeaders();
<ide> }
<ide>
<add>
<ide> @Override
<ide> public String toString() {
<ide> return "SendToMethodReturnValueHandler [annotationRequired=" + annotationRequired + "]";
<ide><path>spring-messaging/src/main/java/org/springframework/messaging/simp/annotation/support/SimpAnnotationMethodMessageHandler.java
<ide> import org.springframework.messaging.simp.SimpMessageTypeMessageCondition;
<ide> import org.springframework.messaging.simp.SimpMessagingTemplate;
<ide> import org.springframework.messaging.simp.annotation.SubscribeMapping;
<del>import org.springframework.messaging.support.MessageBuilder;
<add>import org.springframework.messaging.support.MessageHeaderAccessor;
<ide> import org.springframework.stereotype.Controller;
<ide> import org.springframework.util.AntPathMatcher;
<ide> import org.springframework.util.Assert;
<ide> protected Set<String> getDirectLookupDestinations(SimpMessageMappingInfo mapping
<ide>
<ide> @Override
<ide> protected String getDestination(Message<?> message) {
<del> return (String) SimpMessageHeaderAccessor.getDestination(message.getHeaders());
<add> return SimpMessageHeaderAccessor.getDestination(message.getHeaders());
<ide> }
<ide>
<ide> @Override
<ide> protected void handleMatch(SimpMessageMappingInfo mapping, HandlerMethod handler
<ide> Map<String, String> vars = getPathMatcher().extractUriTemplateVariables(matchedPattern, lookupDestination);
<ide>
<ide> if (!CollectionUtils.isEmpty(vars)) {
<del> SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor.wrap(message);
<del> headers.setHeader(DestinationVariableMethodArgumentResolver.DESTINATION_TEMPLATE_VARIABLES_HEADER, vars);
<del> message = MessageBuilder.createMessage(message.getPayload(), headers.getMessageHeaders());
<del>
<add> MessageHeaderAccessor accessor = MessageHeaderAccessor.getAccessor(message, MessageHeaderAccessor.class);
<add> Assert.state(accessor != null && accessor.isMutable());
<add> accessor.setHeader(DestinationVariableMethodArgumentResolver.DESTINATION_TEMPLATE_VARIABLES_HEADER, vars);
<ide> }
<ide>
<ide> super.handleMatch(mapping, handlerMethod, lookupDestination, message);
<ide><path>spring-messaging/src/main/java/org/springframework/messaging/simp/annotation/support/SubscriptionMethodReturnValueHandler.java
<ide> /*
<del> * Copyright 2002-2013 the original author or authors.
<add> * Copyright 2002-2014 the original author or authors.
<ide> *
<ide> * Licensed under the Apache License, Version 2.0 (the "License");
<ide> * you may not use this file except in compliance with the License.
<ide> import org.springframework.core.MethodParameter;
<ide> import org.springframework.messaging.Message;
<ide> import org.springframework.messaging.MessageHeaders;
<del>import org.springframework.messaging.core.MessagePostProcessor;
<ide> import org.springframework.messaging.core.MessageSendingOperations;
<ide> import org.springframework.messaging.handler.annotation.SendTo;
<ide> import org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandler;
<ide> import org.springframework.messaging.simp.SimpMessageHeaderAccessor;
<ide> import org.springframework.messaging.simp.SimpMessageType;
<ide> import org.springframework.messaging.simp.annotation.SendToUser;
<ide> import org.springframework.messaging.simp.annotation.SubscribeMapping;
<del>import org.springframework.messaging.support.MessageBuilder;
<ide> import org.springframework.util.Assert;
<ide>
<ide> /**
<del> * A {@link HandlerMethodReturnValueHandler} for replying directly to a subscription. It
<del> * supports methods annotated with {@link org.springframework.messaging.simp.annotation.SubscribeMapping} unless they're also annotated
<del> * with {@link SendTo} or {@link SendToUser}.
<add> * A {@link HandlerMethodReturnValueHandler} for replying directly to a subscription.
<add> * It is supported on methods annotated with
<add> * {@link org.springframework.messaging.simp.annotation.SubscribeMapping}
<add> * unless they're also annotated with {@link SendTo} or {@link SendToUser} in
<add> * which case a message is sent to the broker instead.
<ide> *
<del> * <p>The value returned from the method is converted, and turned to a {@link Message} and
<del> * then enriched with the sessionId, subscriptionId, and destination of the input message.
<del> * The message is then sent directly back to the connected client.
<add> * <p>The value returned from the method is converted, and turned to a {@link Message}
<add> * and then enriched with the sessionId, subscriptionId, and destination of the
<add> * input message. The message is then sent directly back to the connected client.
<ide> *
<ide> * @author Rossen Stoyanchev
<ide> * @since 4.0
<ide> public class SubscriptionMethodReturnValueHandler implements HandlerMethodReturn
<ide>
<ide>
<ide> /**
<del> * @param messagingTemplate a messaging template for sending messages directly
<del> * to clients, e.g. in response to a subscription
<add> * Class constructor.
<add> *
<add> * @param messagingTemplate a messaging template to send messages to, most
<add> * likely the "clientOutboundChannel", must not be {@link null}.
<ide> */
<ide> public SubscriptionMethodReturnValueHandler(MessageSendingOperations<String> messagingTemplate) {
<ide> Assert.notNull(messagingTemplate, "messagingTemplate must not be null");
<ide> public void handleReturnValue(Object returnValue, MethodParameter returnType, Me
<ide> }
<ide>
<ide> MessageHeaders headers = message.getHeaders();
<add> String destination = SimpMessageHeaderAccessor.getDestination(headers);
<ide> String sessionId = SimpMessageHeaderAccessor.getSessionId(headers);
<ide> String subscriptionId = SimpMessageHeaderAccessor.getSubscriptionId(headers);
<del> String destination = SimpMessageHeaderAccessor.getDestination(headers);
<ide>
<del> Assert.state(subscriptionId != null, "No subsriptiondId in input message to method " + returnType.getMethod());
<add> Assert.state(subscriptionId != null,
<add> "No subscriptionId in message=" + message + ", method=" + returnType.getMethod());
<ide>
<del> MessagePostProcessor postProcessor = new SubscriptionHeaderPostProcessor(sessionId, subscriptionId);
<del> this.messagingTemplate.convertAndSend(destination, returnValue, postProcessor);
<add> this.messagingTemplate.convertAndSend(destination, returnValue, createHeaders(sessionId, subscriptionId));
<ide> }
<ide>
<del>
<del> private final class SubscriptionHeaderPostProcessor implements MessagePostProcessor {
<del>
<del> private final String sessionId;
<del>
<del> private final String subscriptionId;
<del>
<del>
<del> public SubscriptionHeaderPostProcessor(String sessionId, String subscriptionId) {
<del> this.sessionId = sessionId;
<del> this.subscriptionId = subscriptionId;
<del> }
<del>
<del> @Override
<del> public Message<?> postProcessMessage(Message<?> message) {
<del> SimpMessageHeaderAccessor headerAccessor = SimpMessageHeaderAccessor.wrap(message);
<del> headerAccessor.setSessionId(this.sessionId);
<del> headerAccessor.setSubscriptionId(this.subscriptionId);
<del> headerAccessor.setMessageTypeIfNotSet(SimpMessageType.MESSAGE);
<del> return MessageBuilder.createMessage(message.getPayload(), headerAccessor.getMessageHeaders());
<del> }
<add> private MessageHeaders createHeaders(String sessionId, String subscriptionId) {
<add> SimpMessageHeaderAccessor headerAccessor = SimpMessageHeaderAccessor.create(SimpMessageType.MESSAGE);
<add> headerAccessor.setSessionId(sessionId);
<add> headerAccessor.setSubscriptionId(subscriptionId);
<add> headerAccessor.setLeaveMutable(true);
<add> return headerAccessor.getMessageHeaders();
<ide> }
<add>
<ide> }
<ide><path>spring-messaging/src/test/java/org/springframework/messaging/converter/MessageConverterTests.java
<ide> /*
<del> * Copyright 2002-2013 the original author or authors.
<add> * Copyright 2002-2014 the original author or authors.
<ide> *
<ide> * Licensed under the Apache License, Version 2.0 (the "License");
<ide> * you may not use this file except in compliance with the License.
<ide> import org.junit.Test;
<ide> import org.springframework.messaging.Message;
<ide> import org.springframework.messaging.MessageHeaders;
<add>import org.springframework.messaging.simp.SimpMessageHeaderAccessor;
<add>import org.springframework.messaging.simp.SimpMessageType;
<ide> import org.springframework.messaging.support.MessageBuilder;
<ide> import org.springframework.util.MimeType;
<ide> import org.springframework.util.MimeTypeUtils;
<ide> import static org.junit.Assert.assertEquals;
<ide>
<ide> /**
<del> * Test fixture for {@link org.springframework.messaging.converter.AbstractMessageConverter}.
<add> * Unit tests for
<add> * {@link org.springframework.messaging.converter.AbstractMessageConverter}.
<ide> *
<ide> * @author Rossen Stoyanchev
<ide> */
<ide> public void setStrictContentTypeMatchWithNoSupportedMimeTypes() {
<ide> }
<ide>
<ide> @Test
<del> public void toMessageHeadersCopied() {
<add> public void toMessageWithHeaders() {
<ide> Map<String, Object> map = new HashMap<String, Object>();
<ide> map.put("foo", "bar");
<ide> MessageHeaders headers = new MessageHeaders(map);
<ide> Message<?> message = this.converter.toMessage("ABC", headers);
<ide>
<del> assertEquals("bar", message.getHeaders().get("foo"));
<ide> assertNotNull(message.getHeaders().getId());
<ide> assertNotNull(message.getHeaders().getTimestamp());
<add> assertEquals(MimeTypeUtils.TEXT_PLAIN, message.getHeaders().get(MessageHeaders.CONTENT_TYPE));
<add> assertEquals("bar", message.getHeaders().get("foo"));
<add> }
<add>
<add> @Test
<add> public void toMessageWithMutableMessageHeaders() {
<add> SimpMessageHeaderAccessor accessor = SimpMessageHeaderAccessor.create(SimpMessageType.MESSAGE);
<add> accessor.setHeader("foo", "bar");
<add> accessor.setNativeHeader("fooNative", "barNative");
<add> accessor.setLeaveMutable(true);
<add>
<add> MessageHeaders headers = accessor.getMessageHeaders();
<add> Message<?> message = this.converter.toMessage("ABC", headers);
<add>
<add> assertSame(headers, message.getHeaders());
<add> assertNull(message.getHeaders().getId());
<add> assertNull(message.getHeaders().getTimestamp());
<add> assertEquals(MimeTypeUtils.TEXT_PLAIN, message.getHeaders().get(MessageHeaders.CONTENT_TYPE));
<ide> }
<ide>
<ide> @Test
<ide><path>spring-messaging/src/test/java/org/springframework/messaging/converter/SimpleMessageConverterTests.java
<add>/*
<add> * Copyright 2002-2014 the original author or authors.
<add> *
<add> * Licensed under the Apache License, Version 2.0 (the "License");
<add> * you may not use this file except in compliance with the License.
<add> * You may obtain a copy of the License at
<add> *
<add> * http://www.apache.org/licenses/LICENSE-2.0
<add> *
<add> * Unless required by applicable law or agreed to in writing, software
<add> * distributed under the License is distributed on an "AS IS" BASIS,
<add> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<add> * See the License for the specific language governing permissions and
<add> * limitations under the License.
<add> */
<add>
<add>package org.springframework.messaging.converter;
<add>
<add>import org.junit.Before;
<add>import org.junit.Test;
<add>import org.springframework.messaging.Message;
<add>import org.springframework.messaging.MessageHeaders;
<add>import org.springframework.messaging.support.MessageHeaderAccessor;
<add>
<add>import java.util.Collections;
<add>import java.util.Map;
<add>
<add>import static org.junit.Assert.assertEquals;
<add>import static org.junit.Assert.assertNull;
<add>import static org.junit.Assert.assertSame;
<add>
<add>/**
<add> * Unit tests for
<add> * {@link org.springframework.messaging.converter.SimpleMessageConverter}.
<add> *
<add> * @author Rossen Stoyanchev
<add> */
<add>public class SimpleMessageConverterTests {
<add>
<add> private SimpleMessageConverter converter;
<add>
<add> @Before
<add> public void setup() {
<add> this.converter = new SimpleMessageConverter();
<add> }
<add>
<add> @Test
<add> public void toMessageWithNullPayload() {
<add> assertNull(this.converter.toMessage(null, null));
<add> }
<add>
<add> @Test
<add> public void toMessageWithPayloadAndHeaders() {
<add> MessageHeaders headers = new MessageHeaders(Collections.<String, Object>singletonMap("foo", "bar"));
<add> Message<?> message = this.converter.toMessage("payload", headers);
<add>
<add> assertEquals("payload", message.getPayload());
<add> assertEquals("bar", message.getHeaders().get("foo"));
<add> }
<add>
<add> @Test
<add> public void toMessageWithPayloadAndMutableHeaders() {
<add> MessageHeaderAccessor accessor = new MessageHeaderAccessor();
<add> accessor.setHeader("foo", "bar");
<add> accessor.setLeaveMutable(true);
<add> MessageHeaders headers = accessor.getMessageHeaders();
<add>
<add> Message<?> message = this.converter.toMessage("payload", headers);
<add>
<add> assertEquals("payload", message.getPayload());
<add> assertSame(headers, message.getHeaders());
<add> assertEquals("bar", message.getHeaders().get("foo"));
<add> }
<add>}
<ide><path>spring-messaging/src/test/java/org/springframework/messaging/core/GenericMessagingTemplateTests.java
<ide>
<ide> package org.springframework.messaging.core;
<ide>
<add>import java.util.List;
<ide> import java.util.concurrent.CountDownLatch;
<ide> import java.util.concurrent.TimeUnit;
<ide> import java.util.concurrent.atomic.AtomicReference;
<ide> import org.springframework.messaging.MessageChannel;
<ide> import org.springframework.messaging.MessageDeliveryException;
<ide> import org.springframework.messaging.MessageHandler;
<add>import org.springframework.messaging.MessageHeaders;
<ide> import org.springframework.messaging.MessagingException;
<add>import org.springframework.messaging.StubMessageChannel;
<ide> import org.springframework.messaging.SubscribableChannel;
<ide> import org.springframework.messaging.support.ExecutorSubscribableChannel;
<ide> import org.springframework.messaging.support.GenericMessage;
<add>import org.springframework.messaging.support.MessageHeaderAccessor;
<ide> import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
<ide>
<ide> import static org.junit.Assert.*;
<ide> public class GenericMessagingTemplateTests {
<ide>
<ide> private GenericMessagingTemplate template;
<ide>
<add> private StubMessageChannel messageChannel;
<add>
<ide> private ThreadPoolTaskExecutor executor;
<ide>
<ide>
<ide> @Before
<ide> public void setup() {
<add> this.messageChannel = new StubMessageChannel();
<ide> this.template = new GenericMessagingTemplate();
<add> this.template.setDefaultDestination(this.messageChannel);
<add> this.template.setDestinationResolver(new TestDestinationResolver());
<ide> this.executor = new ThreadPoolTaskExecutor();
<ide> this.executor.afterPropertiesSet();
<ide> }
<ide> public void handleMessage(Message<?> message) throws MessagingException {
<ide> }
<ide> }
<ide>
<add> @Test
<add> public void convertAndSendWithSimpMessageHeaders() {
<add> MessageHeaderAccessor accessor = new MessageHeaderAccessor();
<add> accessor.setHeader("key", "value");
<add> accessor.setLeaveMutable(true);
<add> MessageHeaders headers = accessor.getMessageHeaders();
<add>
<add> this.template.convertAndSend("channel", "data", headers);
<add> List<Message<byte[]>> messages = this.messageChannel.getMessages();
<add> Message<byte[]> message = messages.get(0);
<add>
<add> assertSame(headers, message.getHeaders());
<add> assertFalse(accessor.isMutable());
<add> }
<add>
<add> private class TestDestinationResolver implements DestinationResolver<MessageChannel> {
<add>
<add> @Override
<add> public MessageChannel resolveDestination(String name) throws DestinationResolutionException {
<add> return messageChannel;
<add> }
<add> }
<ide> }
<ide><path>spring-messaging/src/test/java/org/springframework/messaging/core/MessageSendingTemplateTests.java
<ide>
<ide> package org.springframework.messaging.core;
<ide>
<add>import java.nio.charset.Charset;
<ide> import java.util.Arrays;
<ide> import java.util.HashMap;
<ide> import java.util.Map;
<ide> import org.springframework.messaging.MessageHeaders;
<ide> import org.springframework.messaging.converter.*;
<ide> import org.springframework.messaging.support.GenericMessage;
<add>import org.springframework.messaging.support.MessageHeaderAccessor;
<add>import org.springframework.util.MimeType;
<ide> import org.springframework.util.MimeTypeUtils;
<ide>
<ide> import static org.junit.Assert.*;
<ide> public void convertAndSendPayloadAndHeadersToDestination() {
<ide> assertEquals("payload", this.template.message.getPayload());
<ide> }
<ide>
<add> @Test
<add> public void convertAndSendPayloadAndMutableHeadersToDestination() {
<add> MessageHeaderAccessor accessor = new MessageHeaderAccessor();
<add> accessor.setHeader("foo", "bar");
<add> accessor.setLeaveMutable(true);
<add> MessageHeaders messageHeaders = accessor.getMessageHeaders();
<add>
<add> this.template.setMessageConverter(new StringMessageConverter());
<add> this.template.convertAndSend("somewhere", "payload", messageHeaders);
<add>
<add> MessageHeaders actual = this.template.message.getHeaders();
<add> assertSame(messageHeaders, actual);
<add> assertEquals(new MimeType("text", "plain", Charset.forName("UTF-8")), actual.get(MessageHeaders.CONTENT_TYPE));
<add> assertEquals("bar", actual.get("foo"));
<add> }
<add>
<ide> @Test
<ide> public void convertAndSendPayloadWithPostProcessor() {
<ide> this.template.setDefaultDestination("home");
<ide><path>spring-messaging/src/test/java/org/springframework/messaging/simp/SimpMessagingTemplateTests.java
<ide>
<ide> package org.springframework.messaging.simp;
<ide>
<add>import org.apache.activemq.transport.stomp.Stomp;
<ide> import org.junit.Before;
<ide> import org.junit.Test;
<ide> import org.springframework.messaging.Message;
<add>import org.springframework.messaging.MessageHeaders;
<ide> import org.springframework.messaging.StubMessageChannel;
<add>import org.springframework.messaging.simp.stomp.StompCommand;
<add>import org.springframework.messaging.simp.stomp.StompHeaderAccessor;
<add>import org.springframework.messaging.support.MessageBuilder;
<add>import org.springframework.messaging.support.MessageHeaderAccessor;
<ide> import org.springframework.messaging.support.NativeMessageHeaderAccessor;
<ide> import org.springframework.util.LinkedMultiValueMap;
<ide>
<ide> import java.util.*;
<ide>
<ide> import static org.junit.Assert.assertEquals;
<add>import static org.junit.Assert.assertFalse;
<add>import static org.junit.Assert.assertNotNull;
<ide> import static org.junit.Assert.assertNull;
<add>import static org.junit.Assert.assertSame;
<add>import static org.junit.Assert.assertTrue;
<ide>
<ide> /**
<ide> * Unit tests for {@link org.springframework.messaging.simp.SimpMessagingTemplate}.
<ide> public class SimpMessagingTemplateTests {
<ide> @Before
<ide> public void setup() {
<ide> this.messageChannel = new StubMessageChannel();
<del> this.messagingTemplate = new SimpMessagingTemplate(messageChannel);
<add> this.messagingTemplate = new SimpMessagingTemplate(this.messageChannel);
<ide> }
<ide>
<ide>
<ide> public void convertAndSendToUser() {
<ide> assertEquals(1, messages.size());
<ide>
<ide> Message<byte[]> message = messages.get(0);
<del> SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor.wrap(message);
<add> SimpMessageHeaderAccessor headerAccessor =
<add> MessageHeaderAccessor.getAccessor(message, SimpMessageHeaderAccessor.class);
<ide>
<del> assertEquals(SimpMessageType.MESSAGE, headers.getMessageType());
<del> assertEquals("/user/joe/queue/foo", headers.getDestination());
<add> assertNotNull(headerAccessor);
<add> assertEquals(SimpMessageType.MESSAGE, headerAccessor.getMessageType());
<add> assertEquals("/user/joe/queue/foo", headerAccessor.getDestination());
<ide> }
<ide>
<ide> @Test
<ide> public void convertAndSendToUserWithEncoding() {
<ide>
<ide> assertEquals(1, messages.size());
<ide>
<del> Message<byte[]> message = messages.get(0);
<del> SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor.wrap(message);
<del> assertEquals("/user/http:%2F%2Fjoe.openid.example.org%2F/queue/foo", headers.getDestination());
<add> SimpMessageHeaderAccessor headerAccessor =
<add> MessageHeaderAccessor.getAccessor(messages.get(0), SimpMessageHeaderAccessor.class);
<add>
<add> assertNotNull(headerAccessor);
<add> assertEquals("/user/http:%2F%2Fjoe.openid.example.org%2F/queue/foo", headerAccessor.getDestination());
<ide> }
<ide>
<ide> @Test
<ide> public void convertAndSendWithCustomHeader() {
<ide> this.messagingTemplate.convertAndSend("/foo", "data", headers);
<ide>
<ide> List<Message<byte[]>> messages = this.messageChannel.getMessages();
<del> Message<byte[]> message = messages.get(0);
<del> SimpMessageHeaderAccessor resultHeaders = SimpMessageHeaderAccessor.wrap(message);
<ide>
<del> assertNull(resultHeaders.toMap().get("key"));
<del> assertEquals(Arrays.asList("value"), resultHeaders.getNativeHeader("key"));
<add> SimpMessageHeaderAccessor headerAccessor =
<add> MessageHeaderAccessor.getAccessor(messages.get(0), SimpMessageHeaderAccessor.class);
<add>
<add> assertNotNull(headerAccessor);
<add> assertNull(headerAccessor.toMap().get("key"));
<add> assertEquals(Arrays.asList("value"), headerAccessor.getNativeHeader("key"));
<ide> }
<ide>
<ide> @Test
<ide> public void convertAndSendWithCustomHeaderNonNative() {
<ide> headers.put(NativeMessageHeaderAccessor.NATIVE_HEADERS, new LinkedMultiValueMap<String, String>());
<ide> this.messagingTemplate.convertAndSend("/foo", "data", headers);
<ide>
<add> List<Message<byte[]>> messages = this.messageChannel.getMessages();
<add>
<add> SimpMessageHeaderAccessor headerAccessor =
<add> MessageHeaderAccessor.getAccessor(messages.get(0), SimpMessageHeaderAccessor.class);
<add>
<add> assertNotNull(headerAccessor);
<add> assertEquals("value", headerAccessor.toMap().get("key"));
<add> assertNull(headerAccessor.getNativeHeader("key"));
<add> }
<add>
<add> @Test
<add> public void convertAndSendWithMutableSimpMessageHeaders() {
<add> SimpMessageHeaderAccessor accessor = SimpMessageHeaderAccessor.create();
<add> accessor.setHeader("key", "value");
<add> accessor.setNativeHeader("fooNative", "barNative");
<add> accessor.setLeaveMutable(true);
<add> MessageHeaders headers = accessor.getMessageHeaders();
<add>
<add> this.messagingTemplate.convertAndSend("/foo", "data", headers);
<add>
<ide> List<Message<byte[]>> messages = this.messageChannel.getMessages();
<ide> Message<byte[]> message = messages.get(0);
<del> SimpMessageHeaderAccessor resultHeaders = SimpMessageHeaderAccessor.wrap(message);
<ide>
<del> assertEquals("value", resultHeaders.toMap().get("key"));
<del> assertNull(resultHeaders.getNativeHeader("key"));
<add> assertSame(headers, message.getHeaders());
<add> assertFalse(accessor.isMutable());
<add> }
<add>
<add> @Test
<add> public void processHeadersToSend() {
<add> Map<String, Object> map = this.messagingTemplate.processHeadersToSend(null);
<add>
<add> assertNotNull(map);
<add> assertTrue("Actual: " + map.getClass().toString(), MessageHeaders.class.isAssignableFrom(map.getClass()));
<add>
<add> SimpMessageHeaderAccessor headerAccessor =
<add> MessageHeaderAccessor.getAccessor((MessageHeaders) map, SimpMessageHeaderAccessor.class);
<add>
<add> assertTrue(headerAccessor.isMutable());
<add> assertEquals(SimpMessageType.MESSAGE, headerAccessor.getMessageType());
<add> }
<add>
<add> @Test
<add> public void doSendWithMutableHeaders() {
<add> SimpMessageHeaderAccessor accessor = SimpMessageHeaderAccessor.create();
<add> accessor.setHeader("key", "value");
<add> accessor.setNativeHeader("fooNative", "barNative");
<add> accessor.setLeaveMutable(true);
<add> MessageHeaders headers = accessor.getMessageHeaders();
<add> Message<?> message = MessageBuilder.createMessage("payload", headers);
<add>
<add> this.messagingTemplate.doSend("/topic/foo", message);
<add>
<add> List<Message<byte[]>> messages = this.messageChannel.getMessages();
<add> Message<byte[]> sentMessage = messages.get(0);
<add>
<add> assertSame(message, sentMessage);
<add> assertFalse(accessor.isMutable());
<add> }
<add>
<add> @Test
<add> public void doSendWithStompHeaders() {
<add> StompHeaderAccessor accessor = StompHeaderAccessor.create(StompCommand.SUBSCRIBE);
<add> accessor.setDestination("/user/queue/foo");
<add> Message<?> message = MessageBuilder.createMessage(new byte[0], accessor.getMessageHeaders());
<add>
<add> this.messagingTemplate.doSend("/queue/foo-user123", message);
<add>
<add> List<Message<byte[]>> messages = this.messageChannel.getMessages();
<add> Message<byte[]> sentMessage = messages.get(0);
<add>
<add> MessageHeaderAccessor sentAccessor = MessageHeaderAccessor.getAccessor(sentMessage, MessageHeaderAccessor.class);
<add> assertEquals(StompHeaderAccessor.class, sentAccessor.getClass());
<add> assertEquals("/queue/foo-user123", ((StompHeaderAccessor) sentAccessor).getDestination());
<ide> }
<ide>
<del>}
<add>}
<ide>\ No newline at end of file
<ide><path>spring-messaging/src/test/java/org/springframework/messaging/simp/annotation/support/SendToMethodReturnValueHandlerTests.java
<ide> package org.springframework.messaging.simp.annotation.support;
<ide>
<ide> import java.lang.reflect.Method;
<add>import java.nio.charset.Charset;
<ide> import java.security.Principal;
<ide>
<ide> import javax.security.auth.Subject;
<ide> import org.mockito.ArgumentCaptor;
<ide> import org.mockito.Captor;
<ide> import org.mockito.Mock;
<add>import org.mockito.Mockito;
<ide> import org.mockito.MockitoAnnotations;
<ide>
<ide> import org.springframework.core.MethodParameter;
<ide> import org.springframework.messaging.Message;
<ide> import org.springframework.messaging.MessageChannel;
<add>import org.springframework.messaging.MessageHeaders;
<add>import org.springframework.messaging.converter.StringMessageConverter;
<add>import org.springframework.messaging.core.MessageSendingOperations;
<ide> import org.springframework.messaging.handler.DestinationPatternsMessageCondition;
<ide> import org.springframework.messaging.handler.annotation.SendTo;
<ide> import org.springframework.messaging.simp.SimpMessageHeaderAccessor;
<add>import org.springframework.messaging.simp.SimpMessageSendingOperations;
<ide> import org.springframework.messaging.simp.SimpMessagingTemplate;
<ide> import org.springframework.messaging.simp.annotation.SendToUser;
<ide> import org.springframework.messaging.simp.user.DestinationUserNameProvider;
<ide> import org.springframework.messaging.support.MessageBuilder;
<del>import org.springframework.messaging.converter.MessageConverter;
<add>import org.springframework.messaging.support.MessageHeaderAccessor;
<add>import org.springframework.util.MimeType;
<ide>
<ide> import static org.junit.Assert.*;
<ide> import static org.mockito.Matchers.*;
<add>import static org.mockito.Matchers.eq;
<ide> import static org.mockito.Mockito.*;
<ide>
<ide> /**
<ide> */
<ide> public class SendToMethodReturnValueHandlerTests {
<ide>
<del> private static final String payloadContent = "payload";
<add> public static final MimeType MIME_TYPE = new MimeType("text", "plain", Charset.forName("UTF-8"));
<add>
<add> private static final String PAYLOAD = "payload";
<ide>
<ide>
<ide> private SendToMethodReturnValueHandler handler;
<ide> public class SendToMethodReturnValueHandlerTests {
<ide>
<ide> @Captor ArgumentCaptor<Message<?>> messageCaptor;
<ide>
<del> @Mock private MessageConverter messageConverter;
<del>
<ide> private MethodParameter noAnnotationsReturnType;
<ide> private MethodParameter sendToReturnType;
<ide> private MethodParameter sendToDefaultDestReturnType;
<ide> public void setup() throws Exception {
<ide>
<ide> MockitoAnnotations.initMocks(this);
<ide>
<del> Message message = MessageBuilder.withPayload(payloadContent).build();
<del> when(this.messageConverter.toMessage(payloadContent, null)).thenReturn(message);
<del>
<ide> SimpMessagingTemplate messagingTemplate = new SimpMessagingTemplate(this.messageChannel);
<del> messagingTemplate.setMessageConverter(this.messageConverter);
<add> messagingTemplate.setMessageConverter(new StringMessageConverter());
<ide>
<ide> this.handler = new SendToMethodReturnValueHandler(messagingTemplate, true);
<ide> this.handlerAnnotationNotRequired = new SendToMethodReturnValueHandler(messagingTemplate, false);
<ide> public void sendToNoAnnotations() throws Exception {
<ide> when(this.messageChannel.send(any(Message.class))).thenReturn(true);
<ide>
<ide> Message<?> inputMessage = createInputMessage("sess1", "sub1", "/app", "/dest", null);
<del> this.handler.handleReturnValue(payloadContent, this.noAnnotationsReturnType, inputMessage);
<add> this.handler.handleReturnValue(PAYLOAD, this.noAnnotationsReturnType, inputMessage);
<ide>
<ide> verify(this.messageChannel, times(1)).send(this.messageCaptor.capture());
<ide>
<ide> Message<?> message = this.messageCaptor.getAllValues().get(0);
<ide> SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor.wrap(message);
<ide> assertEquals("sess1", headers.getSessionId());
<del> assertNull(headers.getSubscriptionId());
<ide> assertEquals("/topic/dest", headers.getDestination());
<add> assertEquals(MIME_TYPE, headers.getContentType());
<add> assertNull("Subscription id should not be copied", headers.getSubscriptionId());
<ide> }
<ide>
<ide> @Test
<ide> public void sendTo() throws Exception {
<ide>
<ide> String sessionId = "sess1";
<ide> Message<?> inputMessage = createInputMessage(sessionId, "sub1", null, null, null);
<del> this.handler.handleReturnValue(payloadContent, this.sendToReturnType, inputMessage);
<add> this.handler.handleReturnValue(PAYLOAD, this.sendToReturnType, inputMessage);
<ide>
<ide> verify(this.messageChannel, times(2)).send(this.messageCaptor.capture());
<ide>
<ide> Message<?> message = this.messageCaptor.getAllValues().get(0);
<ide> SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor.wrap(message);
<ide> assertEquals(sessionId, headers.getSessionId());
<del> assertNull(headers.getSubscriptionId());
<ide> assertEquals("/dest1", headers.getDestination());
<add> assertEquals(MIME_TYPE, headers.getContentType());
<add> assertNull("Subscription id should not be copied", headers.getSubscriptionId());
<ide>
<ide> message = this.messageCaptor.getAllValues().get(1);
<ide> headers = SimpMessageHeaderAccessor.wrap(message);
<ide> assertEquals(sessionId, headers.getSessionId());
<del> assertNull(headers.getSubscriptionId());
<ide> assertEquals("/dest2", headers.getDestination());
<add> assertEquals(MIME_TYPE, headers.getContentType());
<add> assertNull("Subscription id should not be copied", headers.getSubscriptionId());
<ide> }
<ide>
<ide> @Test
<ide> public void sendToDefaultDestination() throws Exception {
<ide>
<ide> String sessionId = "sess1";
<ide> Message<?> inputMessage = createInputMessage(sessionId, "sub1", "/app", "/dest", null);
<del> this.handler.handleReturnValue(payloadContent, this.sendToDefaultDestReturnType, inputMessage);
<add> this.handler.handleReturnValue(PAYLOAD, this.sendToDefaultDestReturnType, inputMessage);
<ide>
<ide> verify(this.messageChannel, times(1)).send(this.messageCaptor.capture());
<ide>
<ide> Message<?> message = this.messageCaptor.getAllValues().get(0);
<ide> SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor.wrap(message);
<ide> assertEquals(sessionId, headers.getSessionId());
<del> assertNull(headers.getSubscriptionId());
<ide> assertEquals("/topic/dest", headers.getDestination());
<add> assertEquals(MIME_TYPE, headers.getContentType());
<add> assertNull("Subscription id should not be copied", headers.getSubscriptionId());
<add> }
<add>
<add> @Test
<add> public void testHeadersToSend() throws Exception {
<add>
<add> Message<?> inputMessage = createInputMessage("sess1", "sub1", "/app", "/dest", null);
<add>
<add> SimpMessageSendingOperations messagingTemplate = Mockito.mock(SimpMessageSendingOperations.class);
<add> SendToMethodReturnValueHandler handler = new SendToMethodReturnValueHandler(messagingTemplate, false);
<add>
<add> handler.handleReturnValue(PAYLOAD, this.noAnnotationsReturnType, inputMessage);
<add>
<add> ArgumentCaptor<MessageHeaders> captor = ArgumentCaptor.forClass(MessageHeaders.class);
<add> verify(messagingTemplate).convertAndSend(eq("/topic/dest"), eq(PAYLOAD), captor.capture());
<add>
<add> SimpMessageHeaderAccessor headerAccessor =
<add> MessageHeaderAccessor.getAccessor(captor.getValue(), SimpMessageHeaderAccessor.class);
<add>
<add> assertNotNull(headerAccessor);
<add> assertTrue(headerAccessor.isMutable());
<add> assertEquals("sess1", headerAccessor.getSessionId());
<add> assertNull("Subscription id should not be copied", headerAccessor.getSubscriptionId());
<ide> }
<ide>
<ide> @Test
<ide> public void sendToUser() throws Exception {
<ide> String sessionId = "sess1";
<ide> TestUser user = new TestUser();
<ide> Message<?> inputMessage = createInputMessage(sessionId, "sub1", null, null, user);
<del> this.handler.handleReturnValue(payloadContent, this.sendToUserReturnType, inputMessage);
<add> this.handler.handleReturnValue(PAYLOAD, this.sendToUserReturnType, inputMessage);
<ide>
<ide> verify(this.messageChannel, times(2)).send(this.messageCaptor.capture());
<ide>
<ide> Message<?> message = this.messageCaptor.getAllValues().get(0);
<ide> SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor.wrap(message);
<ide> assertEquals(sessionId, headers.getSessionId());
<del> assertNull(headers.getSubscriptionId());
<add> assertEquals(MIME_TYPE, headers.getContentType());
<ide> assertEquals("/user/" + user.getName() + "/dest1", headers.getDestination());
<add> assertNull("Subscription id should not be copied", headers.getSubscriptionId());
<ide>
<ide> message = this.messageCaptor.getAllValues().get(1);
<ide> headers = SimpMessageHeaderAccessor.wrap(message);
<ide> assertEquals(sessionId, headers.getSessionId());
<del> assertNull(headers.getSubscriptionId());
<ide> assertEquals("/user/" + user.getName() + "/dest2", headers.getDestination());
<add> assertEquals(MIME_TYPE, headers.getContentType());
<add> assertNull("Subscription id should not be copied", headers.getSubscriptionId());
<ide> }
<ide>
<ide> @Test
<ide> public void sendToUserWithUserNameProvider() throws Exception {
<ide> String sessionId = "sess1";
<ide> TestUser user = new UniqueUser();
<ide> Message<?> inputMessage = createInputMessage(sessionId, "sub1", null, null, user);
<del> this.handler.handleReturnValue(payloadContent, this.sendToUserReturnType, inputMessage);
<add> this.handler.handleReturnValue(PAYLOAD, this.sendToUserReturnType, inputMessage);
<ide>
<ide> verify(this.messageChannel, times(2)).send(this.messageCaptor.capture());
<ide>
<ide> public void sendToUserDefaultDestination() throws Exception {
<ide> String sessionId = "sess1";
<ide> TestUser user = new TestUser();
<ide> Message<?> inputMessage = createInputMessage(sessionId, "sub1", "/app", "/dest", user);
<del> this.handler.handleReturnValue(payloadContent, this.sendToUserDefaultDestReturnType, inputMessage);
<add> this.handler.handleReturnValue(PAYLOAD, this.sendToUserDefaultDestReturnType, inputMessage);
<ide>
<ide> verify(this.messageChannel, times(1)).send(this.messageCaptor.capture());
<ide>
<ide> Message<?> message = this.messageCaptor.getAllValues().get(0);
<ide> SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor.wrap(message);
<ide> assertEquals(sessionId, headers.getSessionId());
<del> assertNull(headers.getSubscriptionId());
<ide> assertEquals("/user/" + user.getName() + "/queue/dest", headers.getDestination());
<add> assertEquals(MIME_TYPE, headers.getContentType());
<add> assertNull("Subscription id should not be copied", headers.getSubscriptionId());
<add> }
<add>
<add> @Test
<add> public void testHeadersToSendToUser() throws Exception {
<add>
<add> TestUser user = new TestUser();
<add> Message<?> inputMessage = createInputMessage("sess1", "sub1", "/app", "/dest", user);
<add>
<add> SimpMessageSendingOperations messagingTemplate = Mockito.mock(SimpMessageSendingOperations.class);
<add> SendToMethodReturnValueHandler handler = new SendToMethodReturnValueHandler(messagingTemplate, false);
<add>
<add> handler.handleReturnValue(PAYLOAD, this.sendToUserDefaultDestReturnType, inputMessage);
<add>
<add> ArgumentCaptor<MessageHeaders> captor = ArgumentCaptor.forClass(MessageHeaders.class);
<add> verify(messagingTemplate).convertAndSendToUser(eq("joe"), eq("/queue/dest"), eq(PAYLOAD), captor.capture());
<add>
<add> SimpMessageHeaderAccessor headerAccessor =
<add> MessageHeaderAccessor.getAccessor(captor.getValue(), SimpMessageHeaderAccessor.class);
<add>
<add> assertNotNull(headerAccessor);
<add> assertTrue(headerAccessor.isMutable());
<add> assertEquals("sess1", headerAccessor.getSessionId());
<add> assertNull("Subscription id should not be copied", headerAccessor.getSubscriptionId());
<ide> }
<ide>
<ide>
<ide> private Message<?> createInputMessage(String sessId, String subsId, String destinationPrefix,
<ide> String destination, Principal principal) {
<del> SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor.create();
<del> headers.setSessionId(sessId);
<del> headers.setSubscriptionId(subsId);
<add>
<add> SimpMessageHeaderAccessor headerAccessor = SimpMessageHeaderAccessor.create();
<add> headerAccessor.setSessionId(sessId);
<add> headerAccessor.setSubscriptionId(subsId);
<ide> if (destination != null && destinationPrefix != null) {
<del> headers.setDestination(destinationPrefix + destination);
<del> headers.setHeader(DestinationPatternsMessageCondition.LOOKUP_DESTINATION_HEADER, destination);
<add> headerAccessor.setDestination(destinationPrefix + destination);
<add> headerAccessor.setHeader(DestinationPatternsMessageCondition.LOOKUP_DESTINATION_HEADER, destination);
<ide> }
<ide> if (principal != null) {
<del> headers.setUser(principal);
<add> headerAccessor.setUser(principal);
<ide> }
<del> return MessageBuilder.withPayload(new byte[0]).copyHeaders(headers.toMap()).build();
<add> return MessageBuilder.createMessage(new byte[0], headerAccessor.getMessageHeaders());
<ide> }
<ide>
<ide> private static class TestUser implements Principal {
<ide> public String getDestinationUserName() {
<ide> }
<ide>
<ide> public String handleNoAnnotations() {
<del> return payloadContent;
<add> return PAYLOAD;
<ide> }
<ide>
<ide> @SendTo
<ide> public String handleAndSendToDefaultDestination() {
<del> return payloadContent;
<add> return PAYLOAD;
<ide> }
<ide>
<ide> @SendTo({"/dest1", "/dest2"})
<ide> public String handleAndSendTo() {
<del> return payloadContent;
<add> return PAYLOAD;
<ide> }
<ide>
<ide> @SendToUser
<ide> public String handleAndSendToUserDefaultDestination() {
<del> return payloadContent;
<add> return PAYLOAD;
<ide> }
<ide>
<ide> @SendToUser({"/dest1", "/dest2"})
<ide> public String handleAndSendToUser() {
<del> return payloadContent;
<add> return PAYLOAD;
<ide> }
<ide>
<ide> }
<ide><path>spring-messaging/src/test/java/org/springframework/messaging/simp/annotation/support/SubscriptionMethodReturnValueHandlerTests.java
<ide> package org.springframework.messaging.simp.annotation.support;
<ide>
<ide> import java.lang.reflect.Method;
<add>import java.nio.charset.Charset;
<ide> import java.security.Principal;
<ide>
<ide> import org.junit.Before;
<ide> import org.junit.Test;
<ide> import org.mockito.ArgumentCaptor;
<ide> import org.mockito.Captor;
<ide> import org.mockito.Mock;
<add>import org.mockito.Mockito;
<ide> import org.mockito.MockitoAnnotations;
<ide> import org.springframework.core.MethodParameter;
<ide> import org.springframework.messaging.Message;
<ide> import org.springframework.messaging.MessageChannel;
<add>import org.springframework.messaging.MessageHeaders;
<add>import org.springframework.messaging.converter.StringMessageConverter;
<add>import org.springframework.messaging.core.MessageSendingOperations;
<ide> import org.springframework.messaging.handler.annotation.MessageMapping;
<ide> import org.springframework.messaging.handler.annotation.SendTo;
<ide> import org.springframework.messaging.simp.SimpMessageHeaderAccessor;
<ide> import org.springframework.messaging.simp.SimpMessagingTemplate;
<ide> import org.springframework.messaging.simp.annotation.SubscribeMapping;
<ide> import org.springframework.messaging.support.MessageBuilder;
<del>import org.springframework.messaging.converter.MessageConverter;
<add>import org.springframework.messaging.support.MessageHeaderAccessor;
<add>import org.springframework.util.MimeType;
<ide>
<ide> import static org.junit.Assert.*;
<ide> import static org.mockito.Matchers.*;
<ide> */
<ide> public class SubscriptionMethodReturnValueHandlerTests {
<ide>
<del> private static final String payloadContent = "payload";
<add> public static final MimeType MIME_TYPE = new MimeType("text", "plain", Charset.forName("UTF-8"));
<add>
<add> private static final String PAYLOAD = "payload";
<ide>
<ide>
<ide> private SubscriptionMethodReturnValueHandler handler;
<ide> public class SubscriptionMethodReturnValueHandlerTests {
<ide>
<ide> @Captor ArgumentCaptor<Message<?>> messageCaptor;
<ide>
<del> @Mock private MessageConverter messageConverter;
<del>
<ide> private MethodParameter subscribeEventReturnType;
<ide>
<ide> private MethodParameter subscribeEventSendToReturnType;
<ide> public void setup() throws Exception {
<ide>
<ide> MockitoAnnotations.initMocks(this);
<ide>
<del> Message message = MessageBuilder.withPayload(payloadContent).build();
<del> when(this.messageConverter.toMessage(payloadContent, null)).thenReturn(message);
<del>
<ide> SimpMessagingTemplate messagingTemplate = new SimpMessagingTemplate(this.messageChannel);
<del> messagingTemplate.setMessageConverter(this.messageConverter);
<add> messagingTemplate.setMessageConverter(new StringMessageConverter());
<ide>
<ide> this.handler = new SubscriptionMethodReturnValueHandler(messagingTemplate);
<ide>
<ide> public void supportsReturnType() throws Exception {
<ide> }
<ide>
<ide> @Test
<del> public void subscribeEventMethod() throws Exception {
<add> public void testMessageSentToChannel() throws Exception {
<ide>
<ide> when(this.messageChannel.send(any(Message.class))).thenReturn(true);
<ide>
<ide> public void subscribeEventMethod() throws Exception {
<ide> String destination = "/dest";
<ide> Message<?> inputMessage = createInputMessage(sessionId, subscriptionId, destination, null);
<ide>
<del> this.handler.handleReturnValue(payloadContent, this.subscribeEventReturnType, inputMessage);
<add> this.handler.handleReturnValue(PAYLOAD, this.subscribeEventReturnType, inputMessage);
<ide>
<ide> verify(this.messageChannel).send(this.messageCaptor.capture());
<ide> assertNotNull(this.messageCaptor.getValue());
<ide>
<ide> Message<?> message = this.messageCaptor.getValue();
<del> SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor.wrap(message);
<add> SimpMessageHeaderAccessor headerAccessor = SimpMessageHeaderAccessor.wrap(message);
<add>
<add> assertNull("SimpMessageHeaderAccessor should have disabled id", headerAccessor.getId());
<add> assertNull("SimpMessageHeaderAccessor should have disabled timestamp", headerAccessor.getTimestamp());
<add> assertEquals(sessionId, headerAccessor.getSessionId());
<add> assertEquals(subscriptionId, headerAccessor.getSubscriptionId());
<add> assertEquals(destination, headerAccessor.getDestination());
<add> assertEquals(MIME_TYPE, headerAccessor.getContentType());
<add> }
<add>
<add> @SuppressWarnings("unchecked")
<add> @Test
<add> public void testHeadersPassedToMessagingTemplate() throws Exception {
<add>
<add> String sessionId = "sess1";
<add> String subscriptionId = "subs1";
<add> String destination = "/dest";
<add> Message<?> inputMessage = createInputMessage(sessionId, subscriptionId, destination, null);
<add>
<add> MessageSendingOperations messagingTemplate = Mockito.mock(MessageSendingOperations.class);
<add> SubscriptionMethodReturnValueHandler handler = new SubscriptionMethodReturnValueHandler(messagingTemplate);
<add>
<add> handler.handleReturnValue(PAYLOAD, this.subscribeEventReturnType, inputMessage);
<add>
<add> ArgumentCaptor<MessageHeaders> captor = ArgumentCaptor.forClass(MessageHeaders.class);
<add> verify(messagingTemplate).convertAndSend(eq("/dest"), eq(PAYLOAD), captor.capture());
<add>
<add> SimpMessageHeaderAccessor headerAccessor =
<add> MessageHeaderAccessor.getAccessor(captor.getValue(), SimpMessageHeaderAccessor.class);
<ide>
<del> assertEquals("sessionId should always be copied", sessionId, headers.getSessionId());
<del> assertEquals(subscriptionId, headers.getSubscriptionId());
<del> assertEquals(destination, headers.getDestination());
<add> assertNotNull(headerAccessor);
<add> assertTrue(headerAccessor.isMutable());
<add> assertEquals(sessionId, headerAccessor.getSessionId());
<add> assertEquals(subscriptionId, headerAccessor.getSubscriptionId());
<ide> }
<ide>
<ide>
<ide> private Message<?> createInputMessage(String sessId, String subsId, String dest,
<ide> }
<ide>
<ide>
<add> @SuppressWarnings("unused")
<ide> @SubscribeMapping("/data") // not needed for the tests but here for completeness
<ide> private String getData() {
<del> return payloadContent;
<add> return PAYLOAD;
<ide> }
<ide>
<add> @SuppressWarnings("unused")
<ide> @SubscribeMapping("/data") // not needed for the tests but here for completeness
<ide> @SendTo("/sendToDest")
<ide> private String getDataAndSendTo() {
<del> return payloadContent;
<add> return PAYLOAD;
<ide> }
<ide>
<add> @SuppressWarnings("unused")
<ide> @MessageMapping("/handle") // not needed for the tests but here for completeness
<ide> public String handle() {
<del> return payloadContent;
<add> return PAYLOAD;
<ide> }
<ide> } | 17 |
Javascript | Javascript | add tests for selection select and selectall | 1444698b22e0ace3df6559b36e7f362db9dedc0a | <ide><path>test/core/selection-append-test.js
<ide> var vows = require("vows"),
<ide> var suite = vows.describe("selection.append");
<ide>
<ide> suite.addBatch({
<del> "select": {
<add> "select(body)": {
<ide> topic: function() {
<ide> return d3.select("body").html("");
<ide> },
<ide> "appends an HTML element": function(body) {
<ide> var div = body.append("div");
<ide> assert.equal(div[0][0].tagName, "DIV");
<ide> assert.isNull(div[0][0].namespaceURI);
<del> assert.isTrue(div[0][0].parentNode === body[0][0]);
<del> assert.isTrue(body[0][0].lastChild === div[0][0]);
<add> assert.isTrue(div[0][0].parentNode === document.body);
<add> assert.isTrue(div[0][0] === document.body.lastChild);
<ide> },
<ide> "appends an SVG element": function(body) {
<ide> var svg = body.append("svg:svg");
<ide> assert.equal(svg[0][0].tagName, "SVG");
<ide> assert.equal(svg[0][0].namespaceURI, "http://www.w3.org/2000/svg");
<del> assert.isTrue(svg[0][0].parentNode === body[0][0]);
<del> assert.isTrue(body[0][0].lastChild === svg[0][0]);
<add> assert.isTrue(svg[0][0].parentNode === document.body);
<add> assert.isTrue(svg[0][0] === document.body.lastChild);
<ide> }
<ide> }
<ide> });
<ide>
<ide> suite.addBatch({
<del> "selectAll": {
<add> "selectAll(div)": {
<ide> topic: function() {
<ide> return d3.select("body").html("").selectAll("div").data(d3.range(2)).enter().append("div");
<ide> },
<ide><path>test/core/selection-attr-test.js
<ide> var vows = require("vows"),
<ide> var suite = vows.describe("selection.attr");
<ide>
<ide> suite.addBatch({
<del> "select": {
<add> "select(body)": {
<ide> topic: function() {
<ide> return d3.select("body");
<ide> },
<ide> "sets an attribute as a string": function(body) {
<ide> body.attr("bgcolor", "red");
<del> assert.equal(body[0][0].getAttribute("bgcolor"), "red");
<add> assert.equal(document.body.getAttribute("bgcolor"), "red");
<ide> },
<ide> "sets an attribute as a number": function(body) {
<ide> body.attr("opacity", 1);
<del> assert.equal(body[0][0].getAttribute("opacity"), "1");
<add> assert.equal(document.body.getAttribute("opacity"), "1");
<ide> },
<ide> "sets an attribute as a function": function(body) {
<ide> body.attr("bgcolor", function() { return "orange"; });
<del> assert.equal(body[0][0].getAttribute("bgcolor"), "orange");
<add> assert.equal(document.body.getAttribute("bgcolor"), "orange");
<ide> },
<ide> "sets an attribute as a function of data": function(body) {
<ide> body.data(["cyan"]).attr("bgcolor", String);
<del> assert.equal(body[0][0].getAttribute("bgcolor"), "cyan");
<add> assert.equal(document.body.getAttribute("bgcolor"), "cyan");
<ide> },
<ide> "sets an attribute as a function of index": function(body) {
<ide> body.attr("bgcolor", function(d, i) { return "orange-" + i; });
<del> assert.equal(body[0][0].getAttribute("bgcolor"), "orange-0");
<add> assert.equal(document.body.getAttribute("bgcolor"), "orange-0");
<ide> },
<ide> "gets an attribute value": function(body) {
<del> body[0][0].setAttribute("bgcolor", "yellow");
<add> document.body.setAttribute("bgcolor", "yellow");
<ide> assert.equal(body.attr("bgcolor"), "yellow");
<ide> }
<ide> }
<ide> });
<ide>
<ide> suite.addBatch({
<del> "selectAll": {
<add> "selectAll(div)": {
<ide> topic: function() {
<ide> return d3.select("body").html("").selectAll("div").data(d3.range(2)).enter().append("div");
<ide> },
<ide><path>test/core/selection-property-test.js
<ide> suite.addBatch({
<ide> },
<ide> "sets a property as a string": function(body) {
<ide> body.property("bgcolor", "red");
<del> assert.equal(body[0][0].bgcolor, "red");
<add> assert.equal(document.body.bgcolor, "red");
<ide> },
<ide> "sets a property as a number": function(body) {
<ide> body.property("opacity", 1);
<del> assert.equal(body[0][0].opacity, "1");
<add> assert.equal(document.body.opacity, "1");
<ide> },
<ide> "sets a property as a function": function(body) {
<ide> body.property("bgcolor", function() { return "orange"; });
<del> assert.equal(body[0][0].bgcolor, "orange");
<add> assert.equal(document.body.bgcolor, "orange");
<ide> },
<ide> "gets a property value": function(body) {
<del> body[0][0].bgcolor = "yellow";
<add> document.body.bgcolor = "yellow";
<ide> assert.equal(body.property("bgcolor"), "yellow");
<ide> }
<ide> }
<ide><path>test/core/selection-select-test.js
<add>require("../env");
<add>require("../../d3");
<add>
<add>var vows = require("vows"),
<add> assert = require("assert");
<add>
<add>var suite = vows.describe("selection.select");
<add>
<add>suite.addBatch({
<add> "select(body)": {
<add> topic: function() {
<add> var body = d3.select("body").html("");
<add> body.append("div").attr("class", "first");
<add> body.append("div").attr("class", "second");
<add> return body;
<add> },
<add> "selects the first matching element": function(body) {
<add> var div = body.select("div");
<add> assert.isTrue(div[0][0] === document.body.firstChild);
<add> assert.equal(div.length, 1);
<add> assert.equal(div[0].length, 1);
<add> assert.equal(div.attr("class"), "first");
<add> },
<add> "propagates parent node to the selected elements": function(body) {
<add> var div = body.select("div");
<add> assert.isNotNull(div[0].parentNode);
<add> assert.isTrue(div[0].parentNode === document.documentElement);
<add> assert.isTrue(div[0].parentNode === body[0].parentNode);
<add> },
<add> "propagates data to the selected elements": function(body) {
<add> var data = new Object(), div = body.data([data]).select("div");
<add> assert.strictEqual(div[0][0].__data__, data);
<add> },
<add> "does not propagate data if no data was specified": function(body) {
<add> delete document.body.__data__;
<add> var data = new Object(), div = body.select("div").data([data]);
<add> div = body.select("div");
<add> assert.strictEqual(div[0][0].__data__, data);
<add> assert.isUndefined(document.body.__data__);
<add> },
<add> "returns null if no match is found": function(body) {
<add> var span = body.select("span");
<add> assert.equal(span[0][0], null);
<add> assert.equal(span.length, 1);
<add> assert.equal(span[0].length, 1);
<add> }
<add> }
<add>});
<add>
<add>suite.addBatch({
<add> "selectAll(div)": {
<add> topic: function() {
<add> var div = d3.select("body").html("").selectAll("div").data(d3.range(2)).enter().append("div");
<add> div.append("span").attr("class", "first");
<add> div.append("span").attr("class", "second");
<add> return div;
<add> },
<add> "selects the first matching element": function(div) {
<add> var span = div.select("span");
<add> assert.isTrue(span[0][0].parentNode === div[0][0]);
<add> assert.isTrue(span[0][1].parentNode === div[0][1]);
<add> assert.equal(span.length, 1);
<add> assert.equal(span[0].length, 2);
<add> assert.equal(span.attr("class"), "first");
<add> },
<add> "propagates parent node to the selected elements": function(div) {
<add> var span = div.select("span");
<add> assert.isNotNull(span[0].parentNode);
<add> assert.isTrue(span[0].parentNode === document.body);
<add> assert.isTrue(span[0].parentNode === div[0].parentNode);
<add> },
<add> "propagates data to the selected elements": function(div) {
<add> var data = new Object(), span = div.data([data]).select("span");
<add> assert.strictEqual(span[0][0].__data__, data);
<add> },
<add> "does not propagate data if no data was specified": function(div) {
<add> delete div[0][0].__data__;
<add> delete div[0][1].__data__;
<add> var a = new Object(), b = new Object(), span = div.select("span").data([a, b]);
<add> span = div.select("span");
<add> assert.strictEqual(span[0][0].__data__, a);
<add> assert.strictEqual(span[0][1].__data__, b);
<add> assert.isUndefined(div[0][0].__data__);
<add> assert.isUndefined(div[0][1].__data__);
<add> },
<add> "returns null if no match is found": function(div) {
<add> var div = div.select("div");
<add> assert.equal(div[0][0], null);
<add> assert.equal(div[0][1], null);
<add> assert.equal(div.length, 1);
<add> assert.equal(div[0].length, 2);
<add> }
<add> }
<add>});
<add>
<add>suite.export(module);
<ide><path>test/core/selection-selectAll-test.js
<add>require("../env");
<add>require("../../d3");
<add>
<add>var vows = require("vows"),
<add> assert = require("assert");
<add>
<add>var suite = vows.describe("selection.selectAll");
<add>
<add>suite.addBatch({
<add> "select(body)": {
<add> topic: function() {
<add> var body = d3.select("body").html("");
<add> body.append("div").attr("class", "first");
<add> body.append("div").attr("class", "second");
<add> return body;
<add> },
<add> "selects all matching elements": function(body) {
<add> var div = body.selectAll("div");
<add> assert.isTrue(div[0][0] === document.body.firstChild);
<add> assert.isTrue(div[0][1] === document.body.lastChild);
<add> assert.equal(div.length, 1);
<add> assert.equal(div[0].length, 2);
<add> },
<add> "propagates parent node to the selected elements": function(body) {
<add> var div = body.selectAll("div");
<add> assert.isNotNull(div[0].parentNode);
<add> assert.isTrue(div[0].parentNode === document.body);
<add> },
<add> "does not propagate data if data was specified": function(body) {
<add> var div = body.data([new Object()]).selectAll("div");
<add> assert.isUndefined(div[0][0].__data__);
<add> assert.isUndefined(div[0][1].__data__);
<add> },
<add> "does not propagate data if data was not specified": function(body) {
<add> var div = body.selectAll("div").data([1, 2]);
<add> div = body.data([new Object()]).selectAll("div");
<add> assert.equal(div[0][0].__data__, 1);
<add> assert.equal(div[0][1].__data__, 2);
<add> },
<add> "returns empty array if no match is found": function(body) {
<add> var span = body.selectAll("span");
<add> assert.equal(span.length, 1);
<add> assert.equal(span[0].length, 0);
<add> }
<add> }
<add>});
<add>
<add>suite.addBatch({
<add> "selectAll(div)": {
<add> topic: function() {
<add> var div = d3.select("body").html("").selectAll("div").data(d3.range(2)).enter().append("div");
<add> div.append("span").attr("class", "first");
<add> div.append("span").attr("class", "second");
<add> return div;
<add> },
<add> "selects all matching elements": function(div) {
<add> var span = div.selectAll("span");
<add> assert.equal(span.length, 2);
<add> assert.equal(span[0].length, 2);
<add> assert.isTrue(span[0][0].parentNode === div[0][0]);
<add> assert.isTrue(span[0][1].parentNode === div[0][0]);
<add> assert.isTrue(span[1][0].parentNode === div[0][1]);
<add> assert.isTrue(span[1][1].parentNode === div[0][1]);
<add> },
<add> "propagates parent node to the selected elements": function(div) {
<add> var span = div.selectAll("span");
<add> assert.isNotNull(span[0].parentNode);
<add> assert.isTrue(span[0].parentNode === div[0][0]);
<add> assert.isTrue(span[1].parentNode === div[0][1]);
<add> },
<add> "does not propagate data if data was specified": function(div) {
<add> var span = div.selectAll("span");
<add> delete span[0][0].__data__;
<add> delete span[0][1].__data__;
<add> span = div.data([new Object(), new Object()]).selectAll("span");
<add> assert.isUndefined(span[0][0].__data__);
<add> assert.isUndefined(span[0][1].__data__);
<add> },
<add> "does not propagate data if data was not specified": function(div) {
<add> var a = new Object(), b = new Object(), span = div.selectAll("span").data([a, b]);
<add> delete div[0][0].__data__;
<add> delete div[0][1].__data__;
<add> span = div.selectAll("span");
<add> assert.equal(span[0][0].__data__, a);
<add> assert.equal(span[0][1].__data__, b);
<add> },
<add> "returns empty array if no match is found": function(div) {
<add> var div = div.selectAll("div");
<add> assert.equal(div.length, 2);
<add> assert.equal(div[0].length, 0);
<add> assert.equal(div[1].length, 0);
<add> }
<add> }
<add>});
<add>
<add>suite.export(module);
<ide><path>test/core/selection-style-test.js
<ide> suite.addBatch({
<ide> },
<ide> "sets a property as a string": function(body) {
<ide> body.style("background-color", "red");
<del> assert.equal(body[0][0].style["background-color"], "red");
<add> assert.equal(document.body.style["background-color"], "red");
<ide> },
<ide> "sets a property as a number": function(body) {
<ide> body.style("opacity", .3);
<del> assert.equal(body[0][0].style["opacity"], ".3");
<add> assert.equal(document.body.style["opacity"], ".3");
<ide> },
<ide> "sets a property as a function": function(body) {
<ide> body.style("background-color", function() { return "orange"; });
<del> assert.equal(body[0][0].style["background-color"], "orange");
<add> assert.equal(document.body.style["background-color"], "orange");
<ide> },
<ide> "gets a property value": function(body) {
<del> body[0][0].style.setProperty("background-color", "yellow", "");
<add> document.body.style.setProperty("background-color", "yellow", "");
<ide> assert.equal(body.style("background-color"), "yellow");
<ide> },
<ide> "observes the specified priority": function(body) {
<ide> body.style("background-color", "green", "important");
<del> assert.equal(body[0][0].style.getPropertyPriority("background-color"), "important");
<add> assert.equal(document.body.style.getPropertyPriority("background-color"), "important");
<ide> }
<ide> }
<ide> });
<ide><path>test/env.js
<del>document = require("jsdom").jsdom("<html><head></head><body></body></html>", null, {features: {QuerySelector: true}});
<add>document = require("jsdom").jsdom("<html><head></head><body></body></html>");
<ide> window = document.createWindow();
<ide> navigator = window.navigator;
<ide>
<add>require("../lib/sizzle/sizzle");
<add>Sizzle = window.Sizzle;
<add>
<ide> process.env.TZ = "America/Los_Angeles"; | 7 |
Python | Python | set version to 2.2.0.dev4 | 178d010b25c0dd438a85565e452dca31660efc11 | <ide><path>spacy/about.py
<ide> # fmt: off
<ide>
<ide> __title__ = "spacy"
<del>__version__ = "2.2.0.dev3"
<add>__version__ = "2.2.0.dev4"
<ide> __summary__ = "Industrial-strength Natural Language Processing (NLP) with Python and Cython"
<ide> __uri__ = "https://spacy.io"
<ide> __author__ = "Explosion AI" | 1 |
Javascript | Javascript | make console work with js engines which use print | de4e51beafd20633de817228cc8f0151f5733123 | <ide><path>Libraries/polyfills/console.js
<ide> * @providesModule console
<ide> * @polyfill
<ide> * @nolint
<add> * @format
<ide> */
<ide>
<ide> /* eslint-disable */
<ide> const inspect = (function() {
<ide> function inspect(obj, opts) {
<ide> var ctx = {
<ide> seen: [],
<del> stylize: stylizeNoColor
<add> stylize: stylizeNoColor,
<ide> };
<ide> return formatValue(ctx, obj, opts.depth);
<ide> }
<ide> const inspect = (function() {
<ide> return hash;
<ide> }
<ide>
<del>
<ide> function formatValue(ctx, value, recurseTimes) {
<ide> // Primitive types cannot have properties
<ide> var primitive = formatPrimitive(ctx, value);
<ide> const inspect = (function() {
<ide>
<ide> // IE doesn't make error fields non-enumerable
<ide> // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
<del> if (isError(value)
<del> && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
<add> if (
<add> isError(value) &&
<add> (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)
<add> ) {
<ide> return formatError(value);
<ide> }
<ide>
<ide> const inspect = (function() {
<ide> }
<ide> }
<ide>
<del> var base = '', array = false, braces = ['{', '}'];
<add> var base = '',
<add> array = false,
<add> braces = ['{', '}'];
<ide>
<ide> // Make Array say that they are Array
<ide> if (isArray(value)) {
<ide> const inspect = (function() {
<ide> output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
<ide> } else {
<ide> output = keys.map(function(key) {
<del> return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
<add> return formatProperty(
<add> ctx,
<add> value,
<add> recurseTimes,
<add> visibleKeys,
<add> key,
<add> array,
<add> );
<ide> });
<ide> }
<ide>
<ide> const inspect = (function() {
<ide> return reduceToSingleString(output, base, braces);
<ide> }
<ide>
<del>
<ide> function formatPrimitive(ctx, value) {
<del> if (isUndefined(value))
<del> return ctx.stylize('undefined', 'undefined');
<add> if (isUndefined(value)) return ctx.stylize('undefined', 'undefined');
<ide> if (isString(value)) {
<del> var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
<del> .replace(/'/g, "\\'")
<del> .replace(/\\"/g, '"') + '\'';
<add> var simple =
<add> "'" +
<add> JSON.stringify(value)
<add> .replace(/^"|"$/g, '')
<add> .replace(/'/g, "\\'")
<add> .replace(/\\"/g, '"') +
<add> "'";
<ide> return ctx.stylize(simple, 'string');
<ide> }
<del> if (isNumber(value))
<del> return ctx.stylize('' + value, 'number');
<del> if (isBoolean(value))
<del> return ctx.stylize('' + value, 'boolean');
<add> if (isNumber(value)) return ctx.stylize('' + value, 'number');
<add> if (isBoolean(value)) return ctx.stylize('' + value, 'boolean');
<ide> // For some reason typeof null is "object", so special case here.
<del> if (isNull(value))
<del> return ctx.stylize('null', 'null');
<add> if (isNull(value)) return ctx.stylize('null', 'null');
<ide> }
<ide>
<del>
<ide> function formatError(value) {
<ide> return '[' + Error.prototype.toString.call(value) + ']';
<ide> }
<ide>
<del>
<ide> function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
<ide> var output = [];
<ide> for (var i = 0, l = value.length; i < l; ++i) {
<ide> if (hasOwnProperty(value, String(i))) {
<del> output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
<del> String(i), true));
<add> output.push(
<add> formatProperty(
<add> ctx,
<add> value,
<add> recurseTimes,
<add> visibleKeys,
<add> String(i),
<add> true,
<add> ),
<add> );
<ide> } else {
<ide> output.push('');
<ide> }
<ide> }
<ide> keys.forEach(function(key) {
<ide> if (!key.match(/^\d+$/)) {
<del> output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
<del> key, true));
<add> output.push(
<add> formatProperty(ctx, value, recurseTimes, visibleKeys, key, true),
<add> );
<ide> }
<ide> });
<ide> return output;
<ide> }
<ide>
<del>
<ide> function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
<ide> var name, str, desc;
<del> desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
<add> desc = Object.getOwnPropertyDescriptor(value, key) || {value: value[key]};
<ide> if (desc.get) {
<ide> if (desc.set) {
<ide> str = ctx.stylize('[Getter/Setter]', 'special');
<ide> const inspect = (function() {
<ide> }
<ide> if (str.indexOf('\n') > -1) {
<ide> if (array) {
<del> str = str.split('\n').map(function(line) {
<del> return ' ' + line;
<del> }).join('\n').substr(2);
<add> str = str
<add> .split('\n')
<add> .map(function(line) {
<add> return ' ' + line;
<add> })
<add> .join('\n')
<add> .substr(2);
<ide> } else {
<del> str = '\n' + str.split('\n').map(function(line) {
<del> return ' ' + line;
<del> }).join('\n');
<add> str =
<add> '\n' +
<add> str
<add> .split('\n')
<add> .map(function(line) {
<add> return ' ' + line;
<add> })
<add> .join('\n');
<ide> }
<ide> }
<ide> } else {
<ide> const inspect = (function() {
<ide> name = name.substr(1, name.length - 2);
<ide> name = ctx.stylize(name, 'name');
<ide> } else {
<del> name = name.replace(/'/g, "\\'")
<del> .replace(/\\"/g, '"')
<del> .replace(/(^"|"$)/g, "'");
<add> name = name
<add> .replace(/'/g, "\\'")
<add> .replace(/\\"/g, '"')
<add> .replace(/(^"|"$)/g, "'");
<ide> name = ctx.stylize(name, 'string');
<ide> }
<ide> }
<ide>
<ide> return name + ': ' + str;
<ide> }
<ide>
<del>
<ide> function reduceToSingleString(output, base, braces) {
<ide> var numLinesEst = 0;
<ide> var length = output.reduce(function(prev, cur) {
<ide> const inspect = (function() {
<ide> }, 0);
<ide>
<ide> if (length > 60) {
<del> return braces[0] +
<del> (base === '' ? '' : base + '\n ') +
<del> ' ' +
<del> output.join(',\n ') +
<del> ' ' +
<del> braces[1];
<add> return (
<add> braces[0] +
<add> (base === '' ? '' : base + '\n ') +
<add> ' ' +
<add> output.join(',\n ') +
<add> ' ' +
<add> braces[1]
<add> );
<ide> }
<ide>
<ide> return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
<ide> }
<ide>
<del>
<ide> // NOTE: These type checking functions intentionally don't use `instanceof`
<ide> // because it is fragile and can be easily faked with `Object.create()`.
<ide> function isArray(ar) {
<ide> const inspect = (function() {
<ide> }
<ide>
<ide> function isError(e) {
<del> return isObject(e) &&
<del> (objectToString(e) === '[object Error]' || e instanceof Error);
<add> return (
<add> isObject(e) &&
<add> (objectToString(e) === '[object Error]' || e instanceof Error)
<add> );
<ide> }
<ide>
<ide> function isFunction(arg) {
<ide> return typeof arg === 'function';
<ide> }
<ide>
<ide> function isPrimitive(arg) {
<del> return arg === null ||
<del> typeof arg === 'boolean' ||
<del> typeof arg === 'number' ||
<del> typeof arg === 'string' ||
<del> typeof arg === 'symbol' || // ES6 symbol
<del> typeof arg === 'undefined';
<add> return (
<add> arg === null ||
<add> typeof arg === 'boolean' ||
<add> typeof arg === 'number' ||
<add> typeof arg === 'string' ||
<add> typeof arg === 'symbol' || // ES6 symbol
<add> typeof arg === 'undefined'
<add> );
<ide> }
<ide>
<ide> function objectToString(o) {
<ide> const inspect = (function() {
<ide> return inspect;
<ide> })();
<ide>
<del>
<ide> const OBJECT_COLUMN_NAME = '(index)';
<ide> const LOG_LEVELS = {
<ide> trace: 0,
<ide> info: 1,
<ide> warn: 2,
<del> error: 3
<add> error: 3,
<ide> };
<ide> const INSPECTOR_LEVELS = [];
<ide> INSPECTOR_LEVELS[LOG_LEVELS.trace] = 'debug';
<ide> if (global.nativeLoggingHook) {
<ide> if (arguments.length === 1 && typeof arguments[0] === 'string') {
<ide> str = arguments[0];
<ide> } else {
<del> str = Array.prototype.map.call(arguments, function(arg) {
<del> return inspect(arg, {depth: 10});
<del> }).join(', ');
<add> str = Array.prototype.map
<add> .call(arguments, function(arg) {
<add> return inspect(arg, {depth: 10});
<add> })
<add> .join(', ');
<ide> }
<ide>
<ide> let logLevel = level;
<ide> if (global.nativeLoggingHook) {
<ide> INSPECTOR_LEVELS[logLevel],
<ide> str,
<ide> [].slice.call(arguments),
<del> INSPECTOR_FRAMES_TO_SKIP);
<add> INSPECTOR_FRAMES_TO_SKIP,
<add> );
<ide> }
<ide> global.nativeLoggingHook(str, logLevel);
<ide> };
<ide> }
<ide>
<ide> function repeat(element, n) {
<del> return Array.apply(null, Array(n)).map(function() { return element; });
<del> };
<add> return Array.apply(null, Array(n)).map(function() {
<add> return element;
<add> });
<add> }
<ide>
<ide> function consoleTablePolyfill(rows) {
<ide> // convert object -> array
<ide> if (global.nativeLoggingHook) {
<ide> });
<ide> space = space || ' ';
<ide> return cells.join(space + '|' + space);
<del> };
<add> }
<ide>
<ide> var separators = columnWidths.map(function(columnWidth) {
<ide> return repeat('-', columnWidth).join('');
<ide> if (global.nativeLoggingHook) {
<ide> warn: getNativeLogFunction(LOG_LEVELS.warn),
<ide> trace: getNativeLogFunction(LOG_LEVELS.trace),
<ide> debug: getNativeLogFunction(LOG_LEVELS.trace),
<del> table: consoleTablePolyfill
<add> table: consoleTablePolyfill,
<ide> };
<ide>
<ide> // If available, also call the original `console` method since that is
<ide> if (global.nativeLoggingHook) {
<ide> });
<ide> }
<ide> } else if (!global.console) {
<del> function consoleLoggingStub() {};
<add> const log = global.print || function consoleLoggingStub() {};
<ide> global.console = {
<del> error: consoleLoggingStub,
<del> info: consoleLoggingStub,
<del> log: consoleLoggingStub,
<del> warn: consoleLoggingStub,
<del> trace: consoleLoggingStub,
<del> debug: consoleLoggingStub,
<del> table: consoleLoggingStub
<add> error: log,
<add> info: log,
<add> log: log,
<add> warn: log,
<add> trace: log,
<add> debug: log,
<add> table: log,
<ide> };
<ide> } | 1 |
Text | Text | add types of print statements. | 864c0af2f5a8fbf6918921e4c9310c686dea5dd4 | <ide><path>guide/english/kotlin/hello-world/index.md
<ide> fun main(args : Array<String>): Unit {...}
<ide>
<ide> ### Print Statement
<ide>
<del>The println function takes a string as an argument and prints it to the screen. In this case we are printing the string "Hello, World!". Note that string literals are declared using double quotes ```"String"```.
<add>The println function takes a string as an argument and prints it to the screen. In this case we are printing the string "Hello, World!". Note that string literals are declared using double quotes ```"String"```.
<add>Printing in kotlin can be done in two ways; using "println" function and "print" function. The "println" function prints things on a new line whereas the "print" function prints things on the current line.
<ide>
<ide>
<ide> If you'd like to know more about Kotlin Syntax and start writing awesome programs you should check the awesome Kotlin Official Documentation: https://kotlinlang.org/docs/reference/ | 1 |
Javascript | Javascript | detect rc build with x.y.z-rc.n format | 9f727f5e03bbe6f798f0a084bf318f78f064013d | <ide><path>deps/npm/node_modules/node-gyp/lib/install.js
<ide> function install (gyp, argv, callback) {
<ide> // pick out 'nightly', 'next-nightly' or 'rc' from the version string if it's there
<ide> // adjust URL accordingly
<ide> function getDefaultIojsUrl(version) {
<del> var versionMatch = version.match(/^v\d+\.\d+\.\d+-(?:(?:(nightly|next-nightly)\d{8}[0-9a-f]{10})|(?:(rc)\d+))$/)
<add> var versionMatch = version.match(/^v\d+\.\d+\.\d+-(?:(?:(nightly|next-nightly)\.?\d{8}[0-9a-f]{10})|(?:(rc)\.\d+))$/)
<ide> var distType = versionMatch ? versionMatch[1] || versionMatch[2] : 'release'
<ide> var defaultUrl = `https://iojs.org/download/${distType}`
<ide> return defaultUrl
<ide> function getDefaultIojsUrl(version) {
<ide> if (require.main === module) {
<ide> var assert = require('assert')
<ide> console.log('test v2.3.4 -> https://iojs.org/download/release')
<del> assert(getDefaultIojsUrl('v2.3.4', 'https://iojs.org/download/release'))
<add> assert.equal(getDefaultIojsUrl('v2.3.4'), 'https://iojs.org/download/release')
<ide> console.log('test v2.3.4-nightly12345678aaaaaaaaaa -> https://iojs.org/download/nightly')
<del> assert(getDefaultIojsUrl('v2.3.4-nightly12345678aaaaaaaaaa', 'https://iojs.org/download/nightly'))
<add> assert.equal(getDefaultIojsUrl('v2.3.4-nightly12345678aaaaaaaaaa'), 'https://iojs.org/download/nightly')
<add> console.log('test v2.3.4-nightly.12345678aaaaaaaaaa -> https://iojs.org/download/nightly')
<add> assert.equal(getDefaultIojsUrl('v2.3.4-nightly.12345678aaaaaaaaaa'), 'https://iojs.org/download/nightly')
<ide> console.log('test v2.3.4-next-nightly12345678aaaaaaaaaa -> https://iojs.org/download/release/next-nightly')
<del> assert(getDefaultIojsUrl('v2.3.4-next-nightly12345678aaaaaaaaaa', 'https://iojs.org/download/next-nightly'))
<del> console.log('test v2.3.4-rc100 -> https://iojs.org/download/rc')
<del> assert(getDefaultIojsUrl('v2.3.4-rc100', 'https://iojs.org/download/rc'))
<add> assert.equal(getDefaultIojsUrl('v2.3.4-next-nightly12345678aaaaaaaaaa'), 'https://iojs.org/download/next-nightly')
<add> console.log('test v2.3.4-next-nightly.12345678aaaaaaaaaa -> https://iojs.org/download/release/next-nightly')
<add> assert.equal(getDefaultIojsUrl('v2.3.4-next-nightly.12345678aaaaaaaaaa'), 'https://iojs.org/download/next-nightly')
<add> console.log('test v2.3.4-rc.100 -> https://iojs.org/download/rc')
<add> assert.equal(getDefaultIojsUrl('v2.3.4-rc.100'), 'https://iojs.org/download/rc')
<ide> } | 1 |
Python | Python | add integration tests for minio | ce651a5fb3bc8d18f215d69f82dfc9c01b42676d | <ide><path>integration/storage/base.py
<ide> def _test_objects(self, do_upload, do_download, size=1 * MB):
<ide> self.driver.delete_object(obj)
<ide>
<ide> # check that a missing file can't be deleted or looked up
<del> with self.assertRaises(types.ObjectDoesNotExistError):
<del> self.driver.delete_object(obj)
<del> with self.assertRaises(types.ObjectDoesNotExistError):
<del> self.driver.get_object(container.name, blob_name)
<add> self.assert_file_is_missing(container, obj)
<ide>
<ide> # check that the file is deleted
<ide> blobs = self.driver.list_container_objects(container)
<ide> self.assertEqual([blob.name for blob in blobs], [blob_name[::-1]])
<ide>
<add> def assert_file_is_missing(self, container, obj):
<add> with self.assertRaises(types.ObjectDoesNotExistError):
<add> self.driver.delete_object(obj)
<add> with self.assertRaises(types.ObjectDoesNotExistError):
<add> self.driver.get_object(container.name, obj.name)
<add>
<ide> def test_objects(self, size=1 * MB):
<ide> def do_upload(container, blob_name, content):
<ide> infile = self._create_tempfile(content=content)
<ide> class ContainerTestBase(TestBase):
<ide> image = None
<ide> version = 'latest'
<ide> environment = {}
<add> command = None
<ide> ready_message = None
<ide>
<ide> host = 'localhost'
<ide> def setUpClass(cls):
<ide>
<ide> cls.container = cls.client.containers.run(
<ide> '{}:{}'.format(cls.image, cls.version),
<add> command=cls.command,
<ide> detach=True,
<ide> auto_remove=True,
<ide> ports={cls.port: cls.port},
<ide><path>integration/storage/test_minio.py
<add># Licensed to the Apache Software Foundation (ASF) under one or more
<add># contributor license agreements. See the NOTICE file distributed with
<add># this work for additional information regarding copyright ownership.
<add># The ASF licenses this file to You under the Apache License, Version 2.0
<add># (the 'License'); you may not use this file except in compliance with
<add># the License. You may obtain a copy of the License at
<add>#
<add># http://www.apache.org/licenses/LICENSE-2.0
<add>#
<add># Unless required by applicable law or agreed to in writing, software
<add># distributed under the License is distributed on an 'AS IS' BASIS,
<add># WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<add># See the License for the specific language governing permissions and
<add># limitations under the License.
<add>
<add>import sys
<add>import unittest
<add>
<add>from integration.storage.base import Integration
<add>from libcloud.storage import types
<add>
<add>
<add>class MinioTest(Integration.ContainerTestBase):
<add> provider = 'minio'
<add>
<add> account = 'minioaccount'
<add> secret = 'miniopassword'
<add>
<add> image = 'minio/minio'
<add> port = 9000
<add> environment = {'MINIO_ROOT_USER': account, 'MINIO_ROOT_PASSWORD': secret}
<add> command = ['server', '/data']
<add> ready_message = b'IAM initialization complete'
<add>
<add> def test_cdn_url(self):
<add> self.skipTest('Not implemented in driver')
<add>
<add> def assert_file_is_missing(self, container, obj):
<add> with self.assertRaises(types.ObjectDoesNotExistError):
<add> self.driver.get_object(container.name, obj.name)
<add>
<add>
<add>if __name__ == '__main__':
<add> sys.exit(unittest.main()) | 2 |
PHP | PHP | add tests for addoptionalplugin() | a78d43b7fe6e042ad11f16a22fcf70fb4ef97a9b | <ide><path>tests/TestCase/Http/BaseApplicationTest.php
<ide>
<ide> /**
<ide> * Base application test.
<add> *
<add> * @coversDefaultClass \Cake\Http\BaseApplication
<ide> */
<ide> class BaseApplicationTest extends TestCase
<ide> {
<ide> public function testPluginBootstrapRecursivePlugins()
<ide> 'Nested plugin should have bootstrap run'
<ide> );
<ide> }
<add>
<add> /**
<add> * Tests that loading a non existing plugin through addOptionalPlugin() does not throw an exception
<add> *
<add> * @return void
<add> * @covers ::addOptionalPlugin
<add> */
<add> public function testAddOptionalPluginLoadingNonExistingPlugin()
<add> {
<add> $app = $this->getMockForAbstractClass(BaseApplication::class, [$this->path]);
<add> $pluginCountBefore = count($app->getPlugins());
<add> $nonExistingPlugin = 'NonExistingPlugin';
<add> $app->addOptionalPlugin($nonExistingPlugin);
<add> $pluginCountAfter = count($app->getPlugins());
<add> $this->assertSame($pluginCountBefore, $pluginCountAfter);
<add> }
<add>
<add> /**
<add> * Tests that loading an existing plugin through addOptionalPlugin() works
<add> *
<add> * @return void
<add> * @covers ::addOptionalPlugin
<add> */
<add> public function testAddOptionalPluginLoadingNonExistingPluginValid()
<add> {
<add> $app = $this->getMockForAbstractClass(BaseApplication::class, [$this->path]);
<add> $app->addOptionalPlugin(TestPlugin::class);
<add>
<add> $this->assertCount(1, $app->getPlugins());
<add> $this->assertTrue($app->getPlugins()->has('TestPlugin'));
<add> }
<ide> } | 1 |
Text | Text | clarify eventtype in fs.watch | b209a6e2715f098985a24cde9023b4aa3b5a25c5 | <ide><path>doc/api/fs.md
<ide> The listener callback gets two arguments `(eventType, filename)`. `eventType` i
<ide> `'rename'` or `'change'`, and `filename` is the name of the file which triggered
<ide> the event.
<ide>
<del>Please note the listener callback is attached to the `'change'` event
<del>fired by [`fs.FSWatcher`][], but they are not the same thing.
<add>Note that on most platforms, `'rename'` is emitted whenever a filename appears
<add>or disappears in the directory.
<add>
<add>Also note the listener callback is attached to the `'change'` event fired by
<add>[`fs.FSWatcher`][], but it is not the same thing as the `'change'` value of
<add>`eventType`.
<ide>
<ide> ### Caveats
<ide> | 1 |
Javascript | Javascript | fix interpolant alias | 2254a241d084615ad5fe5fa35e515c6c2f556041 | <ide><path>src/math/Interpolant.js
<ide> Object.assign( Interpolant.prototype, {
<ide>
<ide> constructor: Interpolant,
<ide>
<del> beforeStart_: //( 0, t, t0 ), returns this.resultBuffer
<del> Interpolant.prototype.copySampleValue_,
<del>
<del> afterEnd_: //( N-1, tN-1, t ), returns this.resultBuffer
<del> Interpolant.prototype.copySampleValue_,
<del>
<ide> evaluate: function( t ) {
<ide>
<ide> var pp = this.parameterPositions,
<ide> Object.assign( Interpolant.prototype, {
<ide>
<ide> } );
<ide>
<add>//!\ DECLARE ALIAS AFTER assign prototype !
<add>Object.assign( Interpolant.prototype, {
<add>
<add> //( 0, t, t0 ), returns this.resultBuffer
<add> beforeStart_: Interpolant.prototype.copySampleValue_,
<add>
<add> //( N-1, tN-1, t ), returns this.resultBuffer
<add> afterEnd_: Interpolant.prototype.copySampleValue_,
<add>
<add>} );
<ide>
<ide> export { Interpolant }; | 1 |
Text | Text | fix typo in docker-context-files/readme.md | b21c3b58aa05821aa950a7c9aac9b92558156da2 | <ide><path>docker-context-files/README.md
<ide> under the License.
<ide> -->
<ide>
<del>This folder is par of the Docker context.
<add>This folder is part of the Docker context.
<ide>
<ide> Most of other folders in Airflow are not part of the context in order to make the context smaller.
<ide> | 1 |
Python | Python | fix typo in test | 90ebbb8e4e37c2d6562735a5192d3116de2621ac | <ide><path>numpy/core/tests/test_print.py
<ide> def _test_redirected_print(x, tp):
<ide> err_msg='print failed for type%s' % tp)
<ide>
<ide> def check_float_type_print(tp):
<del> for x in [0, 1,-1, 1e20, np.inf, -np.inf, np.nan]
<add> for x in [0, 1,-1, 1e20, np.inf, -np.inf, np.nan]:
<ide> _test_redirected_print(float(x), tp)
<ide>
<ide> if tp(1e10).itemsize > 4: | 1 |
Javascript | Javascript | invoke callback with common.mustcall() | 1df9340d0b460c68ac5006d881b0337fd26202fe | <ide><path>test/parallel/test-crypto-domain.js
<ide> if (!common.hasCrypto)
<ide> common.skip('missing crypto');
<ide>
<ide> const assert = require('assert');
<del>const domain = require('domain');
<ide> const crypto = require('crypto');
<add>const domain = require('domain');
<ide>
<ide> function test(fn) {
<ide> const ex = new Error('BAM');
<ide><path>test/parallel/test-crypto-hash.js
<ide> if (!common.hasCrypto)
<ide> common.skip('missing crypto');
<ide>
<ide> const assert = require('assert');
<del>const fs = require('fs');
<ide> const crypto = require('crypto');
<add>const fs = require('fs');
<add>
<ide> const fixtures = require('../common/fixtures');
<ide>
<ide> // Test hashing
<ide> const fileStream = fs.createReadStream(fn);
<ide> fileStream.on('data', function(data) {
<ide> sha1Hash.update(data);
<ide> });
<del>fileStream.on('close', function() {
<add>fileStream.on('close', common.mustCall(function() {
<ide> assert.strictEqual(sha1Hash.digest('hex'),
<ide> '22723e553129a336ad96e10f6aecdf0f45e4149e',
<ide> 'Test SHA1 of sample.png');
<del>});
<add>}));
<ide>
<ide> // Issue #2227: unknown digest method should throw an error.
<ide> assert.throws(function() { | 2 |
Python | Python | remove deprecated arguments from new run_clm | 9eb3a410cd826e47b7c97db8af4056a2465e65eb | <ide><path>examples/language-modeling/run_clm.py
<ide> def tokenize_function(examples):
<ide> )
<ide>
<ide> if data_args.block_size <= 0:
<del> block_size = tokenizer.max_len
<add> block_size = tokenizer.model_max_length
<ide> else:
<del> if data_args.block_size > tokenizer.max_len:
<add> if data_args.block_size > tokenizer.model_max_length:
<ide> logger.warn(
<ide> f"The block_size passed ({data_args.block_size}) is larger than the maximum length for the model"
<del> f"({tokenizer.max_len}). Using block_size={tokenizer.max_len}."
<add> f"({tokenizer.model_max_length}). Using block_size={tokenizer.model_max_length}."
<ide> )
<del> block_size = min(data_args.block_size, tokenizer.max_len)
<add> block_size = min(data_args.block_size, tokenizer.model_max_length)
<ide>
<ide> # Main data processing function that will concatenate all texts from our dataset and generate chunks of block_size.
<ide> def group_texts(examples): | 1 |
PHP | PHP | add object to text insert test case | a5185ca52809adf225d9e1047f288f09a3214f64 | <ide><path>tests/TestCase/Utility/TextTest.php
<ide> */
<ide> namespace Cake\Test\TestCase\Utility;
<ide>
<add>use Cake\I18n\Time;
<ide> use Cake\TestSuite\TestCase;
<ide> use Cake\Utility\Text;
<ide>
<ide> public function testInsert()
<ide> $expected = 'switching 10 by 5';
<ide> $result = Text::insert($string, ['timeout_count' => 10, 'timeout' => 5]);
<ide> $this->assertEquals($expected, $result);
<add> $string = 'inserting a :user.email';
<add> $expected = 'inserting a [email protected]';
<add> $result = Text::insert($string, [
<add> 'user.email' => '[email protected]',
<add> 'user.id' => 2,
<add> 'user.created' => Time::parse('2016-01-01')
<add> ]);
<add> $this->assertEquals($expected, $result);
<ide> }
<ide>
<ide> /** | 1 |
Ruby | Ruby | make use of the inherited initializer | a53ef972066503e601e023748949b6668fce51e3 | <ide><path>actionpack/lib/action_dispatch/routing/mapper.rb
<ide> class SingletonResource < Resource #:nodoc:
<ide> DEFAULT_ACTIONS = [:show, :create, :update, :destroy, :new, :edit]
<ide>
<ide> def initialize(entities, options)
<add> super
<add>
<ide> @as = nil
<del> @name = entities.to_s
<del> @path = (options[:path] || @name).to_s
<ide> @controller = (options[:controller] || plural).to_s
<ide> @as = options[:as]
<del> @options = options
<ide> end
<ide>
<ide> def plural | 1 |
PHP | PHP | extract helper method for generating radio ids | 912a2ba760c435baede88d45b8313ac2169c0787 | <ide><path>src/View/Widget/Radio.php
<ide> protected function _renderInput($val, $text, $data) {
<ide> $radio['name'] = $data['name'];
<ide>
<ide> if (empty($radio['id'])) {
<del> $radio['id'] = mb_strtolower(Inflector::slug($radio['name'] . '_' . $radio['value'], '-'));
<add> $radio['id'] = $this->_id($radio);
<ide> }
<ide>
<ide> if (isset($data['val']) && strval($data['val']) === strval($radio['value'])) {
<ide> protected function _renderLabel($radio, $label, $input, $escape) {
<ide> return $this->_label->render($labelAttrs);
<ide> }
<ide>
<add>/**
<add> * Generate an ID attribute for a radio button.
<add> *
<add> * Ensures that id's for a given set of fields are unique.
<add> *
<add> * @param array $radio The radio properties.
<add> * @return string Generated id.
<add> */
<add> protected function _id($radio) {
<add> return mb_strtolower(Inflector::slug($radio['name'] . '_' . $radio['value'], '-'));}
<add>
<ide> } | 1 |
Text | Text | fix some 404 links | 509a184820ca91d6935213cb3008cb881d8a3a5d | <ide><path>doc/guides/contributing/pull-requests.md
<ide> included in the API docs will also be checked when running `make lint` (or
<ide> use `REPLACEME` for the version number in the documentation YAML.
<ide>
<ide> For contributing C++ code, you may want to look at the
<del>[C++ Style Guide](../../cpp-style-guide.md), as well as the
<add>[C++ Style Guide](../cpp-style-guide.md), as well as the
<ide> [README of `src/`](../../../src/README.md) for an overview over Node.js
<ide> C++ internals.
<ide>
<ide> If you want to know more about the code review and the landing process, see the
<ide> [Collaborator Guide][].
<ide>
<ide> [approved]: #getting-approvals-for-your-pull-request
<del>[benchmark results]: ../../../benchmark/writing-and-running-benchmarks.md
<add>[benchmark results]: ../writing-and-running-benchmarks.md
<ide> [Building guide]: ../../../BUILDING.md
<ide> [CI (Continuous Integration) test run]: #ci-testing
<ide> [Code of Conduct]: https://github.com/nodejs/admin/blob/master/CODE_OF_CONDUCT.md
<del>[Collaborator Guide]: ../../../COLLABORATOR_GUIDE.md
<add>[Collaborator Guide]: ../collaborator-guide.md
<ide> [guide for writing tests in Node.js]: ../writing-tests.md
<ide> [hiding-a-comment]: https://help.github.com/articles/managing-disruptive-comments/#hiding-a-comment
<ide> [https://ci.nodejs.org/]: https://ci.nodejs.org/
<ide> [IRC in the #node-dev channel]: https://webchat.freenode.net?channels=node-dev&uio=d4
<del>[Onboarding guide]: ../../onboarding.md
<add>[Onboarding guide]: ../../../onboarding.md
<ide> [running tests]: ../../../BUILDING.md#running-tests
<ide><path>onboarding.md
<ide> needs to be pointed out separately during the onboarding.
<ide> the [summit](https://github.com/nodejs/summit) repository for details.
<ide>
<ide> [Code of Conduct]: https://github.com/nodejs/admin/blob/master/CODE_OF_CONDUCT.md
<del>[`author-ready`]: https://github.com/nodejs/node/blob/master/COLLABORATOR_GUIDE.md#author-ready-pull-requests
<add>[`author-ready`]: doc/guides/collaborator-guide.md#author-ready-pull-requests
<ide> [`core-validate-commit`]: https://github.com/nodejs/core-validate-commit
<ide> [`git-node`]: https://github.com/nodejs/node-core-utils/blob/master/docs/git-node.md
<ide> [`node-core-utils`]: https://github.com/nodejs/node-core-utils
<del>[Landing Pull Requests]: https://github.com/nodejs/node/blob/master/COLLABORATOR_GUIDE.md#landing-pull-requests
<add>[Landing Pull Requests]: doc/guides/collaborator-guide.md#landing-pull-requests
<ide> [Publicizing or hiding organization membership]: https://help.github.com/articles/publicizing-or-hiding-organization-membership/
<ide> [set up the credentials]: https://github.com/nodejs/node-core-utils#setting-up-credentials
<ide> [two-factor authentication]: https://help.github.com/articles/securing-your-account-with-two-factor-authentication-2fa/
<ide> [using a TOTP mobile app]: https://help.github.com/articles/configuring-two-factor-authentication-via-a-totp-mobile-app/
<del>[who-to-cc]: ../COLLABORATOR_GUIDE.md#who-to-cc-in-the-issue-tracker
<add>[who-to-cc]: doc/guides/collaborator-guide.md#who-to-cc-in-the-issue-tracker | 2 |
Javascript | Javascript | set ios 11 in saucelabs to 11.3 | 96c4cb6694d6775ef4892ed39556b7927b0897a7 | <ide><path>karma-shared.conf.js
<ide> module.exports = function(config, specificOptions) {
<ide> base: 'SauceLabs',
<ide> browserName: 'iphone',
<ide> platform: 'OS X 10.12',
<del> version: '11'
<add> version: '11.3'
<ide> },
<ide>
<ide> 'BS_Chrome': { | 1 |
Text | Text | fix paragraph order in stream.md | 3662934b5ac9002586676fdec662bea957144b34 | <ide><path>doc/api/stream.md
<ide> buffered writes in a more optimized manner.
<ide>
<ide> See also: [`writable.uncork()`][].
<ide>
<add>##### writable.destroy([error])
<add><!-- YAML
<add>added: v8.0.0
<add>-->
<add>
<add>* Returns: {this}
<add>
<add>Destroy the stream, and emit the passed `error` and a `close` event.
<add>After this call, the writable stream has ended and subsequent calls
<add>to `write` / `end` will give an `ERR_STREAM_DESTROYED` error.
<add>Implementors should not override this method,
<add>but instead implement [`writable._destroy`][writable-_destroy].
<add>
<ide> ##### writable.end([chunk][, encoding][, callback])
<ide> <!-- YAML
<ide> added: v0.9.4
<ide> write('hello', () => {
<ide>
<ide> A Writable stream in object mode will always ignore the `encoding` argument.
<ide>
<del>##### writable.destroy([error])
<del><!-- YAML
<del>added: v8.0.0
<del>-->
<del>
<del>* Returns: {this}
<del>
<del>Destroy the stream, and emit the passed `error` and a `close` event.
<del>After this call, the writable stream has ended and subsequent calls
<del>to `write` / `end` will give an `ERR_STREAM_DESTROYED` error.
<del>Implementors should not override this method,
<del>but instead implement [`writable._destroy`][writable-_destroy].
<del>
<ide> ### Readable Streams
<ide>
<ide> Readable streams are an abstraction for a *source* from which data is
<ide> In general, the `readable.pipe()` and `'data'` event mechanisms are easier to
<ide> understand than the `'readable'` event. However, handling `'readable'` might
<ide> result in increased throughput.
<ide>
<add>##### readable.destroy([error])
<add><!-- YAML
<add>added: v8.0.0
<add>-->
<add>
<add>* `error` {Error} Error which will be passed as payload in `'error'` event
<add>* Returns: {this}
<add>
<add>Destroy the stream, and emit `'error'` and `close`. After this call, the
<add>readable stream will release any internal resources and subsequent calls
<add>to `push` will be ignored.
<add>Implementors should not override this method, but instead implement
<add>[`readable._destroy`][readable-_destroy].
<add>
<ide> ##### readable.isPaused()
<ide> <!-- YAML
<ide> added: v0.11.14
<ide> to prevent memory leaks.
<ide> The [`process.stderr`][] and [`process.stdout`][] Writable streams are never
<ide> closed until the Node.js process exits, regardless of the specified options.
<ide>
<del>##### readable.readableHighWaterMark
<del><!-- YAML
<del>added: v9.3.0
<del>-->
<del>
<del>* Returns: {number}
<del>
<del>Returns the value of `highWaterMark` passed when constructing this
<del>`Readable`.
<del>
<ide> ##### readable.read([size])
<ide> <!-- YAML
<ide> added: v0.9.4
<ide> also be emitted.
<ide> Calling [`stream.read([size])`][stream-read] after the [`'end'`][] event has
<ide> been emitted will return `null`. No runtime error will be raised.
<ide>
<add>##### readable.readableHighWaterMark
<add><!-- YAML
<add>added: v9.3.0
<add>-->
<add>
<add>* Returns: {number}
<add>
<add>Returns the value of `highWaterMark` passed when constructing this
<add>`Readable`.
<add>
<ide> ##### readable.readableLength
<ide> <!-- YAML
<ide> added: v9.4.0
<ide> myReader.on('readable', () => {
<ide> });
<ide> ```
<ide>
<del>##### readable.destroy([error])
<del><!-- YAML
<del>added: v8.0.0
<del>-->
<del>
<del>* `error` {Error} Error which will be passed as payload in `'error'` event
<del>* Returns: {this}
<del>
<del>Destroy the stream, and emit `'error'` and `close`. After this call, the
<del>readable stream will release any internal resources and subsequent calls
<del>to `push` will be ignored.
<del>Implementors should not override this method, but instead implement
<del>[`readable._destroy`][readable-_destroy].
<del>
<ide> ##### readable[@@asyncIterator]
<ide> <!-- YAML
<ide> added: REPLACEME | 1 |
Ruby | Ruby | convert pathname test to spec | 85ff9add185fc24d99b296cf9cca3071b6d865c0 | <ide><path>Library/Homebrew/test/pathname_spec.rb
<add>require "tmpdir"
<add>require "extend/pathname"
<add>require "install_renamed"
<add>
<add>describe Pathname do
<add> include FileUtils
<add>
<add> let(:src) { Pathname.new(Dir.mktmpdir) }
<add> let(:dst) { Pathname.new(Dir.mktmpdir) }
<add> let(:file) { src/"foo" }
<add> let(:dir) { src/"bar" }
<add>
<add> after(:each) { rm_rf [src, dst] }
<add>
<add> describe DiskUsageExtension do
<add> before(:each) do
<add> mkdir_p dir/"a-directory"
<add> touch [dir/".DS_Store", dir/"a-file"]
<add> File.truncate(dir/"a-file", 1_048_576)
<add> ln_s dir/"a-file", dir/"a-symlink"
<add> ln dir/"a-file", dir/"a-hardlink"
<add> end
<add>
<add> describe "#file_count" do
<add> it "returns the number of files in a directory" do
<add> expect(dir.file_count).to eq(3)
<add> end
<add> end
<add>
<add> describe "#abv" do
<add> context "when called on a directory" do
<add> it "returns a string with the file count and disk usage" do
<add> expect(dir.abv).to eq("3 files, 1M")
<add> end
<add> end
<add>
<add> context "when called on a file" do
<add> it "returns the disk usage" do
<add> expect((dir/"a-file").abv).to eq("1M")
<add> end
<add> end
<add> end
<add> end
<add>
<add> describe "#rmdir_if_possible" do
<add> before(:each) { mkdir_p dir }
<add>
<add> it "returns true and removes a directory if it doesn't contain files" do
<add> expect(dir.rmdir_if_possible).to be true
<add> expect(dir).not_to exist
<add> end
<add>
<add> it "returns false and doesn't delete a directory if it contains files" do
<add> touch dir/"foo"
<add> expect(dir.rmdir_if_possible).to be false
<add> expect(dir).to be_a_directory
<add> end
<add>
<add> it "ignores .DS_Store files" do
<add> touch dir/".DS_Store"
<add> expect(dir.rmdir_if_possible).to be true
<add> expect(dir).not_to exist
<add> end
<add> end
<add>
<add> describe "#write" do
<add> it "creates a file and writes to it" do
<add> expect(file).not_to exist
<add> file.write("CONTENT")
<add> expect(File.read(file)).to eq("CONTENT")
<add> end
<add>
<add> it "raises an error if the file already exists" do
<add> touch file
<add> expect { file.write("CONTENT") }.to raise_error(RuntimeError)
<add> end
<add> end
<add>
<add> describe "#append_lines" do
<add> it "appends lines to a file" do
<add> touch file
<add>
<add> file.append_lines("CONTENT")
<add> expect(File.read(file)).to eq <<-EOS.undent
<add> CONTENT
<add> EOS
<add>
<add> file.append_lines("CONTENTS")
<add> expect(File.read(file)).to eq <<-EOS.undent
<add> CONTENT
<add> CONTENTS
<add> EOS
<add> end
<add>
<add> it "raises an error if the file does not exist" do
<add> expect(file).not_to exist
<add> expect { file.append_lines("CONTENT") }.to raise_error(RuntimeError)
<add> end
<add> end
<add>
<add> describe "#atomic_write" do
<add> it "atomically replaces a file" do
<add> touch file
<add> file.atomic_write("CONTENT")
<add> expect(File.read(file)).to eq("CONTENT")
<add> end
<add>
<add> it "preserves permissions" do
<add> File.open(file, "w", 0100777).close
<add> file.atomic_write("CONTENT")
<add> expect(file.stat.mode).to eq(0100777 & ~File.umask)
<add> end
<add>
<add> it "preserves default permissions" do
<add> file.atomic_write("CONTENT")
<add> sentinel = file.parent.join("sentinel")
<add> touch sentinel
<add> expect(file.stat.mode).to eq(sentinel.stat.mode)
<add> end
<add> end
<add>
<add> describe "#ensure_writable" do
<add> it "makes a file writable and restores permissions afterwards" do
<add> touch file
<add> chmod 0555, file
<add> expect(file).not_to be_writable
<add> file.ensure_writable do
<add> expect(file).to be_writable
<add> end
<add> expect(file).not_to be_writable
<add> end
<add> end
<add>
<add> describe "#extname" do
<add> it "supports common multi-level archives" do
<add> expect(Pathname.new("foo-0.1.tar.gz").extname).to eq(".tar.gz")
<add> expect(Pathname.new("foo-0.1.cpio.gz").extname).to eq(".cpio.gz")
<add> end
<add> end
<add>
<add> describe "#stem" do
<add> it "returns the basename without double extensions" do
<add> expect(Pathname("foo-0.1.tar.gz").stem).to eq("foo-0.1")
<add> expect(Pathname("foo-0.1.cpio.gz").stem).to eq("foo-0.1")
<add> end
<add> end
<add>
<add> describe "#install" do
<add> before(:each) do
<add> (src/"a.txt").write "This is sample file a."
<add> (src/"b.txt").write "This is sample file b."
<add> end
<add>
<add> it "raises an error if the file doesn't exist" do
<add> expect { dst.install "non_existent_file" }.to raise_error(Errno::ENOENT)
<add> end
<add>
<add> it "installs a file to a directory with its basename" do
<add> touch file
<add> dst.install(file)
<add> expect(dst/file.basename).to exist
<add> expect(file).not_to exist
<add> end
<add>
<add> it "creates intermediate directories" do
<add> touch file
<add> expect(dir).not_to be_a_directory
<add> dir.install(file)
<add> expect(dir).to be_a_directory
<add> end
<add>
<add> it "can install a file" do
<add> dst.install src/"a.txt"
<add> expect(dst/"a.txt").to exist, "a.txt was not installed"
<add> expect(dst/"b.txt").not_to exist, "b.txt was installed."
<add> end
<add>
<add> it "can install an array of files" do
<add> dst.install [src/"a.txt", src/"b.txt"]
<add>
<add> expect(dst/"a.txt").to exist, "a.txt was not installed"
<add> expect(dst/"b.txt").to exist, "b.txt was not installed"
<add> end
<add>
<add> it "can install a directory" do
<add> bin = src/"bin"
<add> bin.mkpath
<add> mv Dir[src/"*.txt"], bin
<add> dst.install bin
<add>
<add> expect(dst/"bin/a.txt").to exist, "a.txt was not installed"
<add> expect(dst/"bin/b.txt").to exist, "b.txt was not installed"
<add> end
<add>
<add> it "supports renaming files" do
<add> dst.install src/"a.txt" => "c.txt"
<add>
<add> expect(dst/"c.txt").to exist, "c.txt was not installed"
<add> expect(dst/"a.txt").not_to exist, "a.txt was installed but not renamed"
<add> expect(dst/"b.txt").not_to exist, "b.txt was installed"
<add> end
<add>
<add> it "supports renaming multiple files" do
<add> dst.install(src/"a.txt" => "c.txt", src/"b.txt" => "d.txt")
<add>
<add> expect(dst/"c.txt").to exist, "c.txt was not installed"
<add> expect(dst/"d.txt").to exist, "d.txt was not installed"
<add> expect(dst/"a.txt").not_to exist, "a.txt was installed but not renamed"
<add> expect(dst/"b.txt").not_to exist, "b.txt was installed but not renamed"
<add> end
<add>
<add> it "supports renaming directories" do
<add> bin = src/"bin"
<add> bin.mkpath
<add> mv Dir[src/"*.txt"], bin
<add> dst.install bin => "libexec"
<add>
<add> expect(dst/"bin").not_to exist, "bin was installed but not renamed"
<add> expect(dst/"libexec/a.txt").to exist, "a.txt was not installed"
<add> expect(dst/"libexec/b.txt").to exist, "b.txt was not installed"
<add> end
<add>
<add> it "can install directories as relative symlinks" do
<add> bin = src/"bin"
<add> bin.mkpath
<add> mv Dir[src/"*.txt"], bin
<add> dst.install_symlink bin
<add>
<add> expect(dst/"bin").to be_a_symlink
<add> expect(dst/"bin").to be_a_directory
<add> expect(dst/"bin/a.txt").to exist
<add> expect(dst/"bin/b.txt").to exist
<add> expect((dst/"bin").readlink).to be_relative
<add> end
<add>
<add> it "can install relative paths as symlinks" do
<add> dst.install_symlink "foo" => "bar"
<add> expect((dst/"bar").readlink).to eq(Pathname.new("foo"))
<add> end
<add> end
<add>
<add> describe InstallRenamed do
<add> before(:each) do
<add> dst.extend(InstallRenamed)
<add> end
<add>
<add> it "renames the installed file if it already exists" do
<add> file.write "a"
<add> dst.install file
<add>
<add> file.write "b"
<add> dst.install file
<add>
<add> expect(File.read(dst/file.basename)).to eq("a")
<add> expect(File.read(dst/"#{file.basename}.default")).to eq("b")
<add> end
<add>
<add> it "renames the installed directory" do
<add> file.write "a"
<add> dst.install src
<add> expect(File.read(dst/src.basename/file.basename)).to eq("a")
<add> end
<add>
<add> it "recursively renames directories" do
<add> (dst/dir.basename).mkpath
<add> (dst/dir.basename/"another_file").write "a"
<add> dir.mkpath
<add> (dir/"another_file").write "b"
<add> dst.install dir
<add> expect(File.read(dst/dir.basename/"another_file.default")).to eq("b")
<add> end
<add> end
<add>
<add> describe "#cp_path_sub" do
<add> it "copies a file and replaces the given pattern" do
<add> file.write "a"
<add> file.cp_path_sub src, dst
<add> expect(File.read(dst/file.basename)).to eq("a")
<add> end
<add>
<add> it "copies a directory and replaces the given pattern" do
<add> dir.mkpath
<add> dir.cp_path_sub src, dst
<add> expect(dst/dir.basename).to be_a_directory
<add> end
<add> end
<add>end
<add>
<add>describe FileUtils do
<add> let(:dst) { Pathname.new(Dir.mktmpdir) }
<add>
<add> describe "#mkdir" do
<add> it "creates indermediate directories" do
<add> described_class.mkdir dst/"foo/bar/baz" do
<add> expect(dst/"foo/bar/baz").to exist, "foo/bar/baz was not created"
<add> expect(dst/"foo/bar/baz").to be_a_directory, "foo/bar/baz was not a directory structure"
<add> end
<add> end
<add> end
<add>end
<ide><path>Library/Homebrew/test/pathname_test.rb
<del>require "testing_env"
<del>require "tmpdir"
<del>require "extend/pathname"
<del>require "install_renamed"
<del>
<del>module PathnameTestExtension
<del> include FileUtils
<del>
<del> def setup
<del> super
<del> @src = Pathname.new(mktmpdir)
<del> @dst = Pathname.new(mktmpdir)
<del> @file = @src/"foo"
<del> @dir = @src/"bar"
<del> end
<del>end
<del>
<del>class PathnameTests < Homebrew::TestCase
<del> include PathnameTestExtension
<del>
<del> def test_disk_usage_extension
<del> mkdir_p @dir/"a-directory"
<del> touch @dir/".DS_Store"
<del> touch @dir/"a-file"
<del> File.truncate(@dir/"a-file", 1_048_576)
<del> ln_s @dir/"a-file", @dir/"a-symlink"
<del> ln @dir/"a-file", @dir/"a-hardlink"
<del> assert_equal 3, @dir.file_count
<del> assert_equal "3 files, 1M", @dir.abv
<del> assert_equal "1M", (@dir/"a-file").abv
<del> end
<del>
<del> def test_rmdir_if_possible
<del> mkdir_p @dir
<del> touch @dir/"foo"
<del>
<del> assert [email protected]_if_possible
<del> assert_predicate @dir, :directory?
<del>
<del> rm_f @dir/"foo"
<del> assert @dir.rmdir_if_possible
<del> refute_predicate @dir, :exist?
<del> end
<del>
<del> def test_rmdir_if_possible_ignore_ds_store
<del> mkdir_p @dir
<del> touch @dir/".DS_Store"
<del> assert @dir.rmdir_if_possible
<del> refute_predicate @dir, :exist?
<del> end
<del>
<del> def test_write
<del> @file.write("CONTENT")
<del> assert_equal "CONTENT", File.read(@file)
<del> end
<del>
<del> def test_write_does_not_overwrite
<del> touch @file
<del> assert_raises(RuntimeError) { @file.write("CONTENT") }
<del> end
<del>
<del> def test_append_lines
<del> touch @file
<del> @file.append_lines("CONTENT")
<del> assert_equal "CONTENT\n", File.read(@file)
<del> @file.append_lines("CONTENTS")
<del> assert_equal "CONTENT\nCONTENTS\n", File.read(@file)
<del> end
<del>
<del> def test_append_lines_does_not_create
<del> assert_raises(RuntimeError) { @file.append_lines("CONTENT") }
<del> end
<del>
<del> def test_atomic_write
<del> touch @file
<del> @file.atomic_write("CONTENT")
<del> assert_equal "CONTENT", File.read(@file)
<del> end
<del>
<del> def test_atomic_write_preserves_permissions
<del> File.open(@file, "w", 0100777) {}
<del> @file.atomic_write("CONTENT")
<del> assert_equal 0100777 & ~File.umask, @file.stat.mode
<del> end
<del>
<del> def test_atomic_write_preserves_default_permissions
<del> @file.atomic_write("CONTENT")
<del> sentinel = @file.parent.join("sentinel")
<del> touch sentinel
<del> assert_equal sentinel.stat.mode, @file.stat.mode
<del> end
<del>
<del> def test_ensure_writable
<del> touch @file
<del> chmod 0555, @file
<del> @file.ensure_writable { assert_predicate @file, :writable? }
<del> refute_predicate @file, :writable?
<del> end
<del>
<del> def test_extname
<del> assert_equal ".tar.gz", Pathname("foo-0.1.tar.gz").extname
<del> assert_equal ".cpio.gz", Pathname("foo-0.1.cpio.gz").extname
<del> end
<del>
<del> def test_stem
<del> assert_equal "foo-0.1", Pathname("foo-0.1.tar.gz").stem
<del> assert_equal "foo-0.1", Pathname("foo-0.1.cpio.gz").stem
<del> end
<del>
<del> def test_install_missing_file
<del> assert_raises(Errno::ENOENT) { @dst.install "non_existent_file" }
<del> end
<del>
<del> def test_install_removes_original
<del> touch @file
<del> @dst.install(@file)
<del>
<del> assert_predicate @dst/@file.basename, :exist?
<del> refute_predicate @file, :exist?
<del> end
<del>
<del> def test_install_creates_intermediate_directories
<del> touch @file
<del> refute_predicate @dir, :directory?
<del> @dir.install(@file)
<del> assert_predicate @dir, :directory?
<del> end
<del>
<del> def test_install_renamed
<del> @dst.extend(InstallRenamed)
<del>
<del> @file.write "a"
<del> @dst.install @file
<del> @file.write "b"
<del> @dst.install @file
<del>
<del> assert_equal "a", File.read(@dst/@file.basename)
<del> assert_equal "b", File.read(@dst/"#{@file.basename}.default")
<del> end
<del>
<del> def test_install_renamed_directory
<del> @dst.extend(InstallRenamed)
<del> @file.write "a"
<del> @dst.install @src
<del> assert_equal "a", File.read(@dst/@src.basename/@file.basename)
<del> end
<del>
<del> def test_install_renamed_directory_recursive
<del> @dst.extend(InstallRenamed)
<del> (@dst/@dir.basename).mkpath
<del> (@dst/@dir.basename/"another_file").write "a"
<del> @dir.mkpath
<del> (@dir/"another_file").write "b"
<del> @dst.install @dir
<del> assert_equal "b", File.read(@dst/@dir.basename/"another_file.default")
<del> end
<del>
<del> def test_cp_path_sub_file
<del> @file.write "a"
<del> @file.cp_path_sub @src, @dst
<del> assert_equal "a", File.read(@dst/"foo")
<del> end
<del>
<del> def test_cp_path_sub_directory
<del> @dir.mkpath
<del> @dir.cp_path_sub @src, @dst
<del> assert_predicate @dst/@dir.basename, :directory?
<del> end
<del>end
<del>
<del>class PathnameInstallTests < Homebrew::TestCase
<del> include PathnameTestExtension
<del>
<del> def setup
<del> super
<del> (@src/"a.txt").write "This is sample file a."
<del> (@src/"b.txt").write "This is sample file b."
<del> end
<del>
<del> def test_install
<del> @dst.install @src/"a.txt"
<del>
<del> assert_predicate @dst/"a.txt", :exist?, "a.txt was not installed"
<del> refute_predicate @dst/"b.txt", :exist?, "b.txt was installed."
<del> end
<del>
<del> def test_install_list
<del> @dst.install [@src/"a.txt", @src/"b.txt"]
<del>
<del> assert_predicate @dst/"a.txt", :exist?, "a.txt was not installed"
<del> assert_predicate @dst/"b.txt", :exist?, "b.txt was not installed"
<del> end
<del>
<del> def test_install_glob
<del> @dst.install Dir[@src/"*.txt"]
<del>
<del> assert_predicate @dst/"a.txt", :exist?, "a.txt was not installed"
<del> assert_predicate @dst/"b.txt", :exist?, "b.txt was not installed"
<del> end
<del>
<del> def test_install_directory
<del> bin = @src/"bin"
<del> bin.mkpath
<del> mv Dir[@src/"*.txt"], bin
<del> @dst.install bin
<del>
<del> assert_predicate @dst/"bin/a.txt", :exist?, "a.txt was not installed"
<del> assert_predicate @dst/"bin/b.txt", :exist?, "b.txt was not installed"
<del> end
<del>
<del> def test_install_rename
<del> @dst.install @src/"a.txt" => "c.txt"
<del>
<del> assert_predicate @dst/"c.txt", :exist?, "c.txt was not installed"
<del> refute_predicate @dst/"a.txt", :exist?, "a.txt was installed but not renamed"
<del> refute_predicate @dst/"b.txt", :exist?, "b.txt was installed"
<del> end
<del>
<del> def test_install_rename_more
<del> @dst.install(@src/"a.txt" => "c.txt", @src/"b.txt" => "d.txt")
<del>
<del> assert_predicate @dst/"c.txt", :exist?, "c.txt was not installed"
<del> assert_predicate @dst/"d.txt", :exist?, "d.txt was not installed"
<del> refute_predicate @dst/"a.txt", :exist?, "a.txt was installed but not renamed"
<del> refute_predicate @dst/"b.txt", :exist?, "b.txt was installed but not renamed"
<del> end
<del>
<del> def test_install_rename_directory
<del> bin = @src/"bin"
<del> bin.mkpath
<del> mv Dir[@src/"*.txt"], bin
<del> @dst.install bin => "libexec"
<del>
<del> refute_predicate @dst/"bin", :exist?, "bin was installed but not renamed"
<del> assert_predicate @dst/"libexec/a.txt", :exist?, "a.txt was not installed"
<del> assert_predicate @dst/"libexec/b.txt", :exist?, "b.txt was not installed"
<del> end
<del>
<del> def test_install_symlink
<del> bin = @src/"bin"
<del> bin.mkpath
<del> mv Dir[@src/"*.txt"], bin
<del> @dst.install_symlink bin
<del>
<del> assert_predicate @dst/"bin", :symlink?
<del> assert_predicate @dst/"bin", :directory?
<del> assert_predicate @dst/"bin/a.txt", :exist?
<del> assert_predicate @dst/"bin/b.txt", :exist?
<del> assert_predicate((@dst/"bin").readlink, :relative?)
<del> end
<del>
<del> def test_install_relative_symlink
<del> @dst.install_symlink "foo" => "bar"
<del> assert_equal Pathname.new("foo"), (@dst/"bar").readlink
<del> end
<del>
<del> def test_mkdir_creates_intermediate_directories
<del> mkdir @dst/"foo/bar/baz" do
<del> assert_predicate @dst/"foo/bar/baz", :exist?, "foo/bar/baz was not created"
<del> assert_predicate @dst/"foo/bar/baz", :directory?, "foo/bar/baz was not a directory structure"
<del> end
<del> end
<del>end | 2 |
Python | Python | fix config to match best model | 01b21983b65d310a401729b258e16f5175a03460 | <ide><path>official/vision/beta/projects/vit/configs/image_classification.py
<ide> def image_classification_imagenet_deit_pretrain() -> cfg.ExperimentConfig:
<ide> input_path=os.path.join(IMAGENET_INPUT_PATH_BASE, 'train*'),
<ide> is_training=True,
<ide> global_batch_size=train_batch_size,
<del> color_jitter=0.4,
<del> random_erasing=common.RandomErasing(),
<ide> aug_type=common.Augmentation(
<ide> type='randaug', randaug=common.RandAugment(
<ide> magnitude=9, exclude_ops=['Cutout'])), | 1 |
Text | Text | add usmart securities to the inthewild.md | 5fc06a6ef9c136a4861bc2426aea768e9a18dcbb | <ide><path>INTHEWILD.md
<ide> Currently, **officially** using Airflow:
<ide> 1. [imgix](https://www.imgix.com/) [[@dclubb](https://github.com/dclubb)]
<ide> 1. [liligo](http://liligo.com/) [[@tromika](https://github.com/tromika)]
<ide> 1. [proton.ai](https://proton.ai/) [[@prmsolutions](https://github.com/prmsolutions)]
<add>1. [uSmart Securities](https://www.usmartsecurities.com/hk/en/) [[@yangrong688](https://github.com/yangrong688)] | 1 |
Javascript | Javascript | remove unused local variable | 047b869f46ab17b2184c550e3b262e019a3da749 | <ide><path>packages/ember-metal/lib/map.js
<ide> Map.prototype = {
<ide> // to use in browsers that are not ES6 friendly;
<ide> var keys = this.keys,
<ide> values = this.values,
<del> guid = guidFor(key),
<del> value;
<add> guid = guidFor(key);
<ide>
<ide> if (values.hasOwnProperty(guid)) {
<ide> keys.remove(key);
<del> value = values[guid];
<ide> delete values[guid];
<ide> return true;
<ide> } else { | 1 |
Javascript | Javascript | fix regression in buffer(buf) constructor | bc28acdd029687d24004f69f98617c7e171ca173 | <ide><path>lib/buffer.js
<ide> function Buffer(subject, encoding) {
<ide> this.length = this.write(subject, 0, encoding);
<ide> } else {
<ide> if (util.isBuffer(subject))
<del> this.copy(subject, 0, 0, this.length);
<add> subject.copy(this, 0, 0, this.length);
<ide> else if (util.isNumber(subject.length) || util.isArray(subject))
<ide> for (var i = 0; i < this.length; i++)
<ide> this[i] = subject[i];
<ide><path>test/simple/test-buffer.js
<ide> assert.throws(function() {
<ide> Buffer('', 'buffer');
<ide> }, TypeError);
<ide>
<add>// Regression test for #6111. Constructing a buffer from another buffer
<add>// should a) work, and b) not corrupt the source buffer.
<add>(function() {
<add> var a = [0];
<add> for (var i = 0; i < 7; ++i) a = a.concat(a);
<add> a = a.map(function(_, i) { return i });
<add> var b = Buffer(a);
<add> var c = Buffer(b);
<add> assert.equal(b.length, a.length);
<add> assert.equal(c.length, a.length);
<add> for (var i = 0, k = a.length; i < k; ++i) {
<add> assert.equal(a[i], i);
<add> assert.equal(b[i], i);
<add> assert.equal(c[i], i);
<add> }
<add>})(); | 2 |
Ruby | Ruby | remove all code | a28b57d3fb84a618d07cb636c387423d1ebbb850 | <ide><path>Library/Homebrew/formula.rb
<ide> def etc; (HOMEBREW_PREFIX+'etc').extend(InstallRenamed) end
<ide> # generally we don't want var stuff inside the keg
<ide> def var; HOMEBREW_PREFIX+'var' end
<ide>
<del> def bash_completion
<del> etc = ENV['HOMEBREW_GIT_ETC'] ? self.etc : prefix+'etc'
<del> etc+'bash_completion.d'
<del> end
<add> def bash_completion; prefix+'etc/bash_completion.d' end
<ide> def zsh_completion; share+'zsh/site-functions' end
<ide>
<ide> # for storing etc, var files for later copying from bottles
<ide><path>Library/Homebrew/formula_installer.rb
<ide> def check_install_sanity
<ide> raise
<ide> end
<ide>
<del> def git_etc_preinstall
<del> return unless quiet_system 'git', '--version'
<del>
<del> etc = HOMEBREW_PREFIX+'etc'
<del> etc.cd do
<del> quiet_system 'git', 'init' unless (etc+'.git').directory?
<del> quiet_system 'git', 'checkout', '-B', "#{f.name}-preinstall"
<del> unless quiet_system 'git', 'diff', '--exit-code', 'HEAD'
<del> system 'git', 'add', '--all', '.'
<del> system 'git', 'commit', '-m', "#{f.name}-#{f.version}: preinstall"
<del> end
<del>
<del> unless quiet_system 'git', 'rev-parse', 'master'
<del> quiet_system 'git', 'branch', 'master'
<del> end
<del> end
<del> end
<del>
<del> def git_etc_postinstall
<del> return unless quiet_system 'git', '--version'
<del>
<del> preinstall_branch = "#{f.name}-preinstall"
<del> default_branch = "#{f.name}-default"
<del> merged = false
<del> f.etc.mkpath
<del> f.etc.cd do
<del> if quiet_system 'git', 'diff', '--exit-code', preinstall_branch
<del> quiet_system 'git', 'branch', default_branch
<del> quiet_system 'git', 'branch', '-D', preinstall_branch
<del> elsif not quiet_system 'git', 'rev-parse', default_branch
<del> quiet_system 'git', 'checkout', '-B', default_branch
<del> quiet_system 'git', 'add', '--all', '.'
<del> system 'git', 'commit', '-m', "#{f.name}-#{f.version}: default"
<del> quiet_system 'git', 'branch', '-D', preinstall_branch
<del> else
<del> previous_default_branch = `git rev-parse #{default_branch}`.strip
<del> quiet_system 'git', 'checkout', '-B', default_branch
<del> quiet_system 'git', 'add', '--all', '.'
<del> system 'git', 'commit', '-m', "#{f.name}-#{f.version}: default"
<del>
<del> default_unchanged = quiet_system('git', 'diff', '--exit-code', \
<del> previous_default_branch)
<del>
<del> if default_unchanged
<del> system 'git', 'reset', '--hard', previous_default_branch
<del> end
<del>
<del> quiet_system 'git', 'checkout', 'master'
<del> quiet_system 'git', 'reset', '--hard', preinstall_branch
<del>
<del> unless default_unchanged
<del> merge_ff = quiet_system 'git', 'merge', '--ff-only', '--no-edit',
<del> '-X', 'ours', default_branch
<del> unless merge_ff
<del> merged = true
<del> system 'git', 'merge', '--no-ff', '--no-edit',
<del> '-X', 'ours', default_branch
<del> end
<del> end
<del> end
<del>
<del> if merged
<del> ohai "Configuration Files"
<del> puts "Your configuration files for #{f.name} in etc were merged:"
<del> puts "To reverse this merge: git reset --hard #{preinstall_branch}"
<del> puts "To restore defaults: git reset --hard #{default_branch}"
<del> end
<del> end
<del> end
<del>
<ide> def build_bottle_preinstall
<ide> @etc_var_glob ||= "#{HOMEBREW_PREFIX}/{etc,var}/**/*"
<ide> @etc_var_preinstall = Dir[@etc_var_glob]
<ide> def install
<ide>
<ide> @@attempted << f
<ide>
<del> git_etc_preinstall if ENV['HOMEBREW_GIT_ETC']
<del>
<ide> @poured_bottle = false
<ide>
<ide> begin
<ide> def install
<ide> opoo "#{f.name} post_install failed. Rerun with `brew postinstall #{f.name}`."
<ide> end
<ide>
<del> git_etc_postinstall if ENV['HOMEBREW_GIT_ETC']
<del>
<ide> opoo "Nothing was installed to #{f.prefix}" unless f.installed?
<ide> end
<ide>
<ide><path>Library/Homebrew/install_renamed.rb
<ide> def cp_path_sub pattern, replacement
<ide> private
<ide>
<ide> def append_default_if_different src, dst
<del> if File.file? dst and !FileUtils.identical?(src, dst) and !ENV['HOMEBREW_GIT_ETC']
<add> if File.file? dst and !FileUtils.identical?(src, dst)
<ide> dst += ".default"
<ide> end
<ide> dst | 3 |
Text | Text | remove extra white-spaces [ci skip] | af981764686c28db40305adf9cfc308f2e20ab50 | <ide><path>guides/source/getting_started.md
<ide> article. Try it! You should get an error that looks like this:
<ide>
<ide> Rails has several security features that help you write secure applications,
<ide> and you're running into one of them now. This one is called
<del>`[strong_parameters](http://guides.rubyonrails.org/action_controller_overview.html#strong-parameters)`,
<add>`[strong_parameters](http://guides.rubyonrails.org/action_controller_overview.html#strong-parameters)`,
<ide> which requires us to tell Rails exactly which parameters are allowed into
<ide> our controller actions.
<ide>
<ide> Why do you have to bother? The ability to grab and automatically assign
<del>all controller parameters to your model in one shot makes the programmer's
<del>job easier, but this convenience also allows malicious use. What if a
<del>request to the server was crafted to look like a new article form submit
<del>but also included extra fields with values that violated your applications
<del>integrity? They would be 'mass assigned' into your model and then into the
<add>all controller parameters to your model in one shot makes the programmer's
<add>job easier, but this convenience also allows malicious use. What if a
<add>request to the server was crafted to look like a new article form submit
<add>but also included extra fields with values that violated your applications
<add>integrity? They would be 'mass assigned' into your model and then into the
<ide> database along with the good stuff - potentially breaking your application
<ide> or worse.
<ide>
<del>We have to whitelist our controller parameters to prevent wrongful
<del>mass assignment. In this case, we want to both allow and require the
<del>`title` and `text` parameters for valid use of `create`. The syntax for
<add>We have to whitelist our controller parameters to prevent wrongful
<add>mass assignment. In this case, we want to both allow and require the
<add>`title` and `text` parameters for valid use of `create`. The syntax for
<ide> this introduces `require` and `permit`. The change will involve one line:
<ide>
<ide> ```ruby
<ide> @article = Article.new(params.require(:article).permit(:title, :text))
<ide> ```
<ide>
<del>This is often factored out into its own method so it can be reused by
<add>This is often factored out into its own method so it can be reused by
<ide> multiple actions in the same controller, for example `create` and `update`.
<del>Above and beyond mass assignment issues, the method is often made
<del>`private` to make sure it can't be called outside its intended context.
<add>Above and beyond mass assignment issues, the method is often made
<add>`private` to make sure it can't be called outside its intended context.
<ide> Here is the result:
<ide>
<ide> ```ruby
<ide> private
<ide> end
<ide> ```
<ide>
<del>TIP: For more information, refer to the reference above and
<add>TIP: For more information, refer to the reference above and
<ide> [this blog article about Strong Parameters](http://weblog.rubyonrails.org/2012/3/21/strong-parameters/).
<ide>
<ide> ### Showing Articles | 1 |
Javascript | Javascript | add detectstrictmode method for backward-compat | 284e97fd81d30221e5af35c4b0dcfbddf644852b | <ide><path>lib/Parser.js
<ide> class Parser extends Tapable {
<ide>
<ide> this.scope = oldScope;
<ide> }
<add>
<add> // TODO webpack 5: remove this methods
<add> // only for backward-compat
<add> detectStrictMode(statements) {
<add> this.detectMode(statements);
<add> }
<ide>
<ide> detectMode(statements) {
<ide> const isLiteral = | 1 |
Javascript | Javascript | add transition tracing transitions stack | e0160d50c5a492a925db6ab3f8478e118336c722 | <ide><path>packages/react-reconciler/src/ReactFiberBeginWork.new.js
<ide> function updateOffscreenComponent(
<ide> // push the cache pool even though we're going to bail out
<ide> // because otherwise there'd be a context mismatch
<ide> if (current !== null) {
<del> pushTransition(workInProgress, null);
<add> pushTransition(workInProgress, null, null);
<ide> }
<ide> }
<ide> pushRenderLanes(workInProgress, renderLanes);
<ide> function updateOffscreenComponent(
<ide> // push the cache pool even though we're going to bail out
<ide> // because otherwise there'd be a context mismatch
<ide> if (current !== null) {
<del> pushTransition(workInProgress, null);
<add> pushTransition(workInProgress, null, null);
<ide> }
<ide> }
<ide>
<ide> function updateOffscreenComponent(
<ide> // using the same cache. Unless the parent changed, since that means
<ide> // there was a refresh.
<ide> const prevCachePool = prevState !== null ? prevState.cachePool : null;
<del> pushTransition(workInProgress, prevCachePool);
<add> // TODO: Consider if and how Offscreen pre-rendering should
<add> // be attributed to the transition that spawned it
<add> pushTransition(workInProgress, prevCachePool, null);
<ide> }
<ide>
<ide> pushRenderLanes(workInProgress, subtreeRenderLanes);
<ide> function updateOffscreenComponent(
<ide> // using the same cache. Unless the parent changed, since that means
<ide> // there was a refresh.
<ide> const prevCachePool = prevState.cachePool;
<del> pushTransition(workInProgress, prevCachePool);
<add> pushTransition(workInProgress, prevCachePool, null);
<ide> }
<ide>
<ide> // Since we're not hidden anymore, reset the state
<ide> function updateOffscreenComponent(
<ide> // using the same cache. Unless the parent changed, since that means
<ide> // there was a refresh.
<ide> if (current !== null) {
<del> pushTransition(workInProgress, null);
<add> pushTransition(workInProgress, null, null);
<ide> }
<ide> }
<ide> }
<ide> function updateHostRoot(current, workInProgress, renderLanes) {
<ide>
<ide> const nextState: RootState = workInProgress.memoizedState;
<ide> const root: FiberRoot = workInProgress.stateNode;
<add> pushRootTransition(workInProgress, root, renderLanes);
<ide>
<ide> if (enableCache) {
<ide> const nextCache: Cache = nextState.cache;
<del> pushRootTransition(root);
<ide> pushCacheProvider(workInProgress, nextCache);
<ide> if (nextCache !== prevState.cache) {
<ide> // The root cache refreshed.
<ide> function attemptEarlyBailoutIfNoScheduledUpdate(
<ide> case HostRoot:
<ide> pushHostRootContext(workInProgress);
<ide> const root: FiberRoot = workInProgress.stateNode;
<add> pushRootTransition(workInProgress, root, renderLanes);
<add>
<ide> if (enableCache) {
<ide> const cache: Cache = current.memoizedState.cache;
<ide> pushCacheProvider(workInProgress, cache);
<del> pushRootTransition(root);
<ide> }
<ide> if (enableTransitionTracing) {
<ide> workInProgress.memoizedState.transitions = getWorkInProgressTransitions();
<ide><path>packages/react-reconciler/src/ReactFiberBeginWork.old.js
<ide> function updateOffscreenComponent(
<ide> // push the cache pool even though we're going to bail out
<ide> // because otherwise there'd be a context mismatch
<ide> if (current !== null) {
<del> pushTransition(workInProgress, null);
<add> pushTransition(workInProgress, null, null);
<ide> }
<ide> }
<ide> pushRenderLanes(workInProgress, renderLanes);
<ide> function updateOffscreenComponent(
<ide> // push the cache pool even though we're going to bail out
<ide> // because otherwise there'd be a context mismatch
<ide> if (current !== null) {
<del> pushTransition(workInProgress, null);
<add> pushTransition(workInProgress, null, null);
<ide> }
<ide> }
<ide>
<ide> function updateOffscreenComponent(
<ide> // using the same cache. Unless the parent changed, since that means
<ide> // there was a refresh.
<ide> const prevCachePool = prevState !== null ? prevState.cachePool : null;
<del> pushTransition(workInProgress, prevCachePool);
<add> // TODO: Consider if and how Offscreen pre-rendering should
<add> // be attributed to the transition that spawned it
<add> pushTransition(workInProgress, prevCachePool, null);
<ide> }
<ide>
<ide> pushRenderLanes(workInProgress, subtreeRenderLanes);
<ide> function updateOffscreenComponent(
<ide> // using the same cache. Unless the parent changed, since that means
<ide> // there was a refresh.
<ide> const prevCachePool = prevState.cachePool;
<del> pushTransition(workInProgress, prevCachePool);
<add> pushTransition(workInProgress, prevCachePool, null);
<ide> }
<ide>
<ide> // Since we're not hidden anymore, reset the state
<ide> function updateOffscreenComponent(
<ide> // using the same cache. Unless the parent changed, since that means
<ide> // there was a refresh.
<ide> if (current !== null) {
<del> pushTransition(workInProgress, null);
<add> pushTransition(workInProgress, null, null);
<ide> }
<ide> }
<ide> }
<ide> function updateHostRoot(current, workInProgress, renderLanes) {
<ide>
<ide> const nextState: RootState = workInProgress.memoizedState;
<ide> const root: FiberRoot = workInProgress.stateNode;
<add> pushRootTransition(workInProgress, root, renderLanes);
<ide>
<ide> if (enableCache) {
<ide> const nextCache: Cache = nextState.cache;
<del> pushRootTransition(root);
<ide> pushCacheProvider(workInProgress, nextCache);
<ide> if (nextCache !== prevState.cache) {
<ide> // The root cache refreshed.
<ide> function attemptEarlyBailoutIfNoScheduledUpdate(
<ide> case HostRoot:
<ide> pushHostRootContext(workInProgress);
<ide> const root: FiberRoot = workInProgress.stateNode;
<add> pushRootTransition(workInProgress, root, renderLanes);
<add>
<ide> if (enableCache) {
<ide> const cache: Cache = current.memoizedState.cache;
<ide> pushCacheProvider(workInProgress, cache);
<del> pushRootTransition(root);
<ide> }
<ide> if (enableTransitionTracing) {
<ide> workInProgress.memoizedState.transitions = getWorkInProgressTransitions();
<ide><path>packages/react-reconciler/src/ReactFiberCompleteWork.new.js
<ide> function completeWork(
<ide> }
<ide>
<ide> if (enableCache) {
<del> popRootTransition(fiberRoot, renderLanes);
<del>
<ide> let previousCache: Cache | null = null;
<ide> if (current !== null) {
<ide> previousCache = current.memoizedState.cache;
<ide> function completeWork(
<ide> }
<ide> popCacheProvider(workInProgress, cache);
<ide> }
<add> popRootTransition(workInProgress, fiberRoot, renderLanes);
<ide> popHostContainer(workInProgress);
<ide> popTopLevelLegacyContextObject(workInProgress);
<ide> resetMutableSourceWorkInProgressVersions();
<ide> function completeWork(
<ide> // Run passive effects to retain/release the cache.
<ide> workInProgress.flags |= Passive;
<ide> }
<del> if (current !== null) {
<del> popTransition(workInProgress);
<del> }
<ide> }
<ide>
<add> popTransition(workInProgress, current);
<add>
<ide> return null;
<ide> }
<ide> case CacheComponent: {
<ide><path>packages/react-reconciler/src/ReactFiberCompleteWork.old.js
<ide> function completeWork(
<ide> }
<ide>
<ide> if (enableCache) {
<del> popRootTransition(fiberRoot, renderLanes);
<del>
<ide> let previousCache: Cache | null = null;
<ide> if (current !== null) {
<ide> previousCache = current.memoizedState.cache;
<ide> function completeWork(
<ide> }
<ide> popCacheProvider(workInProgress, cache);
<ide> }
<add> popRootTransition(workInProgress, fiberRoot, renderLanes);
<ide> popHostContainer(workInProgress);
<ide> popTopLevelLegacyContextObject(workInProgress);
<ide> resetMutableSourceWorkInProgressVersions();
<ide> function completeWork(
<ide> // Run passive effects to retain/release the cache.
<ide> workInProgress.flags |= Passive;
<ide> }
<del> if (current !== null) {
<del> popTransition(workInProgress);
<del> }
<ide> }
<ide>
<add> popTransition(workInProgress, current);
<add>
<ide> return null;
<ide> }
<ide> case CacheComponent: {
<ide><path>packages/react-reconciler/src/ReactFiberTransition.new.js
<ide> import type {FiberRoot} from './ReactInternalTypes';
<ide> import type {Lanes} from './ReactFiberLane.new';
<ide> import type {StackCursor} from './ReactFiberStack.new';
<ide> import type {Cache, SpawnedCachePool} from './ReactFiberCacheComponent.new';
<add>import type {Transition} from './ReactFiberTracingMarkerComponent.new';
<ide>
<del>import {enableCache} from 'shared/ReactFeatureFlags';
<add>import {enableCache, enableTransitionTracing} from 'shared/ReactFeatureFlags';
<ide> import {isPrimaryRenderer} from './ReactFiberHostConfig';
<ide> import {createCursor, push, pop} from './ReactFiberStack.new';
<del>import {getWorkInProgressRoot} from './ReactFiberWorkLoop.new';
<add>import {
<add> getWorkInProgressRoot,
<add> getWorkInProgressTransitions,
<add>} from './ReactFiberWorkLoop.new';
<ide> import {
<ide> createCache,
<ide> retainCache,
<ide> import {
<ide> // used during the previous render by placing it here, on the stack.
<ide> const resumedCache: StackCursor<Cache | null> = createCursor(null);
<ide>
<add>// During the render/synchronous commit phase, we don't actually process the
<add>// transitions. Therefore, we want to lazily combine transitions. Instead of
<add>// comparing the arrays of transitions when we combine them and storing them
<add>// and filtering out the duplicates, we will instead store the unprocessed transitions
<add>// in an array and actually filter them in the passive phase.
<add>const transitionStack: StackCursor<Array<Transition> | null> = createCursor(
<add> null,
<add>);
<add>
<ide> function peekCacheFromPool(): Cache | null {
<ide> if (!enableCache) {
<ide> return (null: any);
<ide> export function requestCacheFromPool(renderLanes: Lanes): Cache {
<ide> return freshCache;
<ide> }
<ide>
<del>export function pushRootTransition(root: FiberRoot) {
<del> if (enableCache) {
<del> return;
<add>export function pushRootTransition(
<add> workInProgress: Fiber,
<add> root: FiberRoot,
<add> renderLanes: Lanes,
<add>) {
<add> if (enableTransitionTracing) {
<add> const rootTransitions = getWorkInProgressTransitions();
<add> push(transitionStack, rootTransitions, workInProgress);
<ide> }
<del> // Note: This function currently does nothing but I'll leave it here for
<del> // code organization purposes in case that changes.
<ide> }
<ide>
<del>export function popRootTransition(root: FiberRoot, renderLanes: Lanes) {
<del> if (enableCache) {
<del> return;
<add>export function popRootTransition(
<add> workInProgress: Fiber,
<add> root: FiberRoot,
<add> renderLanes: Lanes,
<add>) {
<add> if (enableTransitionTracing) {
<add> pop(transitionStack, workInProgress);
<ide> }
<del> // Note: This function currently does nothing but I'll leave it here for
<del> // code organization purposes in case that changes.
<ide> }
<ide>
<ide> export function pushTransition(
<ide> offscreenWorkInProgress: Fiber,
<ide> prevCachePool: SpawnedCachePool | null,
<add> newTransitions: Array<Transition> | null,
<ide> ): void {
<ide> if (enableCache) {
<ide> if (prevCachePool === null) {
<ide> export function pushTransition(
<ide> push(resumedCache, prevCachePool.pool, offscreenWorkInProgress);
<ide> }
<ide> }
<add>
<add> if (enableTransitionTracing) {
<add> if (transitionStack.current === null) {
<add> push(transitionStack, newTransitions, offscreenWorkInProgress);
<add> } else if (newTransitions === null) {
<add> push(transitionStack, transitionStack.current, offscreenWorkInProgress);
<add> } else {
<add> push(
<add> transitionStack,
<add> transitionStack.current.concat(newTransitions),
<add> offscreenWorkInProgress,
<add> );
<add> }
<add> }
<ide> }
<ide>
<del>export function popTransition(workInProgress: Fiber) {
<del> if (enableCache) {
<del> pop(resumedCache, workInProgress);
<add>export function popTransition(workInProgress: Fiber, current: Fiber | null) {
<add> if (current !== null) {
<add> if (enableCache) {
<add> pop(resumedCache, workInProgress);
<add> }
<add>
<add> if (enableTransitionTracing) {
<add> pop(transitionStack, workInProgress);
<add> }
<add> }
<add>}
<add>
<add>export function getSuspendedTransitions(): Array<Transition> | null {
<add> if (!enableTransitionTracing) {
<add> return null;
<ide> }
<add>
<add> return transitionStack.current;
<ide> }
<ide>
<ide> export function getSuspendedCache(): SpawnedCachePool | null {
<ide><path>packages/react-reconciler/src/ReactFiberTransition.old.js
<ide> import type {FiberRoot} from './ReactInternalTypes';
<ide> import type {Lanes} from './ReactFiberLane.old';
<ide> import type {StackCursor} from './ReactFiberStack.old';
<ide> import type {Cache, SpawnedCachePool} from './ReactFiberCacheComponent.old';
<add>import type {Transition} from './ReactFiberTracingMarkerComponent.old';
<ide>
<del>import {enableCache} from 'shared/ReactFeatureFlags';
<add>import {enableCache, enableTransitionTracing} from 'shared/ReactFeatureFlags';
<ide> import {isPrimaryRenderer} from './ReactFiberHostConfig';
<ide> import {createCursor, push, pop} from './ReactFiberStack.old';
<del>import {getWorkInProgressRoot} from './ReactFiberWorkLoop.old';
<add>import {
<add> getWorkInProgressRoot,
<add> getWorkInProgressTransitions,
<add>} from './ReactFiberWorkLoop.old';
<ide> import {
<ide> createCache,
<ide> retainCache,
<ide> import {
<ide> // used during the previous render by placing it here, on the stack.
<ide> const resumedCache: StackCursor<Cache | null> = createCursor(null);
<ide>
<add>// During the render/synchronous commit phase, we don't actually process the
<add>// transitions. Therefore, we want to lazily combine transitions. Instead of
<add>// comparing the arrays of transitions when we combine them and storing them
<add>// and filtering out the duplicates, we will instead store the unprocessed transitions
<add>// in an array and actually filter them in the passive phase.
<add>const transitionStack: StackCursor<Array<Transition> | null> = createCursor(
<add> null,
<add>);
<add>
<ide> function peekCacheFromPool(): Cache | null {
<ide> if (!enableCache) {
<ide> return (null: any);
<ide> export function requestCacheFromPool(renderLanes: Lanes): Cache {
<ide> return freshCache;
<ide> }
<ide>
<del>export function pushRootTransition(root: FiberRoot) {
<del> if (enableCache) {
<del> return;
<add>export function pushRootTransition(
<add> workInProgress: Fiber,
<add> root: FiberRoot,
<add> renderLanes: Lanes,
<add>) {
<add> if (enableTransitionTracing) {
<add> const rootTransitions = getWorkInProgressTransitions();
<add> push(transitionStack, rootTransitions, workInProgress);
<ide> }
<del> // Note: This function currently does nothing but I'll leave it here for
<del> // code organization purposes in case that changes.
<ide> }
<ide>
<del>export function popRootTransition(root: FiberRoot, renderLanes: Lanes) {
<del> if (enableCache) {
<del> return;
<add>export function popRootTransition(
<add> workInProgress: Fiber,
<add> root: FiberRoot,
<add> renderLanes: Lanes,
<add>) {
<add> if (enableTransitionTracing) {
<add> pop(transitionStack, workInProgress);
<ide> }
<del> // Note: This function currently does nothing but I'll leave it here for
<del> // code organization purposes in case that changes.
<ide> }
<ide>
<ide> export function pushTransition(
<ide> offscreenWorkInProgress: Fiber,
<ide> prevCachePool: SpawnedCachePool | null,
<add> newTransitions: Array<Transition> | null,
<ide> ): void {
<ide> if (enableCache) {
<ide> if (prevCachePool === null) {
<ide> export function pushTransition(
<ide> push(resumedCache, prevCachePool.pool, offscreenWorkInProgress);
<ide> }
<ide> }
<add>
<add> if (enableTransitionTracing) {
<add> if (transitionStack.current === null) {
<add> push(transitionStack, newTransitions, offscreenWorkInProgress);
<add> } else if (newTransitions === null) {
<add> push(transitionStack, transitionStack.current, offscreenWorkInProgress);
<add> } else {
<add> push(
<add> transitionStack,
<add> transitionStack.current.concat(newTransitions),
<add> offscreenWorkInProgress,
<add> );
<add> }
<add> }
<ide> }
<ide>
<del>export function popTransition(workInProgress: Fiber) {
<del> if (enableCache) {
<del> pop(resumedCache, workInProgress);
<add>export function popTransition(workInProgress: Fiber, current: Fiber | null) {
<add> if (current !== null) {
<add> if (enableCache) {
<add> pop(resumedCache, workInProgress);
<add> }
<add>
<add> if (enableTransitionTracing) {
<add> pop(transitionStack, workInProgress);
<add> }
<add> }
<add>}
<add>
<add>export function getSuspendedTransitions(): Array<Transition> | null {
<add> if (!enableTransitionTracing) {
<add> return null;
<ide> }
<add>
<add> return transitionStack.current;
<ide> }
<ide>
<ide> export function getSuspendedCache(): SpawnedCachePool | null {
<ide><path>packages/react-reconciler/src/ReactFiberUnwindWork.new.js
<ide> function unwindWork(
<ide> return null;
<ide> }
<ide> case HostRoot: {
<add> const root: FiberRoot = workInProgress.stateNode;
<ide> if (enableCache) {
<del> const root: FiberRoot = workInProgress.stateNode;
<del> popRootTransition(root, renderLanes);
<del>
<ide> const cache: Cache = workInProgress.memoizedState.cache;
<ide> popCacheProvider(workInProgress, cache);
<ide> }
<add> popRootTransition(workInProgress, root, renderLanes);
<ide> popHostContainer(workInProgress);
<ide> popTopLevelLegacyContextObject(workInProgress);
<ide> resetMutableSourceWorkInProgressVersions();
<ide> function unwindWork(
<ide> case OffscreenComponent:
<ide> case LegacyHiddenComponent:
<ide> popRenderLanes(workInProgress);
<del> if (enableCache) {
<del> if (current !== null) {
<del> popTransition(workInProgress);
<del> }
<del> }
<add> popTransition(workInProgress, current);
<ide> return null;
<ide> case CacheComponent:
<ide> if (enableCache) {
<ide> function unwindInterruptedWork(
<ide> break;
<ide> }
<ide> case HostRoot: {
<add> const root: FiberRoot = interruptedWork.stateNode;
<ide> if (enableCache) {
<del> const root: FiberRoot = interruptedWork.stateNode;
<del> popRootTransition(root, renderLanes);
<del>
<ide> const cache: Cache = interruptedWork.memoizedState.cache;
<ide> popCacheProvider(interruptedWork, cache);
<ide> }
<add> popRootTransition(interruptedWork, root, renderLanes);
<ide> popHostContainer(interruptedWork);
<ide> popTopLevelLegacyContextObject(interruptedWork);
<ide> resetMutableSourceWorkInProgressVersions();
<ide> function unwindInterruptedWork(
<ide> case OffscreenComponent:
<ide> case LegacyHiddenComponent:
<ide> popRenderLanes(interruptedWork);
<del> if (enableCache) {
<del> if (current !== null) {
<del> popTransition(interruptedWork);
<del> }
<del> }
<del>
<add> popTransition(interruptedWork, current);
<ide> break;
<ide> case CacheComponent:
<ide> if (enableCache) {
<ide><path>packages/react-reconciler/src/ReactFiberUnwindWork.old.js
<ide> function unwindWork(
<ide> return null;
<ide> }
<ide> case HostRoot: {
<add> const root: FiberRoot = workInProgress.stateNode;
<ide> if (enableCache) {
<del> const root: FiberRoot = workInProgress.stateNode;
<del> popRootTransition(root, renderLanes);
<del>
<ide> const cache: Cache = workInProgress.memoizedState.cache;
<ide> popCacheProvider(workInProgress, cache);
<ide> }
<add> popRootTransition(workInProgress, root, renderLanes);
<ide> popHostContainer(workInProgress);
<ide> popTopLevelLegacyContextObject(workInProgress);
<ide> resetMutableSourceWorkInProgressVersions();
<ide> function unwindWork(
<ide> case OffscreenComponent:
<ide> case LegacyHiddenComponent:
<ide> popRenderLanes(workInProgress);
<del> if (enableCache) {
<del> if (current !== null) {
<del> popTransition(workInProgress);
<del> }
<del> }
<add> popTransition(workInProgress, current);
<ide> return null;
<ide> case CacheComponent:
<ide> if (enableCache) {
<ide> function unwindInterruptedWork(
<ide> break;
<ide> }
<ide> case HostRoot: {
<add> const root: FiberRoot = interruptedWork.stateNode;
<ide> if (enableCache) {
<del> const root: FiberRoot = interruptedWork.stateNode;
<del> popRootTransition(root, renderLanes);
<del>
<ide> const cache: Cache = interruptedWork.memoizedState.cache;
<ide> popCacheProvider(interruptedWork, cache);
<ide> }
<add> popRootTransition(interruptedWork, root, renderLanes);
<ide> popHostContainer(interruptedWork);
<ide> popTopLevelLegacyContextObject(interruptedWork);
<ide> resetMutableSourceWorkInProgressVersions();
<ide> function unwindInterruptedWork(
<ide> case OffscreenComponent:
<ide> case LegacyHiddenComponent:
<ide> popRenderLanes(interruptedWork);
<del> if (enableCache) {
<del> if (current !== null) {
<del> popTransition(interruptedWork);
<del> }
<del> }
<del>
<add> popTransition(interruptedWork, current);
<ide> break;
<ide> case CacheComponent:
<ide> if (enableCache) { | 8 |
Text | Text | fix typo in chnagelog.md | da0a47bec3c13bd93793811155de00730d2e27ae | <ide><path>packages/react-devtools/CHANGELOG.md
<ide>
<ide> ## 4.0.4 (August 18, 2019)
<ide> #### Bug fixes
<del>* Bugfox for potential error if a min-duration commit filter is applied after selecting a fiber in the Profiler UI.
<add>* Bugfix for potential error if a min-duration commit filter is applied after selecting a fiber in the Profiler UI.
<ide>
<ide> ## 4.0.3 (August 17, 2019)
<ide> #### Bug fixes | 1 |
Javascript | Javascript | correct few unclosed elements | 4bfb66ce0be46d3a0e9da2f80f3e1d0c2b559828 | <ide><path>src/ng/filter/filter.js
<ide>
<ide> Search: <input ng-model="searchText">
<ide> <table id="searchTextResults">
<del> <tr><th>Name</th><th>Phone</th><tr>
<add> <tr><th>Name</th><th>Phone</th></tr>
<ide> <tr ng-repeat="friend in friends | filter:searchText">
<ide> <td>{{friend.name}}</td>
<ide> <td>{{friend.phone}}</td>
<del> <tr>
<add> </tr>
<ide> </table>
<ide> <hr>
<ide> Any: <input ng-model="search.$"> <br>
<ide> Name only <input ng-model="search.name"><br>
<ide> Phone only <input ng-model="search.phone"å><br>
<ide> Equality <input type="checkbox" ng-model="strict"><br>
<ide> <table id="searchObjResults">
<del> <tr><th>Name</th><th>Phone</th><tr>
<add> <tr><th>Name</th><th>Phone</th></tr>
<ide> <tr ng-repeat="friend in friends | filter:search:strict">
<ide> <td>{{friend.name}}</td>
<ide> <td>{{friend.phone}}</td>
<del> <tr>
<add> </tr>
<ide> </table>
<ide> </doc:source>
<ide> <doc:scenario>
<ide><path>src/ng/filter/orderBy.js
<ide> (<a href ng-click="predicate = '-name'; reverse=false">^</a>)</th>
<ide> <th><a href="" ng-click="predicate = 'phone'; reverse=!reverse">Phone Number</a></th>
<ide> <th><a href="" ng-click="predicate = 'age'; reverse=!reverse">Age</a></th>
<del> <tr>
<add> </tr>
<ide> <tr ng-repeat="friend in friends | orderBy:predicate:reverse">
<ide> <td>{{friend.name}}</td>
<ide> <td>{{friend.phone}}</td>
<ide> <td>{{friend.age}}</td>
<del> <tr>
<add> </tr>
<ide> </table>
<ide> </div>
<ide> </doc:source> | 2 |
Javascript | Javascript | use new testing api | b273c005ce2a6550bc74f7adadc0ee171fc2e4a2 | <ide><path>node-tests/blueprints/acceptance-test-test.js
<ide> 'use strict';
<ide>
<del>var setupTestHooks = require('ember-cli-blueprint-test-helpers/lib/helpers/setup');
<del>var BlueprintHelpers = require('ember-cli-blueprint-test-helpers/lib/helpers/blueprint-helper');
<del>var generateAndDestroy = BlueprintHelpers.generateAndDestroy;
<add>var blueprintHelpers = require('ember-cli-blueprint-test-helpers/helpers');
<add>var setupTestHooks = blueprintHelpers.setupTestHooks;
<add>var emberNew = blueprintHelpers.emberNew;
<add>var emberGenerateDestroy = blueprintHelpers.emberGenerateDestroy;
<add>var modifyPackages = blueprintHelpers.modifyPackages;
<add>
<add>var chai = require('ember-cli-blueprint-test-helpers/chai');
<add>var expect = chai.expect;
<ide>
<ide> describe('Acceptance: ember generate and destroy acceptance-test', function() {
<ide> setupTestHooks(this);
<ide>
<ide> it('acceptance-test foo', function() {
<del> // pass any additional command line options in the arguments array
<del> return generateAndDestroy(['acceptance-test', 'foo'], {
<del> files: [
<del> {
<del> file: 'tests/acceptance/foo-test.js',
<del> contains: [
<del> "import { test } from 'qunit';",
<del> "moduleForAcceptance('Acceptance | foo');",
<del> "test('visiting /foo', function(assert) {",
<del> "visit('/foo');",
<del> "andThen(function() {",
<del> "assert.equal(currentURL(), '/foo');"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['acceptance-test', 'foo'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/acceptance/foo-test.js'))
<add> .to.contain("import { test } from 'qunit';")
<add> .to.contain("moduleForAcceptance('Acceptance | foo');")
<add> .to.contain("test('visiting /foo', function(assert) {")
<add> .to.contain("visit('/foo');")
<add> .to.contain("andThen(function() {")
<add> .to.contain("assert.equal(currentURL(), '/foo');");
<add> }));
<ide> });
<ide>
<ide> it('in-addon acceptance-test foo', function() {
<del> return generateAndDestroy(['acceptance-test', 'foo'], {
<del> target: 'addon',
<del> files: [
<del> {
<del> file: 'tests/acceptance/foo-test.js',
<del> contains: [
<del> "import { test } from 'qunit';",
<del> "moduleForAcceptance('Acceptance | foo');",
<del> "test('visiting /foo', function(assert) {",
<del> "visit('/foo');",
<del> "andThen(function() {",
<del> "assert.equal(currentURL(), '/foo');"
<del> ]
<del> },
<del> {
<del> file: 'app/acceptance-tests/foo.js',
<del> exists: false
<del> }
<del> ]
<del> });
<add> var args = ['acceptance-test', 'foo'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/acceptance/foo-test.js'))
<add> .to.contain("import { test } from 'qunit';")
<add> .to.contain("moduleForAcceptance('Acceptance | foo');")
<add> .to.contain("test('visiting /foo', function(assert) {")
<add> .to.contain("visit('/foo');")
<add> .to.contain("andThen(function() {")
<add> .to.contain("assert.equal(currentURL(), '/foo');");
<add>
<add> expect(_file('app/acceptance-tests/foo.js'))
<add> .to.not.exist;
<add> }));
<ide> });
<ide>
<ide> it('in-addon acceptance-test foo/bar', function() {
<del> return generateAndDestroy(['acceptance-test', 'foo/bar'], {
<del> target: 'addon',
<del> files: [
<del> {
<del> file: 'tests/acceptance/foo/bar-test.js',
<del> contains: [
<del> "import { test } from 'qunit';",
<del> "moduleForAcceptance('Acceptance | foo/bar');",
<del> "test('visiting /foo/bar', function(assert) {",
<del> "visit('/foo/bar');",
<del> "andThen(function() {",
<del> "assert.equal(currentURL(), '/foo/bar');"
<del> ]
<del> },
<del> {
<del> file: 'app/acceptance-tests/foo/bar.js',
<del> exists: false
<del> }
<del> ]
<del> });
<add> var args = ['acceptance-test', 'foo/bar'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/acceptance/foo/bar-test.js'))
<add> .to.contain("import { test } from 'qunit';")
<add> .to.contain("moduleForAcceptance('Acceptance | foo/bar');")
<add> .to.contain("test('visiting /foo/bar', function(assert) {")
<add> .to.contain("visit('/foo/bar');")
<add> .to.contain("andThen(function() {")
<add> .to.contain("assert.equal(currentURL(), '/foo/bar');");
<add>
<add> expect(_file('app/acceptance-tests/foo/bar.js'))
<add> .to.not.exist;
<add> }));
<ide> });
<ide>
<ide> it('acceptance-test foo for mocha', function() {
<del> // pass any additional command line options in the arguments array
<del> return generateAndDestroy(['acceptance-test', 'foo'], {
<del> packages: [
<del> { name: 'ember-cli-qunit', delete: true },
<del> { name: 'ember-cli-mocha', dev: true }
<del> ],
<del> files: [
<del> {
<del> file: 'tests/acceptance/foo-test.js',
<del> contains: [
<del> "import { describe, it, beforeEach, afterEach } from 'mocha';",
<del> "import { expect } from 'chai';",
<del> "describe('Acceptance | foo', function() {",
<del> "it('can visit /foo', function() {",
<del> "visit('/foo');",
<del> "andThen(function() {",
<del> "expect(currentURL()).to.equal('/foo');"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['acceptance-test', 'foo'];
<add>
<add> return emberNew()
<add> .then(() => modifyPackages([
<add> {name: 'ember-cli-qunit', delete: true},
<add> {name: 'ember-cli-mocha', dev: true}
<add> ]))
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/acceptance/foo-test.js'))
<add> .to.contain("import { describe, it, beforeEach, afterEach } from 'mocha';")
<add> .to.contain("import { expect } from 'chai';")
<add> .to.contain("describe('Acceptance | foo', function() {")
<add> .to.contain("it('can visit /foo', function() {")
<add> .to.contain("visit('/foo');")
<add> .to.contain("andThen(function() {")
<add> .to.contain("expect(currentURL()).to.equal('/foo');");
<add> }));
<ide> });
<ide> });
<ide><path>node-tests/blueprints/component-addon-test.js
<ide> 'use strict';
<ide>
<del>var setupTestHooks = require('ember-cli-blueprint-test-helpers/lib/helpers/setup');
<del>var BlueprintHelpers = require('ember-cli-blueprint-test-helpers/lib/helpers/blueprint-helper');
<del>var generateAndDestroy = BlueprintHelpers.generateAndDestroy;
<add>var blueprintHelpers = require('ember-cli-blueprint-test-helpers/helpers');
<add>var setupTestHooks = blueprintHelpers.setupTestHooks;
<add>var emberNew = blueprintHelpers.emberNew;
<add>var emberGenerateDestroy = blueprintHelpers.emberGenerateDestroy;
<add>
<add>var chai = require('ember-cli-blueprint-test-helpers/chai');
<add>var expect = chai.expect;
<ide>
<ide> describe('Acceptance: ember generate and destroy component-addon', function() {
<ide> setupTestHooks(this);
<ide>
<ide> it('component-addon foo-bar', function() {
<del> // pass any additional command line options in the arguments array
<del> return generateAndDestroy(['component-addon', 'foo-bar'], {
<del> target: 'addon',
<del> // define files to assert, and their contents
<del> files: [
<del> {
<del> file: 'app/components/foo-bar.js',
<del> contents: "export { default } from 'my-addon/components/foo-bar';"
<del> }
<del> ]
<del> });
<add> var args = ['component-addon', 'foo-bar'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/components/foo-bar.js'))
<add> .to.contain("export { default } from 'my-addon/components/foo-bar';");
<add> }));
<ide> });
<ide> });
<ide><path>node-tests/blueprints/component-test.js
<ide> 'use strict';
<ide>
<del>var setupTestHooks = require('ember-cli-blueprint-test-helpers/lib/helpers/setup');
<del>var BlueprintHelpers = require('ember-cli-blueprint-test-helpers/lib/helpers/blueprint-helper');
<del>var generateAndDestroy = BlueprintHelpers.generateAndDestroy;
<add>var blueprintHelpers = require('ember-cli-blueprint-test-helpers/helpers');
<add>var setupTestHooks = blueprintHelpers.setupTestHooks;
<add>var emberNew = blueprintHelpers.emberNew;
<add>var emberGenerateDestroy = blueprintHelpers.emberGenerateDestroy;
<add>var modifyPackages = blueprintHelpers.modifyPackages;
<add>var setupPodConfig = blueprintHelpers.setupPodConfig;
<add>
<add>var chai = require('ember-cli-blueprint-test-helpers/chai');
<add>var expect = chai.expect;
<ide>
<ide> describe('Acceptance: ember generate component', function() {
<ide> setupTestHooks(this);
<ide>
<ide> it('component x-foo', function() {
<del> return generateAndDestroy(['component', 'x-foo'], {
<del> files:[
<del> {
<del> file: 'app/components/x-foo.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "export default Ember.Component.extend({",
<del> "});"
<del> ]
<del> },
<del> {
<del> file: 'app/templates/components/x-foo.hbs',
<del> contains: "{{yield}}"
<del> },
<del> {
<del> file: 'tests/integration/components/x-foo-test.js',
<del> contains: [
<del> "import { moduleForComponent, test } from 'ember-qunit';",
<del> "import hbs from 'htmlbars-inline-precompile';",
<del> "moduleForComponent('x-foo'",
<del> "integration: true",
<del> "{{x-foo}}",
<del> "{{#x-foo}}"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['component', 'x-foo'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/components/x-foo.js')).to.contain("import Ember from 'ember';")
<add> .to.contain("export default Ember.Component.extend({")
<add> .to.contain("});");
<add>
<add> expect(_file('app/templates/components/x-foo.hbs'))
<add> .to.contain("{{yield}}");
<add>
<add> expect(_file('tests/integration/components/x-foo-test.js'))
<add> .to.contain("import { moduleForComponent, test } from 'ember-qunit';")
<add> .to.contain("import hbs from 'htmlbars-inline-precompile';")
<add> .to.contain("moduleForComponent('x-foo'")
<add> .to.contain("integration: true")
<add> .to.contain("{{x-foo}}")
<add> .to.contain("{{#x-foo}}");
<add> }));
<ide> });
<ide>
<ide> it('component foo/x-foo', function() {
<del> return generateAndDestroy(['component', 'foo/x-foo'], {
<del> files: [
<del> {
<del> file: 'app/components/foo/x-foo.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "export default Ember.Component.extend({",
<del> "});"
<del> ]
<del> },
<del> {
<del> file: 'app/templates/components/foo/x-foo.hbs',
<del> contains: "{{yield}}"
<del> },
<del> {
<del> file: 'tests/integration/components/foo/x-foo-test.js',
<del> contains: [
<del> "import { moduleForComponent, test } from 'ember-qunit';",
<del> "import hbs from 'htmlbars-inline-precompile';",
<del> "moduleForComponent('foo/x-foo'",
<del> "integration: true",
<del> "{{foo/x-foo}}",
<del> "{{#foo/x-foo}}"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['component', 'foo/x-foo'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/components/foo/x-foo.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain("export default Ember.Component.extend({")
<add> .to.contain("});");
<add>
<add> expect(_file('app/templates/components/foo/x-foo.hbs'))
<add> .to.contain("{{yield}}");
<add>
<add> expect(_file('tests/integration/components/foo/x-foo-test.js'))
<add> .to.contain("import { moduleForComponent, test } from 'ember-qunit';")
<add> .to.contain("import hbs from 'htmlbars-inline-precompile';")
<add> .to.contain("moduleForComponent('foo/x-foo'")
<add> .to.contain("integration: true")
<add> .to.contain("{{foo/x-foo}}")
<add> .to.contain("{{#foo/x-foo}}");
<add> }));
<ide> });
<ide>
<ide> it('component x-foo ignores --path option', function() {
<del> return generateAndDestroy(['component', 'x-foo', '--path', 'foo'], {
<del> files: [
<del> {
<del> file: 'app/components/x-foo.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "export default Ember.Component.extend({",
<del> "});"
<del> ]
<del> },
<del> {
<del> file: 'app/templates/components/x-foo.hbs',
<del> contains: "{{yield}}"
<del> },
<del> {
<del> file: 'tests/integration/components/x-foo-test.js',
<del> contains: [
<del> "import { moduleForComponent, test } from 'ember-qunit';",
<del> "import hbs from 'htmlbars-inline-precompile';",
<del> "moduleForComponent('x-foo'",
<del> "integration: true",
<del> "{{x-foo}}",
<del> "{{#x-foo}}"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['component', 'x-foo', '--path', 'foo'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/components/x-foo.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain("export default Ember.Component.extend({")
<add> .to.contain("});");
<add>
<add> expect(_file('app/templates/components/x-foo.hbs'))
<add> .to.contain("{{yield}}");
<add>
<add> expect(_file('tests/integration/components/x-foo-test.js'))
<add> .to.contain("import { moduleForComponent, test } from 'ember-qunit';")
<add> .to.contain("import hbs from 'htmlbars-inline-precompile';")
<add> .to.contain("moduleForComponent('x-foo'")
<add> .to.contain("integration: true")
<add> .to.contain("{{x-foo}}")
<add> .to.contain("{{#x-foo}}");
<add> }));
<ide> });
<ide>
<ide> it('in-addon component x-foo', function() {
<del> return generateAndDestroy(['component', 'x-foo'], {
<del> target: 'addon',
<del> files: [
<del> {
<del> file:'addon/components/x-foo.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "import layout from '../templates/components/x-foo';",
<del> "export default Ember.Component.extend({",
<del> "layout",
<del> "});"
<del> ]
<del> },
<del> {
<del> file:'addon/templates/components/x-foo.hbs',
<del> contains: "{{yield}}"
<del> },
<del> {
<del> file:'app/components/x-foo.js',
<del> contains: [
<del> "export { default } from 'my-addon/components/x-foo';"
<del> ]
<del> },
<del> {
<del> file:'tests/integration/components/x-foo-test.js',
<del> contains: [
<del> "import { moduleForComponent, test } from 'ember-qunit';",
<del> "import hbs from 'htmlbars-inline-precompile';",
<del> "moduleForComponent('x-foo'",
<del> "integration: true",
<del> "{{x-foo}}",
<del> "{{#x-foo}}"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['component', 'x-foo'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('addon/components/x-foo.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain("import layout from '../templates/components/x-foo';")
<add> .to.contain("export default Ember.Component.extend({")
<add> .to.contain("layout")
<add> .to.contain("});");
<add>
<add> expect(_file('addon/templates/components/x-foo.hbs'))
<add> .to.contain("{{yield}}");
<add>
<add> expect(_file('app/components/x-foo.js'))
<add> .to.contain("export { default } from 'my-addon/components/x-foo';");
<add>
<add> expect(_file('tests/integration/components/x-foo-test.js'))
<add> .to.contain("import { moduleForComponent, test } from 'ember-qunit';")
<add> .to.contain("import hbs from 'htmlbars-inline-precompile';")
<add> .to.contain("moduleForComponent('x-foo'")
<add> .to.contain("integration: true")
<add> .to.contain("{{x-foo}}")
<add> .to.contain("{{#x-foo}}");
<add> }));
<ide> });
<ide>
<ide> it('in-addon component nested/x-foo', function() {
<del> return generateAndDestroy(['component', 'nested/x-foo'], {
<del> target: 'addon',
<del> files: [
<del> {
<del> file:'addon/components/nested/x-foo.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "import layout from '../../templates/components/nested/x-foo';",
<del> "export default Ember.Component.extend({",
<del> "layout",
<del> "});"
<del> ]
<del> },
<del> {
<del> file:'addon/templates/components/nested/x-foo.hbs',
<del> contains: "{{yield}}"
<del> },
<del> {
<del> file:'app/components/nested/x-foo.js',
<del> contains: [
<del> "export { default } from 'my-addon/components/nested/x-foo';"
<del> ]
<del> },
<del> {
<del> file:'tests/integration/components/nested/x-foo-test.js',
<del> contains: [
<del> "import { moduleForComponent, test } from 'ember-qunit';",
<del> "import hbs from 'htmlbars-inline-precompile';",
<del> "moduleForComponent('nested/x-foo'",
<del> "integration: true",
<del> "{{nested/x-foo}}",
<del> "{{#nested/x-foo}}"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['component', 'nested/x-foo'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('addon/components/nested/x-foo.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain("import layout from '../../templates/components/nested/x-foo';")
<add> .to.contain("export default Ember.Component.extend({")
<add> .to.contain("layout")
<add> .to.contain("});");
<add>
<add> expect(_file('addon/templates/components/nested/x-foo.hbs'))
<add> .to.contain("{{yield}}");
<add>
<add> expect(_file('app/components/nested/x-foo.js'))
<add> .to.contain("export { default } from 'my-addon/components/nested/x-foo';");
<add>
<add> expect(_file('tests/integration/components/nested/x-foo-test.js'))
<add> .to.contain("import { moduleForComponent, test } from 'ember-qunit';")
<add> .to.contain("import hbs from 'htmlbars-inline-precompile';")
<add> .to.contain("moduleForComponent('nested/x-foo'")
<add> .to.contain("integration: true")
<add> .to.contain("{{nested/x-foo}}")
<add> .to.contain("{{#nested/x-foo}}");
<add> }));
<ide> });
<ide>
<ide> it('dummy component x-foo', function() {
<del> return generateAndDestroy(['component', 'x-foo', '--dummy'], {
<del> target: 'addon',
<del> files: [
<del> {
<del> file: 'tests/dummy/app/components/x-foo.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "export default Ember.Component.extend({",
<del> "});"
<del> ]
<del> },
<del> {
<del> file: 'tests/dummy/app/templates/components/x-foo.hbs',
<del> contains: "{{yield}}"
<del> },
<del> {
<del> file: 'app/components/x-foo.js',
<del> exists: false
<del> },
<del> {
<del> file: 'tests/unit/components/x-foo-test.js',
<del> exists: false
<del> }
<del> ]
<del> });
<add> var args = ['component', 'x-foo', '--dummy'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/dummy/app/components/x-foo.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain("export default Ember.Component.extend({")
<add> .to.contain("});");
<add>
<add> expect(_file('tests/dummy/app/templates/components/x-foo.hbs'))
<add> .to.contain("{{yield}}");
<add>
<add> expect(_file('app/components/x-foo.js'))
<add> .to.not.exist;
<add>
<add> expect(_file('tests/unit/components/x-foo-test.js'))
<add> .to.not.exist;
<add> }));
<ide> });
<ide>
<ide> it('dummy component nested/x-foo', function() {
<del> return generateAndDestroy(['component', 'nested/x-foo', '--dummy'], {
<del> target: 'addon',
<del> files: [
<del> {
<del> file: 'tests/dummy/app/components/nested/x-foo.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "export default Ember.Component.extend({",
<del> "});"
<del> ]
<del> },
<del> {
<del> file: 'tests/dummy/app/templates/components/nested/x-foo.hbs',
<del> contains: "{{yield}}"
<del> },
<del> {
<del> file: 'app/components/nested/x-foo.js',
<del> exists: false
<del> },
<del> {
<del> file: 'tests/unit/components/nested/x-foo-test.js',
<del> exists: false
<del> }
<del> ]
<del> });
<add> var args = ['component', 'nested/x-foo', '--dummy'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/dummy/app/components/nested/x-foo.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain("export default Ember.Component.extend({")
<add> .to.contain("});");
<add>
<add> expect(_file('tests/dummy/app/templates/components/nested/x-foo.hbs'))
<add> .to.contain("{{yield}}");
<add>
<add> expect(_file('app/components/nested/x-foo.js'))
<add> .to.not.exist;
<add>
<add> expect(_file('tests/unit/components/nested/x-foo-test.js'))
<add> .to.not.exist;
<add> }));
<ide> });
<ide>
<ide> it('in-repo-addon component x-foo', function() {
<del> return generateAndDestroy(['component', 'x-foo', '--in-repo-addon=my-addon'], {
<del> target: 'inRepoAddon',
<del> files: [
<del> {
<del> file: 'lib/my-addon/addon/components/x-foo.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "import layout from '../templates/components/x-foo';",
<del> "export default Ember.Component.extend({",
<del> "layout",
<del> "});"
<del> ]
<del> },
<del> {
<del> file: 'lib/my-addon/addon/templates/components/x-foo.hbs',
<del> contains: "{{yield}}"
<del> },
<del> {
<del> file: 'lib/my-addon/app/components/x-foo.js',
<del> contains: [
<del> "export { default } from 'my-addon/components/x-foo';"
<del> ]
<del> },
<del> {
<del> file: 'tests/integration/components/x-foo-test.js',
<del> contains: [
<del> "import { moduleForComponent, test } from 'ember-qunit';",
<del> "import hbs from 'htmlbars-inline-precompile';",
<del> "moduleForComponent('x-foo'",
<del> "integration: true",
<del> "{{x-foo}}",
<del> "{{#x-foo}}"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['component', 'x-foo', '--in-repo-addon=my-addon'];
<add>
<add> return emberNew({ target: 'in-repo-addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('lib/my-addon/addon/components/x-foo.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain("import layout from '../templates/components/x-foo';")
<add> .to.contain("export default Ember.Component.extend({")
<add> .to.contain("layout")
<add> .to.contain("});");
<add>
<add> expect(_file('lib/my-addon/addon/templates/components/x-foo.hbs'))
<add> .to.contain("{{yield}}");
<add>
<add> expect(_file('lib/my-addon/app/components/x-foo.js'))
<add> .to.contain("export { default } from 'my-addon/components/x-foo';");
<add>
<add> expect(_file('tests/integration/components/x-foo-test.js'))
<add> .to.contain("import { moduleForComponent, test } from 'ember-qunit';")
<add> .to.contain("import hbs from 'htmlbars-inline-precompile';")
<add> .to.contain("moduleForComponent('x-foo'")
<add> .to.contain("integration: true")
<add> .to.contain("{{x-foo}}")
<add> .to.contain("{{#x-foo}}");
<add> }));
<ide> });
<ide>
<ide> it('in-repo-addon component-test x-foo', function() {
<del> return generateAndDestroy(['component-test', 'x-foo', '--in-repo-addon=my-addon'], {
<del> target: 'inRepoAddon',
<del> files: [
<del> {
<del> file: 'tests/integration/components/x-foo-test.js',
<del> contains: [
<del> "import { moduleForComponent, test } from 'ember-qunit';",
<del> "import hbs from 'htmlbars-inline-precompile';",
<del> "moduleForComponent('x-foo'",
<del> "integration: true",
<del> "{{x-foo}}",
<del> "{{#x-foo}}"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['component-test', 'x-foo', '--in-repo-addon=my-addon'];
<add>
<add> return emberNew({ target: 'in-repo-addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/integration/components/x-foo-test.js'))
<add> .to.contain("import { moduleForComponent, test } from 'ember-qunit';")
<add> .to.contain("import hbs from 'htmlbars-inline-precompile';")
<add> .to.contain("moduleForComponent('x-foo'")
<add> .to.contain("integration: true")
<add> .to.contain("{{x-foo}}")
<add> .to.contain("{{#x-foo}}");
<add> }));
<ide> });
<ide>
<ide> it('in-repo-addon component-test x-foo --unit', function() {
<del> return generateAndDestroy(['component-test', 'x-foo', '--in-repo-addon=my-addon', '--unit'], {
<del> target: 'inRepoAddon',
<del> files: [
<del> {
<del> file: 'tests/unit/components/x-foo-test.js',
<del> contains: [
<del> "import { moduleForComponent, test } from 'ember-qunit';",
<del> "moduleForComponent('x-foo'",
<del> "unit: true"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['component-test', 'x-foo', '--in-repo-addon=my-addon', '--unit'];
<add>
<add> return emberNew({ target: 'in-repo-addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/unit/components/x-foo-test.js'))
<add> .to.contain("import { moduleForComponent, test } from 'ember-qunit';")
<add> .to.contain("moduleForComponent('x-foo'")
<add> .to.contain("unit: true");
<add> }));
<ide> });
<ide>
<ide> it('in-repo-addon component nested/x-foo', function() {
<del> return generateAndDestroy(['component', 'nested/x-foo', '--in-repo-addon=my-addon'], {
<del> target: 'inRepoAddon',
<del> files: [
<del> {
<del> file: 'lib/my-addon/addon/components/nested/x-foo.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "import layout from '../../templates/components/nested/x-foo';",
<del> "export default Ember.Component.extend({",
<del> "layout",
<del> "});"
<del> ]
<del> },
<del> {
<del> file: 'lib/my-addon/addon/templates/components/nested/x-foo.hbs',
<del> contains: "{{yield}}"
<del> },
<del> {
<del> file: 'lib/my-addon/app/components/nested/x-foo.js',
<del> contains: [
<del> "export { default } from 'my-addon/components/nested/x-foo';"
<del> ]
<del> },
<del> {
<del> file: 'tests/integration/components/nested/x-foo-test.js',
<del> contains: [
<del> "import { moduleForComponent, test } from 'ember-qunit';",
<del> "import hbs from 'htmlbars-inline-precompile';",
<del> "moduleForComponent('nested/x-foo'",
<del> "integration: true"
<del> ]
<del> }
<del> ]
<del> });
<del> });
<del>/**
<del>* Pod tests
<del>*
<del>*/
<add> var args = ['component', 'nested/x-foo', '--in-repo-addon=my-addon'];
<add>
<add> return emberNew({ target: 'in-repo-addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('lib/my-addon/addon/components/nested/x-foo.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain("import layout from '../../templates/components/nested/x-foo';")
<add> .to.contain("export default Ember.Component.extend({")
<add> .to.contain("layout")
<add> .to.contain("});");
<add>
<add> expect(_file('lib/my-addon/addon/templates/components/nested/x-foo.hbs'))
<add> .to.contain("{{yield}}");
<add>
<add> expect(_file('lib/my-addon/app/components/nested/x-foo.js'))
<add> .to.contain("export { default } from 'my-addon/components/nested/x-foo';");
<add>
<add> expect(_file('tests/integration/components/nested/x-foo-test.js'))
<add> .to.contain("import { moduleForComponent, test } from 'ember-qunit';")
<add> .to.contain("import hbs from 'htmlbars-inline-precompile';")
<add> .to.contain("moduleForComponent('nested/x-foo'")
<add> .to.contain("integration: true");
<add> }));
<add> });
<add> /**
<add> * Pod tests
<add> *
<add> */
<ide> it('component x-foo --pod', function() {
<del> return generateAndDestroy(['component', 'x-foo', '--pod'], {
<del> files: [
<del> {
<del> file: 'app/components/x-foo/component.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "export default Ember.Component.extend({",
<del> "});"
<del> ]
<del> },
<del> {
<del> file: 'app/components/x-foo/template.hbs',
<del> contains: "{{yield}}"
<del> },
<del> {
<del> file: 'tests/integration/components/x-foo/component-test.js',
<del> contains: [
<del> "import { moduleForComponent, test } from 'ember-qunit';",
<del> "import hbs from 'htmlbars-inline-precompile';",
<del> "moduleForComponent('x-foo'",
<del> "integration: true"
<del> ]
<del> },
<del> ]
<del> });
<add> var args = ['component', 'x-foo', '--pod'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/components/x-foo/component.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain("export default Ember.Component.extend({")
<add> .to.contain("});");
<add>
<add> expect(_file('app/components/x-foo/template.hbs'))
<add> .to.contain("{{yield}}");
<add>
<add> expect(_file('tests/integration/components/x-foo/component-test.js'))
<add> .to.contain("import { moduleForComponent, test } from 'ember-qunit';")
<add> .to.contain("import hbs from 'htmlbars-inline-precompile';")
<add> .to.contain("moduleForComponent('x-foo'")
<add> .to.contain("integration: true");
<add> }));
<ide> });
<ide>
<ide> it('component x-foo --pod podModulePrefix', function() {
<del> return generateAndDestroy(['component', 'x-foo', '--pod'], {
<del> podModulePrefix: true,
<del> files: [
<del> {
<del> file: 'app/pods/components/x-foo/component.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "export default Ember.Component.extend({",
<del> "});"
<del> ]
<del> },
<del> {
<del> file: 'app/pods/components/x-foo/template.hbs',
<del> contains: "{{yield}}"
<del> },
<del> {
<del> file: 'tests/integration/pods/components/x-foo/component-test.js',
<del> contains: [
<del> "import { moduleForComponent, test } from 'ember-qunit';",
<del> "import hbs from 'htmlbars-inline-precompile';",
<del> "moduleForComponent('x-foo'",
<del> "integration: true",
<del> "{{x-foo}}",
<del> "{{#x-foo}}"
<del> ]
<del> },
<del> ]
<del> });
<add> var args = ['component', 'x-foo', '--pod'];
<add>
<add> return emberNew()
<add> .then(() => setupPodConfig({ podModulePrefix: true }))
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/pods/components/x-foo/component.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain("export default Ember.Component.extend({")
<add> .to.contain("});");
<add>
<add> expect(_file('app/pods/components/x-foo/template.hbs'))
<add> .to.contain("{{yield}}");
<add>
<add> expect(_file('tests/integration/pods/components/x-foo/component-test.js'))
<add> .to.contain("import { moduleForComponent, test } from 'ember-qunit';")
<add> .to.contain("import hbs from 'htmlbars-inline-precompile';")
<add> .to.contain("moduleForComponent('x-foo'")
<add> .to.contain("integration: true")
<add> .to.contain("{{x-foo}}")
<add> .to.contain("{{#x-foo}}");
<add> }));
<ide> });
<ide>
<ide> it('component foo/x-foo --pod', function() {
<del> return generateAndDestroy(['component', 'foo/x-foo', '--pod'], {
<del> files: [
<del> {
<del> file: 'app/components/foo/x-foo/component.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "export default Ember.Component.extend({",
<del> "});"
<del> ]
<del> },
<del> {
<del> file: 'app/components/foo/x-foo/template.hbs',
<del> contains: "{{yield}}"
<del> },
<del> {
<del> file: 'tests/integration/components/foo/x-foo/component-test.js',
<del> contains: [
<del> "import { moduleForComponent, test } from 'ember-qunit';",
<del> "import hbs from 'htmlbars-inline-precompile';",
<del> "moduleForComponent('foo/x-foo'",
<del> "integration: true",
<del> "{{foo/x-foo}}",
<del> "{{#foo/x-foo}}"
<del> ]
<del> },
<del> ]
<del> });
<add> var args = ['component', 'foo/x-foo', '--pod'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/components/foo/x-foo/component.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain("export default Ember.Component.extend({")
<add> .to.contain("});");
<add>
<add> expect(_file('app/components/foo/x-foo/template.hbs'))
<add> .to.contain("{{yield}}");
<add>
<add> expect(_file('tests/integration/components/foo/x-foo/component-test.js'))
<add> .to.contain("import { moduleForComponent, test } from 'ember-qunit';")
<add> .to.contain("import hbs from 'htmlbars-inline-precompile';")
<add> .to.contain("moduleForComponent('foo/x-foo'")
<add> .to.contain("integration: true")
<add> .to.contain("{{foo/x-foo}}")
<add> .to.contain("{{#foo/x-foo}}");
<add> }));
<ide> });
<ide>
<ide> it('component foo/x-foo --pod podModulePrefix', function() {
<del> return generateAndDestroy(['component', 'foo/x-foo', '--pod'], {
<del> podModulePrefix: true,
<del> files: [
<del> {
<del> file: 'app/pods/components/foo/x-foo/component.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "export default Ember.Component.extend({",
<del> "});"
<del> ]
<del> },
<del> {
<del> file: 'app/pods/components/foo/x-foo/template.hbs',
<del> contains: "{{yield}}"
<del> },
<del> {
<del> file: 'tests/integration/pods/components/foo/x-foo/component-test.js',
<del> contains: [
<del> "import { moduleForComponent, test } from 'ember-qunit';",
<del> "import hbs from 'htmlbars-inline-precompile';",
<del> "moduleForComponent('foo/x-foo'",
<del> "integration: true",
<del> "{{foo/x-foo}}",
<del> "{{#foo/x-foo}}"
<del> ]
<del> },
<del> ]
<del> });
<add> var args = ['component', 'foo/x-foo', '--pod'];
<add>
<add> return emberNew()
<add> .then(() => setupPodConfig({ podModulePrefix: true }))
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/pods/components/foo/x-foo/component.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain("export default Ember.Component.extend({")
<add> .to.contain("});");
<add>
<add> expect(_file('app/pods/components/foo/x-foo/template.hbs'))
<add> .to.contain("{{yield}}");
<add>
<add> expect(_file('tests/integration/pods/components/foo/x-foo/component-test.js'))
<add> .to.contain("import { moduleForComponent, test } from 'ember-qunit';")
<add> .to.contain("import hbs from 'htmlbars-inline-precompile';")
<add> .to.contain("moduleForComponent('foo/x-foo'")
<add> .to.contain("integration: true")
<add> .to.contain("{{foo/x-foo}}")
<add> .to.contain("{{#foo/x-foo}}");
<add> }));
<ide> });
<ide>
<ide> it('component x-foo --pod --path', function() {
<del> return generateAndDestroy(['component', 'x-foo', '--pod', '--path', 'bar'], {
<del> files: [
<del> {
<del> file: 'app/bar/x-foo/component.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "export default Ember.Component.extend({",
<del> "});"
<del> ]
<del> },
<del> {
<del> file: 'app/bar/x-foo/template.hbs',
<del> contains: "{{yield}}"
<del> },
<del> {
<del> file: 'tests/integration/bar/x-foo/component-test.js',
<del> contains: [
<del> "import { moduleForComponent, test } from 'ember-qunit';",
<del> "import hbs from 'htmlbars-inline-precompile';",
<del> "moduleForComponent('bar/x-foo'",
<del> "integration: true",
<del> "{{bar/x-foo}}",
<del> "{{#bar/x-foo}}"
<del> ]
<del> },
<del> ]
<del> });
<add> var args = ['component', 'x-foo', '--pod', '--path', 'bar'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/bar/x-foo/component.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain("export default Ember.Component.extend({")
<add> .to.contain("});");
<add>
<add> expect(_file('app/bar/x-foo/template.hbs'))
<add> .to.contain("{{yield}}");
<add>
<add> expect(_file('tests/integration/bar/x-foo/component-test.js'))
<add> .to.contain("import { moduleForComponent, test } from 'ember-qunit';")
<add> .to.contain("import hbs from 'htmlbars-inline-precompile';")
<add> .to.contain("moduleForComponent('bar/x-foo'")
<add> .to.contain("integration: true")
<add> .to.contain("{{bar/x-foo}}")
<add> .to.contain("{{#bar/x-foo}}");
<add> }));
<ide> });
<ide>
<ide> it('component x-foo --pod --path podModulePrefix', function() {
<del> return generateAndDestroy(['component', 'x-foo', '--pod', '--path', 'bar'], {
<del> podModulePrefix: true,
<del> files: [
<del> {
<del> file: 'app/pods/bar/x-foo/component.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "export default Ember.Component.extend({",
<del> "});"
<del> ]
<del> },
<del> {
<del> file: 'app/pods/bar/x-foo/template.hbs',
<del> contains: "{{yield}}"
<del> },
<del> {
<del> file: 'tests/integration/pods/bar/x-foo/component-test.js',
<del> contains: [
<del> "import { moduleForComponent, test } from 'ember-qunit';",
<del> "import hbs from 'htmlbars-inline-precompile';",
<del> "moduleForComponent('bar/x-foo'",
<del> "integration: true",
<del> "{{bar/x-foo}}",
<del> "{{#bar/x-foo}}"
<del> ]
<del> },
<del> ]
<del> });
<add> var args = ['component', 'x-foo', '--pod', '--path', 'bar'];
<add>
<add> return emberNew()
<add> .then(() => setupPodConfig({ podModulePrefix: true }))
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/pods/bar/x-foo/component.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain("export default Ember.Component.extend({")
<add> .to.contain("});");
<add>
<add> expect(_file('app/pods/bar/x-foo/template.hbs'))
<add> .to.contain("{{yield}}");
<add>
<add> expect(_file('tests/integration/pods/bar/x-foo/component-test.js'))
<add> .to.contain("import { moduleForComponent, test } from 'ember-qunit';")
<add> .to.contain("import hbs from 'htmlbars-inline-precompile';")
<add> .to.contain("moduleForComponent('bar/x-foo'")
<add> .to.contain("integration: true")
<add> .to.contain("{{bar/x-foo}}")
<add> .to.contain("{{#bar/x-foo}}");
<add> }));
<ide> });
<ide>
<ide> it('component foo/x-foo --pod --path', function() {
<del> return generateAndDestroy(['component', 'foo/x-foo', '--pod', '--path', 'bar'], {
<del> files: [
<del> {
<del> file: 'app/bar/foo/x-foo/component.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "export default Ember.Component.extend({",
<del> "});"
<del> ]
<del> },
<del> {
<del> file: 'app/bar/foo/x-foo/template.hbs',
<del> contains: "{{yield}}"
<del> },
<del> {
<del> file: 'tests/integration/bar/foo/x-foo/component-test.js',
<del> contains: [
<del> "import { moduleForComponent, test } from 'ember-qunit';",
<del> "import hbs from 'htmlbars-inline-precompile';",
<del> "moduleForComponent('bar/foo/x-foo'",
<del> "integration: true",
<del> "{{bar/foo/x-foo}}",
<del> "{{#bar/foo/x-foo}}"
<del> ]
<del> },
<del> ]
<del> });
<add> var args = ['component', 'foo/x-foo', '--pod', '--path', 'bar'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/bar/foo/x-foo/component.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain("export default Ember.Component.extend({")
<add> .to.contain("});");
<add>
<add> expect(_file('app/bar/foo/x-foo/template.hbs'))
<add> .to.contain("{{yield}}");
<add>
<add> expect(_file('tests/integration/bar/foo/x-foo/component-test.js'))
<add> .to.contain("import { moduleForComponent, test } from 'ember-qunit';")
<add> .to.contain("import hbs from 'htmlbars-inline-precompile';")
<add> .to.contain("moduleForComponent('bar/foo/x-foo'")
<add> .to.contain("integration: true")
<add> .to.contain("{{bar/foo/x-foo}}")
<add> .to.contain("{{#bar/foo/x-foo}}");
<add> }));
<ide> });
<ide>
<ide> it('component foo/x-foo --pod --path podModulePrefix', function() {
<del> return generateAndDestroy(['component', 'foo/x-foo', '--pod', '--path', 'bar'], {
<del> podModulePrefix: true,
<del> files: [
<del> {
<del> file: 'app/pods/bar/foo/x-foo/component.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "export default Ember.Component.extend({",
<del> "});"
<del> ]
<del> },
<del> {
<del> file: 'app/pods/bar/foo/x-foo/template.hbs',
<del> contains: "{{yield}}"
<del> },
<del> {
<del> file: 'tests/integration/pods/bar/foo/x-foo/component-test.js',
<del> contains: [
<del> "import { moduleForComponent, test } from 'ember-qunit';",
<del> "moduleForComponent('bar/foo/x-foo'",
<del> "integration: true",
<del> "{{bar/foo/x-foo}}",
<del> "{{#bar/foo/x-foo}}"
<del> ]
<del> },
<del> ]
<del> });
<add> var args = ['component', 'foo/x-foo', '--pod', '--path', 'bar'];
<add>
<add> return emberNew()
<add> .then(() => setupPodConfig({ podModulePrefix: true }))
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/pods/bar/foo/x-foo/component.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain("export default Ember.Component.extend({")
<add> .to.contain("});");
<add>
<add> expect(_file('app/pods/bar/foo/x-foo/template.hbs'))
<add> .to.contain("{{yield}}");
<add>
<add> expect(_file('tests/integration/pods/bar/foo/x-foo/component-test.js'))
<add> .to.contain("import { moduleForComponent, test } from 'ember-qunit';")
<add> .to.contain("moduleForComponent('bar/foo/x-foo'")
<add> .to.contain("integration: true")
<add> .to.contain("{{bar/foo/x-foo}}")
<add> .to.contain("{{#bar/foo/x-foo}}");
<add> }));
<ide> });
<ide>
<ide> it('component x-foo --pod --path nested', function() {
<del> return generateAndDestroy(['component', 'x-foo', '--pod', '--path', 'bar/baz'], {
<del> files: [
<del> {
<del> file: 'app/bar/baz/x-foo/component.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "export default Ember.Component.extend({",
<del> "});"
<del> ]
<del> },
<del> {
<del> file: 'app/bar/baz/x-foo/template.hbs',
<del> contains: "{{yield}}"
<del> },
<del> {
<del> file: 'tests/integration/bar/baz/x-foo/component-test.js',
<del> contains: [
<del> "import { moduleForComponent, test } from 'ember-qunit';",
<del> "import hbs from 'htmlbars-inline-precompile';",
<del> "moduleForComponent('bar/baz/x-foo'",
<del> "integration: true",
<del> "{{bar/baz/x-foo}}",
<del> "{{#bar/baz/x-foo}}"
<del> ]
<del> },
<del> ]
<del> });
<add> var args = ['component', 'x-foo', '--pod', '--path', 'bar/baz'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/bar/baz/x-foo/component.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain("export default Ember.Component.extend({")
<add> .to.contain("});");
<add>
<add> expect(_file('app/bar/baz/x-foo/template.hbs'))
<add> .to.contain("{{yield}}");
<add>
<add> expect(_file('tests/integration/bar/baz/x-foo/component-test.js'))
<add> .to.contain("import { moduleForComponent, test } from 'ember-qunit';")
<add> .to.contain("import hbs from 'htmlbars-inline-precompile';")
<add> .to.contain("moduleForComponent('bar/baz/x-foo'")
<add> .to.contain("integration: true")
<add> .to.contain("{{bar/baz/x-foo}}")
<add> .to.contain("{{#bar/baz/x-foo}}");
<add> }));
<ide> });
<ide>
<ide> it('component x-foo --pod --path nested podModulePrefix', function() {
<del> return generateAndDestroy(['component', 'x-foo', '--pod', '--path', 'bar/baz'], {
<del> podModulePrefix: true,
<del> files: [
<del> {
<del> file: 'app/pods/bar/baz/x-foo/component.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "export default Ember.Component.extend({",
<del> "});"
<del> ]
<del> },
<del> {
<del> file: 'app/pods/bar/baz/x-foo/template.hbs',
<del> contains: "{{yield}}"
<del> },
<del> {
<del> file: 'tests/integration/pods/bar/baz/x-foo/component-test.js',
<del> contains: [
<del> "import { moduleForComponent, test } from 'ember-qunit';",
<del> "import hbs from 'htmlbars-inline-precompile';",
<del> "moduleForComponent('bar/baz/x-foo'",
<del> "integration: true",
<del> "{{bar/baz/x-foo}}",
<del> "{{#bar/baz/x-foo}}"
<del> ]
<del> },
<del> ]
<del> });
<add> var args = ['component', 'x-foo', '--pod', '--path', 'bar/baz'];
<add>
<add> return emberNew()
<add> .then(() => setupPodConfig({ podModulePrefix: true }))
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/pods/bar/baz/x-foo/component.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain("export default Ember.Component.extend({")
<add> .to.contain("});");
<add>
<add> expect(_file('app/pods/bar/baz/x-foo/template.hbs'))
<add> .to.contain("{{yield}}");
<add>
<add> expect(_file('tests/integration/pods/bar/baz/x-foo/component-test.js'))
<add> .to.contain("import { moduleForComponent, test } from 'ember-qunit';")
<add> .to.contain("import hbs from 'htmlbars-inline-precompile';")
<add> .to.contain("moduleForComponent('bar/baz/x-foo'")
<add> .to.contain("integration: true")
<add> .to.contain("{{bar/baz/x-foo}}")
<add> .to.contain("{{#bar/baz/x-foo}}");
<add> }));
<ide> });
<ide>
<ide> it('component foo/x-foo --pod --path nested', function() {
<del> return generateAndDestroy(['component', 'foo/x-foo', '--pod', '--path', 'bar/baz'], {
<del> files: [
<del> {
<del> file: 'app/bar/baz/foo/x-foo/component.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "export default Ember.Component.extend({",
<del> "});"
<del> ]
<del> },
<del> {
<del> file: 'app/bar/baz/foo/x-foo/template.hbs',
<del> contains: "{{yield}}"
<del> },
<del> {
<del> file: 'tests/integration/bar/baz/foo/x-foo/component-test.js',
<del> contains: [
<del> "import { moduleForComponent, test } from 'ember-qunit';",
<del> "import hbs from 'htmlbars-inline-precompile';",
<del> "moduleForComponent('bar/baz/foo/x-foo'",
<del> "integration: true",
<del> "{{bar/baz/foo/x-foo}}",
<del> "{{#bar/baz/foo/x-foo}}"
<del> ]
<del> },
<del> ]
<del> });
<add> var args = ['component', 'foo/x-foo', '--pod', '--path', 'bar/baz'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/bar/baz/foo/x-foo/component.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain("export default Ember.Component.extend({")
<add> .to.contain("});");
<add>
<add> expect(_file('app/bar/baz/foo/x-foo/template.hbs'))
<add> .to.contain("{{yield}}");
<add>
<add> expect(_file('tests/integration/bar/baz/foo/x-foo/component-test.js'))
<add> .to.contain("import { moduleForComponent, test } from 'ember-qunit';")
<add> .to.contain("import hbs from 'htmlbars-inline-precompile';")
<add> .to.contain("moduleForComponent('bar/baz/foo/x-foo'")
<add> .to.contain("integration: true")
<add> .to.contain("{{bar/baz/foo/x-foo}}")
<add> .to.contain("{{#bar/baz/foo/x-foo}}");
<add> }));
<ide> });
<ide>
<ide> it('component foo/x-foo --pod --path nested podModulePrefix', function() {
<del> return generateAndDestroy(['component', 'foo/x-foo', '--pod', '--path', 'bar/baz'], {
<del> podModulePrefix: true,
<del> files: [
<del> {
<del> file: 'app/pods/bar/baz/foo/x-foo/component.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "export default Ember.Component.extend({",
<del> "});"
<del> ]
<del> },
<del> {
<del> file: 'app/pods/bar/baz/foo/x-foo/template.hbs',
<del> contains: "{{yield}}"
<del> },
<del> {
<del> file: 'tests/integration/pods/bar/baz/foo/x-foo/component-test.js',
<del> contains: [
<del> "import { moduleForComponent, test } from 'ember-qunit';",
<del> "import hbs from 'htmlbars-inline-precompile';",
<del> "moduleForComponent('bar/baz/foo/x-foo'",
<del> "integration: true",
<del> "{{bar/baz/foo/x-foo}}",
<del> "{{#bar/baz/foo/x-foo}}"
<del> ]
<del> },
<del> ]
<del> });
<add> var args = ['component', 'foo/x-foo', '--pod', '--path', 'bar/baz'];
<add>
<add> return emberNew()
<add> .then(() => setupPodConfig({ podModulePrefix: true }))
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/pods/bar/baz/foo/x-foo/component.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain("export default Ember.Component.extend({")
<add> .to.contain("});");
<add>
<add> expect(_file('app/pods/bar/baz/foo/x-foo/template.hbs'))
<add> .to.contain("{{yield}}");
<add>
<add> expect(_file('tests/integration/pods/bar/baz/foo/x-foo/component-test.js'))
<add> .to.contain("import { moduleForComponent, test } from 'ember-qunit';")
<add> .to.contain("import hbs from 'htmlbars-inline-precompile';")
<add> .to.contain("moduleForComponent('bar/baz/foo/x-foo'")
<add> .to.contain("integration: true")
<add> .to.contain("{{bar/baz/foo/x-foo}}")
<add> .to.contain("{{#bar/baz/foo/x-foo}}");
<add> }));
<ide> });
<ide>
<ide> it('component x-foo --pod -no-path', function() {
<del> return generateAndDestroy(['component', 'x-foo', '--pod', '-no-path'], {
<del> files: [
<del> {
<del> file: 'app/x-foo/component.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "export default Ember.Component.extend({",
<del> "});"
<del> ]
<del> },
<del> {
<del> file: 'app/x-foo/template.hbs',
<del> contains: "{{yield}}"
<del> },
<del> {
<del> file: 'tests/integration/x-foo/component-test.js',
<del> contains: [
<del> "import { moduleForComponent, test } from 'ember-qunit';",
<del> "import hbs from 'htmlbars-inline-precompile';",
<del> "moduleForComponent('x-foo'",
<del> "integration: true",
<del> "{{x-foo}}",
<del> "{{#x-foo}}"
<del> ]
<del> },
<del> ]
<del> });
<add> var args = ['component', 'x-foo', '--pod', '-no-path'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/x-foo/component.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain("export default Ember.Component.extend({")
<add> .to.contain("});");
<add>
<add> expect(_file('app/x-foo/template.hbs'))
<add> .to.contain("{{yield}}");
<add>
<add> expect(_file('tests/integration/x-foo/component-test.js'))
<add> .to.contain("import { moduleForComponent, test } from 'ember-qunit';")
<add> .to.contain("import hbs from 'htmlbars-inline-precompile';")
<add> .to.contain("moduleForComponent('x-foo'")
<add> .to.contain("integration: true")
<add> .to.contain("{{x-foo}}")
<add> .to.contain("{{#x-foo}}");
<add> }));
<ide> });
<ide>
<ide> it('component x-foo --pod -no-path podModulePrefix', function() {
<del> return generateAndDestroy(['component', 'x-foo', '--pod', '-no-path'], {
<del> podModulePrefix: true,
<del> files: [
<del> {
<del> file: 'app/pods/x-foo/component.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "export default Ember.Component.extend({",
<del> "});"
<del> ]
<del> },
<del> {
<del> file: 'app/pods/x-foo/template.hbs',
<del> contains: "{{yield}}"
<del> },
<del> {
<del> file: 'tests/integration/pods/x-foo/component-test.js',
<del> contains: [
<del> "import { moduleForComponent, test } from 'ember-qunit';",
<del> "import hbs from 'htmlbars-inline-precompile';",
<del> "moduleForComponent('x-foo'",
<del> "integration: true",
<del> "{{x-foo}}",
<del> "{{#x-foo}}"
<del> ]
<del> },
<del> ]
<del> });
<add> var args = ['component', 'x-foo', '--pod', '-no-path'];
<add>
<add> return emberNew()
<add> .then(() => setupPodConfig({ podModulePrefix: true }))
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/pods/x-foo/component.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain("export default Ember.Component.extend({")
<add> .to.contain("});");
<add>
<add> expect(_file('app/pods/x-foo/template.hbs'))
<add> .to.contain("{{yield}}");
<add>
<add> expect(_file('tests/integration/pods/x-foo/component-test.js'))
<add> .to.contain("import { moduleForComponent, test } from 'ember-qunit';")
<add> .to.contain("import hbs from 'htmlbars-inline-precompile';")
<add> .to.contain("moduleForComponent('x-foo'")
<add> .to.contain("integration: true")
<add> .to.contain("{{x-foo}}")
<add> .to.contain("{{#x-foo}}");
<add> }));
<ide> });
<ide>
<ide> it('component foo/x-foo --pod -no-path', function() {
<del> return generateAndDestroy(['component', 'foo/x-foo', '--pod', '-no-path'], {
<del> files: [
<del> {
<del> file: 'app/foo/x-foo/component.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "export default Ember.Component.extend({",
<del> "});"
<del> ]
<del> },
<del> {
<del> file: 'app/foo/x-foo/template.hbs',
<del> contains: "{{yield}}"
<del> },
<del> {
<del> file: 'tests/integration/foo/x-foo/component-test.js',
<del> contains: [
<del> "import { moduleForComponent, test } from 'ember-qunit';",
<del> "import hbs from 'htmlbars-inline-precompile';",
<del> "moduleForComponent('foo/x-foo'",
<del> "integration: true",
<del> "{{foo/x-foo}}",
<del> "{{#foo/x-foo}}"
<del> ]
<del> },
<del> ]
<del> });
<add> var args = ['component', 'foo/x-foo', '--pod', '-no-path'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/foo/x-foo/component.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain("export default Ember.Component.extend({")
<add> .to.contain("});");
<add>
<add> expect(_file('app/foo/x-foo/template.hbs'))
<add> .to.contain("{{yield}}");
<add>
<add> expect(_file('tests/integration/foo/x-foo/component-test.js'))
<add> .to.contain("import { moduleForComponent, test } from 'ember-qunit';")
<add> .to.contain("import hbs from 'htmlbars-inline-precompile';")
<add> .to.contain("moduleForComponent('foo/x-foo'")
<add> .to.contain("integration: true")
<add> .to.contain("{{foo/x-foo}}")
<add> .to.contain("{{#foo/x-foo}}");
<add> }));
<ide> });
<ide>
<ide> it('component foo/x-foo --pod -no-path podModulePrefix', function() {
<del> return generateAndDestroy(['component', 'foo/x-foo', '--pod', '-no-path'], {
<del> podModulePrefix: true,
<del> files: [
<del> {
<del> file: 'app/pods/foo/x-foo/component.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "export default Ember.Component.extend({",
<del> "});"
<del> ]
<del> },
<del> {
<del> file: 'app/pods/foo/x-foo/template.hbs',
<del> contains: "{{yield}}"
<del> },
<del> {
<del> file: 'tests/integration/pods/foo/x-foo/component-test.js',
<del> contains: [
<del> "import { moduleForComponent, test } from 'ember-qunit';",
<del> "import hbs from 'htmlbars-inline-precompile';",
<del> "moduleForComponent('foo/x-foo'",
<del> "integration: true",
<del> "{{foo/x-foo}}",
<del> "{{#foo/x-foo}}"
<del> ]
<del> },
<del> ]
<del> });
<add> var args = ['component', 'foo/x-foo', '--pod', '-no-path'];
<add>
<add> return emberNew()
<add> .then(() => setupPodConfig({ podModulePrefix: true }))
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/pods/foo/x-foo/component.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain("export default Ember.Component.extend({")
<add> .to.contain("});");
<add>
<add> expect(_file('app/pods/foo/x-foo/template.hbs'))
<add> .to.contain("{{yield}}");
<add>
<add> expect(_file('tests/integration/pods/foo/x-foo/component-test.js'))
<add> .to.contain("import { moduleForComponent, test } from 'ember-qunit';")
<add> .to.contain("import hbs from 'htmlbars-inline-precompile';")
<add> .to.contain("moduleForComponent('foo/x-foo'")
<add> .to.contain("integration: true")
<add> .to.contain("{{foo/x-foo}}")
<add> .to.contain("{{#foo/x-foo}}");
<add> }));
<ide> });
<ide>
<ide> it('in-addon component x-foo --pod', function() {
<del> return generateAndDestroy(['component', 'x-foo', '--pod'], {
<del> target: 'addon',
<del> files: [
<del> {
<del> file: 'addon/components/x-foo/component.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "import layout from './template';",
<del> "export default Ember.Component.extend({",
<del> "layout",
<del> "});"
<del> ]
<del> },
<del> {
<del> file: 'addon/components/x-foo/template.hbs',
<del> contains: "{{yield}}"
<del> },
<del> {
<del> file: 'app/components/x-foo/component.js',
<del> contains: [
<del> "export { default } from 'my-addon/components/x-foo/component';"
<del> ]
<del> },
<del> {
<del> file: 'tests/integration/components/x-foo/component-test.js',
<del> contains: [
<del> "import { moduleForComponent, test } from 'ember-qunit';",
<del> "moduleForComponent('x-foo'",
<del> "integration: true"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['component', 'x-foo', '--pod'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('addon/components/x-foo/component.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain("import layout from './template';")
<add> .to.contain("export default Ember.Component.extend({")
<add> .to.contain("layout")
<add> .to.contain("});");
<add>
<add> expect(_file('addon/components/x-foo/template.hbs'))
<add> .to.contain("{{yield}}");
<add>
<add> expect(_file('app/components/x-foo/component.js'))
<add> .to.contain("export { default } from 'my-addon/components/x-foo/component';");
<add>
<add> expect(_file('tests/integration/components/x-foo/component-test.js'))
<add> .to.contain("import { moduleForComponent, test } from 'ember-qunit';")
<add> .to.contain("moduleForComponent('x-foo'")
<add> .to.contain("integration: true");
<add> }));
<ide> });
<ide>
<ide> it('in-repo-addon component x-foo --pod', function() {
<del> return generateAndDestroy(['component', 'x-foo', '--in-repo-addon=my-addon', '--pod'], {
<del> target: 'inRepoAddon',
<del> files: [
<del> {
<del> file: 'lib/my-addon/addon/components/x-foo/component.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "import layout from './template';",
<del> "export default Ember.Component.extend({",
<del> "layout",
<del> "});"
<del> ]
<del> },
<del> {
<del> file: 'lib/my-addon/addon/components/x-foo/template.hbs',
<del> contains: "{{yield}}"
<del> },
<del> {
<del> file: 'lib/my-addon/app/components/x-foo/component.js',
<del> contains: [
<del> "export { default } from 'my-addon/components/x-foo/component';"
<del> ]
<del> },
<del> {
<del> file: 'tests/integration/components/x-foo/component-test.js',
<del> contains: [
<del> "import { moduleForComponent, test } from 'ember-qunit';",
<del> "moduleForComponent('x-foo'",
<del> "integration: true"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['component', 'x-foo', '--in-repo-addon=my-addon', '--pod'];
<add>
<add> return emberNew({ target: 'in-repo-addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('lib/my-addon/addon/components/x-foo/component.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain("import layout from './template';")
<add> .to.contain("export default Ember.Component.extend({")
<add> .to.contain("layout")
<add> .to.contain("});");
<add>
<add> expect(_file('lib/my-addon/addon/components/x-foo/template.hbs'))
<add> .to.contain("{{yield}}");
<add>
<add> expect(_file('lib/my-addon/app/components/x-foo/component.js'))
<add> .to.contain("export { default } from 'my-addon/components/x-foo/component';");
<add>
<add> expect(_file('tests/integration/components/x-foo/component-test.js'))
<add> .to.contain("import { moduleForComponent, test } from 'ember-qunit';")
<add> .to.contain("moduleForComponent('x-foo'")
<add> .to.contain("integration: true");
<add> }));
<ide> });
<ide>
<ide> it('in-repo-addon component nested/x-foo', function() {
<del> return generateAndDestroy(['component', 'nested/x-foo', '--in-repo-addon=my-addon', '--pod'], {
<del> target: 'inRepoAddon',
<del> files: [
<del> {
<del> file: 'lib/my-addon/addon/components/nested/x-foo/component.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "import layout from './template';",
<del> "export default Ember.Component.extend({",
<del> "layout",
<del> "});"
<del> ]
<del> },
<del> {
<del> file: 'lib/my-addon/addon/components/nested/x-foo/template.hbs',
<del> contains: "{{yield}}"
<del> },
<del> {
<del> file: 'lib/my-addon/app/components/nested/x-foo/component.js',
<del> contains: [
<del> "export { default } from 'my-addon/components/nested/x-foo/component';"
<del> ]
<del> },
<del> {
<del> file: 'tests/integration/components/nested/x-foo/component-test.js',
<del> contains: [
<del> "import { moduleForComponent, test } from 'ember-qunit';",
<del> "moduleForComponent('nested/x-foo'",
<del> "integration: true"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['component', 'nested/x-foo', '--in-repo-addon=my-addon', '--pod'];
<add>
<add> return emberNew({ target: 'in-repo-addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('lib/my-addon/addon/components/nested/x-foo/component.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain("import layout from './template';")
<add> .to.contain("export default Ember.Component.extend({")
<add> .to.contain("layout")
<add> .to.contain("});");
<add>
<add> expect(_file('lib/my-addon/addon/components/nested/x-foo/template.hbs'))
<add> .to.contain("{{yield}}");
<add>
<add> expect(_file('lib/my-addon/app/components/nested/x-foo/component.js'))
<add> .to.contain("export { default } from 'my-addon/components/nested/x-foo/component';");
<add>
<add> expect(_file('tests/integration/components/nested/x-foo/component-test.js'))
<add> .to.contain("import { moduleForComponent, test } from 'ember-qunit';")
<add> .to.contain("moduleForComponent('nested/x-foo'")
<add> .to.contain("integration: true");
<add> }));
<ide> });
<ide>
<ide> it('component-test x-foo', function() {
<del> return generateAndDestroy(['component-test', 'x-foo'], {
<del> files: [
<del> {
<del> file: 'tests/integration/components/x-foo-test.js',
<del> contains: [
<del> "import { moduleForComponent, test } from 'ember-qunit';",
<del> "import hbs from 'htmlbars-inline-precompile';",
<del> "moduleForComponent('x-foo'",
<del> "integration: true",
<del> "{{x-foo}}",
<del> "{{#x-foo}}"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['component-test', 'x-foo'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/integration/components/x-foo-test.js'))
<add> .to.contain("import { moduleForComponent, test } from 'ember-qunit';")
<add> .to.contain("import hbs from 'htmlbars-inline-precompile';")
<add> .to.contain("moduleForComponent('x-foo'")
<add> .to.contain("integration: true")
<add> .to.contain("{{x-foo}}")
<add> .to.contain("{{#x-foo}}");
<add> }));
<ide> });
<ide>
<ide> it('component-test x-foo --unit', function() {
<del> return generateAndDestroy(['component-test', 'x-foo', '--unit'], {
<del> files: [
<del> {
<del> file: 'tests/unit/components/x-foo-test.js',
<del> contains: [
<del> "import { moduleForComponent, test } from 'ember-qunit';",
<del> "moduleForComponent('x-foo'",
<del> "unit: true"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['component-test', 'x-foo', '--unit'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/unit/components/x-foo-test.js'))
<add> .to.contain("import { moduleForComponent, test } from 'ember-qunit';")
<add> .to.contain("moduleForComponent('x-foo'")
<add> .to.contain("unit: true");
<add> }));
<ide> });
<ide>
<ide> it('in-addon component-test x-foo', function() {
<del> return generateAndDestroy(['component-test', 'x-foo'], {
<del> target: 'addon',
<del> files: [
<del> {
<del> file:'tests/integration/components/x-foo-test.js',
<del> contains: [
<del> "import { moduleForComponent, test } from 'ember-qunit';",
<del> "import hbs from 'htmlbars-inline-precompile';",
<del> "moduleForComponent('x-foo'",
<del> "integration: true",
<del> "{{x-foo}}",
<del> "{{#x-foo}}"
<del> ]
<del> },
<del> {
<del> file: 'app/component-test/x-foo.js',
<del> exists: false
<del> }
<del> ]
<del> });
<add> var args = ['component-test', 'x-foo'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/integration/components/x-foo-test.js'))
<add> .to.contain("import { moduleForComponent, test } from 'ember-qunit';")
<add> .to.contain("import hbs from 'htmlbars-inline-precompile';")
<add> .to.contain("moduleForComponent('x-foo'")
<add> .to.contain("integration: true")
<add> .to.contain("{{x-foo}}")
<add> .to.contain("{{#x-foo}}");
<add>
<add> expect(_file('app/component-test/x-foo.js'))
<add> .to.not.exist;
<add> }));
<ide> });
<ide>
<ide> it('in-addon component-test x-foo --unit', function() {
<del> return generateAndDestroy(['component-test', 'x-foo', '--unit'], {
<del> target: 'addon',
<del> files: [
<del> {
<del> file:'tests/unit/components/x-foo-test.js',
<del> contains: [
<del> "import { moduleForComponent, test } from 'ember-qunit';",
<del> "moduleForComponent('x-foo'",
<del> "unit: true"
<del> ]
<del> },
<del> {
<del> file: 'app/component-test/x-foo.js',
<del> exists: false
<del> }
<del> ]
<del> });
<add> var args = ['component-test', 'x-foo', '--unit'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/unit/components/x-foo-test.js'))
<add> .to.contain("import { moduleForComponent, test } from 'ember-qunit';")
<add> .to.contain("moduleForComponent('x-foo'")
<add> .to.contain("unit: true");
<add>
<add> expect(_file('app/component-test/x-foo.js'))
<add> .to.not.exist;
<add> }));
<ide> });
<ide>
<ide> it('dummy component-test x-foo', function() {
<del> return generateAndDestroy(['component-test', 'x-foo', '--dummy'], {
<del> target: 'addon',
<del> files: [
<del> {
<del> file: 'tests/integration/components/x-foo-test.js',
<del> contains: [
<del> "import { moduleForComponent, test } from 'ember-qunit';",
<del> "import hbs from 'htmlbars-inline-precompile';",
<del> "moduleForComponent('x-foo'"
<del> ]
<del> },
<del> {
<del> file: 'app/component-test/x-foo.js',
<del> exists: false
<del> }
<del> ]
<del> });
<add> var args = ['component-test', 'x-foo', '--dummy'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/integration/components/x-foo-test.js'))
<add> .to.contain("import { moduleForComponent, test } from 'ember-qunit';")
<add> .to.contain("import hbs from 'htmlbars-inline-precompile';")
<add> .to.contain("moduleForComponent('x-foo'");
<add>
<add> expect(_file('app/component-test/x-foo.js'))
<add> .to.not.exist;
<add> }));
<ide> });
<ide>
<ide> it('component-test x-foo for mocha', function() {
<del> return generateAndDestroy(['component-test', 'x-foo'], {
<del> packages: [
<del> { name: 'ember-cli-qunit', delete: true },
<del> { name: 'ember-cli-mocha', dev: true }
<del> ],
<del> files: [
<del> {
<del> file: 'tests/integration/components/x-foo-test.js',
<del> contains: [
<del> "import { describeComponent, it } from 'ember-mocha';",
<del> "import hbs from 'htmlbars-inline-precompile';",
<del> "describeComponent('x-foo', 'Integration | Component | x foo'",
<del> "integration: true",
<del> "{{x-foo}}",
<del> "{{#x-foo}}"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['component-test', 'x-foo'];
<add>
<add> return emberNew()
<add> .then(() => modifyPackages([
<add> {name: 'ember-cli-qunit', delete: true},
<add> {name: 'ember-cli-mocha', dev: true}
<add> ]))
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/integration/components/x-foo-test.js'))
<add> .to.contain("import { describeComponent, it } from 'ember-mocha';")
<add> .to.contain("import hbs from 'htmlbars-inline-precompile';")
<add> .to.contain("describeComponent('x-foo', 'Integration | Component | x foo'")
<add> .to.contain("integration: true")
<add> .to.contain("{{x-foo}}")
<add> .to.contain("{{#x-foo}}");
<add> }));
<ide> });
<ide>
<ide> it('component-test x-foo --unit for mocha', function() {
<del> return generateAndDestroy(['component-test', 'x-foo', '--unit'], {
<del> packages: [
<del> { name: 'ember-cli-qunit', delete: true },
<del> { name: 'ember-cli-mocha', dev: true }
<del> ],
<del> files: [
<del> {
<del> file: 'tests/unit/components/x-foo-test.js',
<del> contains: [
<del> "import { describeComponent, it } from 'ember-mocha';",
<del> "describeComponent('x-foo', 'Unit | Component | x foo",
<del> "unit: true"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['component-test', 'x-foo', '--unit'];
<add>
<add> return emberNew()
<add> .then(() => modifyPackages([
<add> {name: 'ember-cli-qunit', delete: true},
<add> {name: 'ember-cli-mocha', dev: true}
<add> ]))
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/unit/components/x-foo-test.js'))
<add> .to.contain("import { describeComponent, it } from 'ember-mocha';")
<add> .to.contain("describeComponent('x-foo', 'Unit | Component | x foo")
<add> .to.contain("unit: true");
<add> }));
<ide> });
<ide> });
<ide><path>node-tests/blueprints/controller-test.js
<ide> 'use strict';
<ide>
<del>var setupTestHooks = require('ember-cli-blueprint-test-helpers/lib/helpers/setup');
<del>var BlueprintHelpers = require('ember-cli-blueprint-test-helpers/lib/helpers/blueprint-helper');
<del>var generateAndDestroy = BlueprintHelpers.generateAndDestroy;
<add>var blueprintHelpers = require('ember-cli-blueprint-test-helpers/helpers');
<add>var setupTestHooks = blueprintHelpers.setupTestHooks;
<add>var emberNew = blueprintHelpers.emberNew;
<add>var emberGenerateDestroy = blueprintHelpers.emberGenerateDestroy;
<add>var modifyPackages = blueprintHelpers.modifyPackages;
<add>var setupPodConfig = blueprintHelpers.setupPodConfig;
<add>
<add>var chai = require('ember-cli-blueprint-test-helpers/chai');
<add>var expect = chai.expect;
<ide>
<ide> describe('Acceptance: ember generate and destroy controller', function() {
<ide> setupTestHooks(this);
<ide>
<ide> it('controller foo', function() {
<del> return generateAndDestroy(['controller', 'foo'], {
<del> files: [
<del> {
<del> file: 'app/controllers/foo.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "export default Ember.Controller.extend({\n});"
<del> ]
<del> },
<del> {
<del> file: 'tests/unit/controllers/foo-test.js',
<del> contains: [
<del> "import { moduleFor, test } from 'ember-qunit';",
<del> "moduleFor('controller:foo'"
<del> ]
<del> },
<del> ]
<del> });
<add> var args = ['controller', 'foo'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/controllers/foo.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain("export default Ember.Controller.extend({\n});");
<add>
<add> expect(_file('tests/unit/controllers/foo-test.js'))
<add> .to.contain("import { moduleFor, test } from 'ember-qunit';")
<add> .to.contain("moduleFor('controller:foo'");
<add> }));
<ide> });
<ide>
<ide> it('controller foo/bar', function() {
<del> return generateAndDestroy(['controller', 'foo/bar'], {
<del> files: [
<del> {
<del> file: 'app/controllers/foo/bar.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "export default Ember.Controller.extend({\n});"
<del> ]
<del> },
<del> {
<del> file: 'tests/unit/controllers/foo/bar-test.js',
<del> contains: [
<del> "import { moduleFor, test } from 'ember-qunit';",
<del> "moduleFor('controller:foo/bar'"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['controller', 'foo/bar'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/controllers/foo/bar.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain("export default Ember.Controller.extend({\n});");
<add>
<add> expect(_file('tests/unit/controllers/foo/bar-test.js'))
<add> .to.contain("import { moduleFor, test } from 'ember-qunit';")
<add> .to.contain("moduleFor('controller:foo/bar'");
<add> }));
<ide> });
<ide>
<ide> it('in-addon controller foo', function() {
<del> return generateAndDestroy(['controller', 'foo'], {
<del> target: 'addon',
<del> files: [
<del> {
<del> file: 'addon/controllers/foo.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "export default Ember.Controller.extend({\n});"
<del> ]
<del> },
<del> {
<del> file: 'app/controllers/foo.js',
<del> contains: [
<del> "export { default } from 'my-addon/controllers/foo';"
<del> ]
<del> },
<del> {
<del> file: 'tests/unit/controllers/foo-test.js',
<del> contains: [
<del> "import { moduleFor, test } from 'ember-qunit';",
<del> "moduleFor('controller:foo'"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['controller', 'foo'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('addon/controllers/foo.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain("export default Ember.Controller.extend({\n});");
<add>
<add> expect(_file('app/controllers/foo.js'))
<add> .to.contain("export { default } from 'my-addon/controllers/foo';");
<add>
<add> expect(_file('tests/unit/controllers/foo-test.js'))
<add> .to.contain("import { moduleFor, test } from 'ember-qunit';")
<add> .to.contain("moduleFor('controller:foo'");
<add> }));
<ide> });
<ide>
<ide> it('in-addon controller foo/bar', function() {
<del> return generateAndDestroy(['controller', 'foo/bar'], {
<del> target: 'addon',
<del> files: [
<del> {
<del> file: 'addon/controllers/foo/bar.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "export default Ember.Controller.extend({\n});"
<del> ]
<del> },
<del> {
<del> file: 'app/controllers/foo/bar.js',
<del> contains: [
<del> "export { default } from 'my-addon/controllers/foo/bar';"
<del> ]
<del> },
<del> {
<del> file: 'tests/unit/controllers/foo/bar-test.js',
<del> contains: [
<del> "import { moduleFor, test } from 'ember-qunit';",
<del> "moduleFor('controller:foo/bar'"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['controller', 'foo/bar'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('addon/controllers/foo/bar.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain("export default Ember.Controller.extend({\n});");
<add>
<add> expect(_file('app/controllers/foo/bar.js'))
<add> .to.contain("export { default } from 'my-addon/controllers/foo/bar';");
<add>
<add> expect(_file('tests/unit/controllers/foo/bar-test.js'))
<add> .to.contain("import { moduleFor, test } from 'ember-qunit';")
<add> .to.contain("moduleFor('controller:foo/bar'");
<add> }));
<ide> });
<ide>
<ide> it('dummy controller foo', function() {
<del> return generateAndDestroy(['controller', 'foo', '--dummy'], {
<del> target: 'addon',
<del> files: [
<del> {
<del> file: 'tests/dummy/app/controllers/foo.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "export default Ember.Controller.extend({\n});"
<del> ]
<del> },
<del> {
<del> file: 'app/controllers/foo-test.js',
<del> exists: false
<del> },
<del> {
<del> file: 'tests/unit/controllers/foo-test.js',
<del> exists: false
<del> }
<del> ]
<del> });
<add> var args = ['controller', 'foo', '--dummy'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/dummy/app/controllers/foo.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain("export default Ember.Controller.extend({\n});");
<add>
<add> expect(_file('app/controllers/foo-test.js'))
<add> .to.not.exist;
<add>
<add> expect(_file('tests/unit/controllers/foo-test.js'))
<add> .to.not.exist;
<add> }));
<ide> });
<ide>
<ide> it('dummy controller foo/bar', function() {
<del> return generateAndDestroy(['controller', 'foo/bar', '--dummy'], {
<del> target: 'addon',
<del> files: [
<del> {
<del> file: 'tests/dummy/app/controllers/foo/bar.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "export default Ember.Controller.extend({\n});"
<del> ]
<del> },
<del> {
<del> file: 'app/controllers/foo/bar.js',
<del> exists: false
<del> },
<del> {
<del> file: 'tests/unit/controllers/foo/bar-test.js',
<del> exists: false
<del> }
<del> ]
<del> });
<add> var args = ['controller', 'foo/bar', '--dummy'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/dummy/app/controllers/foo/bar.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain("export default Ember.Controller.extend({\n});");
<add>
<add> expect(_file('app/controllers/foo/bar.js'))
<add> .to.not.exist;
<add>
<add> expect(_file('tests/unit/controllers/foo/bar-test.js'))
<add> .to.not.exist;
<add> }));
<ide> });
<ide>
<ide> it('in-repo-addon controller foo', function() {
<del> return generateAndDestroy(['controller', 'foo', '--in-repo-addon=my-addon'], {
<del> target: 'inRepoAddon',
<del> files: [
<del> {
<del> file: 'lib/my-addon/addon/controllers/foo.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "export default Ember.Controller.extend({\n});"
<del> ]
<del> },
<del> {
<del> file: 'lib/my-addon/app/controllers/foo.js',
<del> contains: [
<del> "export { default } from 'my-addon/controllers/foo';"
<del> ]
<del> },
<del> {
<del> file: 'tests/unit/controllers/foo-test.js',
<del> contains: [
<del> "import { moduleFor, test } from 'ember-qunit';",
<del> "moduleFor('controller:foo'"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['controller', 'foo', '--in-repo-addon=my-addon'];
<add>
<add> return emberNew({ target: 'in-repo-addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('lib/my-addon/addon/controllers/foo.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain("export default Ember.Controller.extend({\n});");
<add>
<add> expect(_file('lib/my-addon/app/controllers/foo.js'))
<add> .to.contain("export { default } from 'my-addon/controllers/foo';");
<add>
<add> expect(_file('tests/unit/controllers/foo-test.js'))
<add> .to.contain("import { moduleFor, test } from 'ember-qunit';")
<add> .to.contain("moduleFor('controller:foo'");
<add> }));
<ide> });
<ide>
<ide> it('in-repo-addon controller foo/bar', function() {
<del> return generateAndDestroy(['controller', 'foo/bar', '--in-repo-addon=my-addon'], {
<del> target: 'inRepoAddon',
<del> files: [
<del> {
<del> file: 'lib/my-addon/addon/controllers/foo/bar.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "export default Ember.Controller.extend({\n});"
<del> ]
<del> },
<del> {
<del> file: 'lib/my-addon/app/controllers/foo/bar.js',
<del> contains: [
<del> "export { default } from 'my-addon/controllers/foo/bar';"
<del> ]
<del> },
<del> {
<del> file: 'tests/unit/controllers/foo/bar-test.js',
<del> contains: [
<del> "import { moduleFor, test } from 'ember-qunit';",
<del> "moduleFor('controller:foo/bar'"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['controller', 'foo/bar', '--in-repo-addon=my-addon'];
<add>
<add> return emberNew({ target: 'in-repo-addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('lib/my-addon/addon/controllers/foo/bar.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain("export default Ember.Controller.extend({\n});");
<add>
<add> expect(_file('lib/my-addon/app/controllers/foo/bar.js'))
<add> .to.contain("export { default } from 'my-addon/controllers/foo/bar';");
<add>
<add> expect(_file('tests/unit/controllers/foo/bar-test.js'))
<add> .to.contain("import { moduleFor, test } from 'ember-qunit';")
<add> .to.contain("moduleFor('controller:foo/bar'");
<add> }));
<ide> });
<ide>
<del>/**
<del>* Pod tests
<del>*
<del>*/
<ide> it('controller foo --pod', function() {
<del> return generateAndDestroy(['controller', 'foo', '--pod'], {
<del> files: [
<del> {
<del> file: 'app/foo/controller.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "export default Ember.Controller.extend({\n});"
<del> ]
<del> },
<del> {
<del> file: 'tests/unit/foo/controller-test.js',
<del> contains: [
<del> "import { moduleFor, test } from 'ember-qunit';",
<del> "moduleFor('controller:foo'"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['controller', 'foo', '--pod'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/foo/controller.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain("export default Ember.Controller.extend({\n});");
<add>
<add> expect(_file('tests/unit/foo/controller-test.js'))
<add> .to.contain("import { moduleFor, test } from 'ember-qunit';")
<add> .to.contain("moduleFor('controller:foo'");
<add> }));
<ide> });
<ide>
<ide> it('controller foo --pod podModulePrefix', function() {
<del> return generateAndDestroy(['controller', 'foo', '--pod'], {
<del> podModulePrefix: true,
<del> files: [
<del> {
<del> file: 'app/pods/foo/controller.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "export default Ember.Controller.extend({\n});"
<del> ]
<del> },
<del> {
<del> file: 'tests/unit/pods/foo/controller-test.js',
<del> contains: [
<del> "import { moduleFor, test } from 'ember-qunit';",
<del> "moduleFor('controller:foo'"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['controller', 'foo', '--pod'];
<add>
<add> return emberNew()
<add> .then(() => setupPodConfig({ podModulePrefix: true }))
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/pods/foo/controller.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain("export default Ember.Controller.extend({\n});");
<add>
<add> expect(_file('tests/unit/pods/foo/controller-test.js'))
<add> .to.contain("import { moduleFor, test } from 'ember-qunit';")
<add> .to.contain("moduleFor('controller:foo'");
<add> }));
<ide> });
<ide>
<ide> it('controller foo/bar --pod', function() {
<del> return generateAndDestroy(['controller', 'foo/bar', '--pod'], {
<del> files: [
<del> {
<del> file: 'app/foo/bar/controller.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "export default Ember.Controller.extend({\n});"
<del> ]
<del> },
<del> {
<del> file: 'tests/unit/foo/bar/controller-test.js',
<del> contains: [
<del> "import { moduleFor, test } from 'ember-qunit';",
<del> "moduleFor('controller:foo/bar'"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['controller', 'foo/bar', '--pod'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/foo/bar/controller.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain("export default Ember.Controller.extend({\n});");
<add>
<add> expect(_file('tests/unit/foo/bar/controller-test.js'))
<add> .to.contain("import { moduleFor, test } from 'ember-qunit';")
<add> .to.contain("moduleFor('controller:foo/bar'");
<add> }));
<ide> });
<ide>
<ide> it('controller foo/bar --pod podModulePrefix', function() {
<del> return generateAndDestroy(['controller', 'foo/bar', '--pod'], {
<del> podModulePrefix: true,
<del> files: [
<del> {
<del> file: 'app/pods/foo/bar/controller.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "export default Ember.Controller.extend({\n});"
<del> ]
<del> },
<del> {
<del> file: 'tests/unit/pods/foo/bar/controller-test.js',
<del> contains: [
<del> "import { moduleFor, test } from 'ember-qunit';",
<del> "moduleFor('controller:foo/bar'"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['controller', 'foo/bar', '--pod'];
<add>
<add> return emberNew()
<add> .then(() => setupPodConfig({ podModulePrefix: true }))
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/pods/foo/bar/controller.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain("export default Ember.Controller.extend({\n});");
<add>
<add> expect(_file('tests/unit/pods/foo/bar/controller-test.js'))
<add> .to.contain("import { moduleFor, test } from 'ember-qunit';")
<add> .to.contain("moduleFor('controller:foo/bar'");
<add> }));
<ide> });
<ide>
<ide> it('controller-test foo', function() {
<del> return generateAndDestroy(['controller-test', 'foo'], {
<del> files: [
<del> {
<del> file: 'tests/unit/controllers/foo-test.js',
<del> contains: [
<del> "import { moduleFor, test } from 'ember-qunit';",
<del> "moduleFor('controller:foo'"
<del> ]
<del> },
<del> ]
<del> });
<add> var args = ['controller-test', 'foo'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/unit/controllers/foo-test.js'))
<add> .to.contain("import { moduleFor, test } from 'ember-qunit';")
<add> .to.contain("moduleFor('controller:foo'");
<add> }));
<ide> });
<ide>
<ide> it('in-addon controller-test foo', function() {
<del> return generateAndDestroy(['controller-test', 'foo'], {
<del> target: 'addon',
<del> files: [
<del> {
<del> file: 'tests/unit/controllers/foo-test.js',
<del> contains: [
<del> "import { moduleFor, test } from 'ember-qunit';",
<del> "moduleFor('controller:foo'"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['controller-test', 'foo'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/unit/controllers/foo-test.js'))
<add> .to.contain("import { moduleFor, test } from 'ember-qunit';")
<add> .to.contain("moduleFor('controller:foo'");
<add> }));
<ide> });
<ide>
<ide> it('controller-test foo for mocha', function() {
<del> return generateAndDestroy(['controller-test', 'foo'], {
<del> packages: [
<del> { name: 'ember-cli-qunit', delete: true },
<del> { name: 'ember-cli-mocha', dev: true }
<del> ],
<del> files: [
<del> {
<del> file: 'tests/unit/controllers/foo-test.js',
<del> contains: [
<del> "import { describeModule, it } from 'ember-mocha';",
<del> "describeModule('controller:foo', 'Unit | Controller | foo'"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['controller-test', 'foo'];
<add>
<add> return emberNew()
<add> .then(() => modifyPackages([
<add> {name: 'ember-cli-qunit', delete: true},
<add> {name: 'ember-cli-mocha', dev: true}
<add> ]))
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/unit/controllers/foo-test.js'))
<add> .to.contain("import { describeModule, it } from 'ember-mocha';")
<add> .to.contain("describeModule('controller:foo', 'Unit | Controller | foo'");
<add> }));
<ide> });
<ide> });
<ide><path>node-tests/blueprints/helper-addon-test.js
<ide> 'use strict';
<ide>
<del>var setupTestHooks = require('ember-cli-blueprint-test-helpers/lib/helpers/setup');
<del>var BlueprintHelpers = require('ember-cli-blueprint-test-helpers/lib/helpers/blueprint-helper');
<del>var generateAndDestroy = BlueprintHelpers.generateAndDestroy;
<add>var blueprintHelpers = require('ember-cli-blueprint-test-helpers/helpers');
<add>var setupTestHooks = blueprintHelpers.setupTestHooks;
<add>var emberNew = blueprintHelpers.emberNew;
<add>var emberGenerateDestroy = blueprintHelpers.emberGenerateDestroy;
<add>
<add>var chai = require('ember-cli-blueprint-test-helpers/chai');
<add>var expect = chai.expect;
<ide>
<ide> describe('Acceptance: ember generate and destroy helper-addon', function() {
<ide> setupTestHooks(this);
<ide>
<ide> it('in-addon helper-addon foo-bar', function() {
<del> return generateAndDestroy(['helper-addon', 'foo-bar'], {
<del> target: 'addon',
<del> files: [
<del> {
<del> file: 'app/helpers/foo-bar.js',
<del> contains: [
<del> "export { default, fooBar } from 'my-addon/helpers/foo-bar';"
<del> ]
<del> },
<del> ]
<del> });
<del> });
<add> var args = ['helper-addon', 'foo-bar'];
<ide>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/helpers/foo-bar.js'))
<add> .to.contain("export { default, fooBar } from 'my-addon/helpers/foo-bar';");
<add> }));
<add> });
<ide> });
<ide><path>node-tests/blueprints/helper-test.js
<ide> 'use strict';
<ide>
<del>var setupTestHooks = require('ember-cli-blueprint-test-helpers/lib/helpers/setup');
<del>var BlueprintHelpers = require('ember-cli-blueprint-test-helpers/lib/helpers/blueprint-helper');
<del>var generateAndDestroy = BlueprintHelpers.generateAndDestroy;
<add>var blueprintHelpers = require('ember-cli-blueprint-test-helpers/helpers');
<add>var setupTestHooks = blueprintHelpers.setupTestHooks;
<add>var emberNew = blueprintHelpers.emberNew;
<add>var emberGenerateDestroy = blueprintHelpers.emberGenerateDestroy;
<add>var modifyPackages = blueprintHelpers.modifyPackages;
<add>var setupPodConfig = blueprintHelpers.setupPodConfig;
<add>
<add>var chai = require('ember-cli-blueprint-test-helpers/chai');
<add>var expect = chai.expect;
<ide>
<ide> describe('Acceptance: ember generate and destroy helper', function() {
<ide> setupTestHooks(this);
<ide>
<ide> it('helper foo/bar-baz', function() {
<del> return generateAndDestroy(['helper', 'foo/bar-baz'], {
<del> files: [
<del> {
<del> file: 'app/helpers/foo/bar-baz.js',
<del> contains: "import Ember from 'ember';\n\n" +
<del> "export function fooBarBaz(params/*, hash*/) {\n" +
<del> " return params;\n" +
<del> "}\n\n" +
<del> "export default Ember.Helper.helper(fooBarBaz);"
<del> },
<del> {
<del> file: 'tests/unit/helpers/foo/bar-baz-test.js',
<del> contains: "import { fooBarBaz } from 'my-app/helpers/foo/bar-baz';"
<del> }
<del> ]
<del> });
<add> var args = ['helper', 'foo/bar-baz'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/helpers/foo/bar-baz.js'))
<add> .to.contain("import Ember from 'ember';\n\n" +
<add> "export function fooBarBaz(params/*, hash*/) {\n" +
<add> " return params;\n" +
<add> "}\n\n" +
<add> "export default Ember.Helper.helper(fooBarBaz);");
<add>
<add> expect(_file('tests/unit/helpers/foo/bar-baz-test.js'))
<add> .to.contain("import { fooBarBaz } from 'my-app/helpers/foo/bar-baz';");
<add> }));
<ide> });
<ide>
<ide> it('in-addon helper foo-bar', function() {
<del> return generateAndDestroy(['helper', 'foo-bar'], {
<del> target: 'addon',
<del> files: [
<del> {
<del> file: 'addon/helpers/foo-bar.js',
<del> contains: "import Ember from 'ember';\n\n" +
<del> "export function fooBar(params/*, hash*/) {\n" +
<del> " return params;\n" +
<del> "}\n\n" +
<del> "export default Ember.Helper.helper(fooBar);"
<del> },
<del> {
<del> file: 'app/helpers/foo-bar.js',
<del> contains: [
<del> "export { default, fooBar } from 'my-addon/helpers/foo-bar';"
<del> ]
<del> },
<del> {
<del> file: 'tests/unit/helpers/foo-bar-test.js',
<del> contains: "import { fooBar } from 'dummy/helpers/foo-bar';"
<del> }
<del> ]
<del> });
<add> var args = ['helper', 'foo-bar'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('addon/helpers/foo-bar.js'))
<add> .to.contain("import Ember from 'ember';\n\n" +
<add> "export function fooBar(params/*, hash*/) {\n" +
<add> " return params;\n" +
<add> "}\n\n" +
<add> "export default Ember.Helper.helper(fooBar);");
<add>
<add> expect(_file('app/helpers/foo-bar.js'))
<add> .to.contain("export { default, fooBar } from 'my-addon/helpers/foo-bar';");
<add> expect(_file('tests/unit/helpers/foo-bar-test.js'))
<add> .to.contain("import { fooBar } from 'dummy/helpers/foo-bar';");
<add> }));
<ide> });
<ide>
<ide> it('in-addon helper foo/bar-baz', function() {
<del> return generateAndDestroy(['helper', 'foo/bar-baz'], {
<del> target: 'addon',
<del> files: [
<del> {
<del> file: 'addon/helpers/foo/bar-baz.js',
<del> contains: "import Ember from 'ember';\n\n" +
<del> "export function fooBarBaz(params/*, hash*/) {\n" +
<del> " return params;\n" +
<del> "}\n\n" +
<del> "export default Ember.Helper.helper(fooBarBaz);"
<del> },
<del> {
<del> file: 'app/helpers/foo/bar-baz.js',
<del> contains: [
<del> "export { default, fooBarBaz } from 'my-addon/helpers/foo/bar-baz';"
<del> ]
<del> },
<del> {
<del> file: 'tests/unit/helpers/foo/bar-baz-test.js',
<del> contains: "import { fooBarBaz } from 'dummy/helpers/foo/bar-baz';"
<del> }
<del> ]
<del> });
<add> var args = ['helper', 'foo/bar-baz'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('addon/helpers/foo/bar-baz.js'))
<add> .to.contain("import Ember from 'ember';\n\n" +
<add> "export function fooBarBaz(params/*, hash*/) {\n" +
<add> " return params;\n" +
<add> "}\n\n" +
<add> "export default Ember.Helper.helper(fooBarBaz);");
<add>
<add> expect(_file('app/helpers/foo/bar-baz.js'))
<add> .to.contain("export { default, fooBarBaz } from 'my-addon/helpers/foo/bar-baz';");
<add> expect(_file('tests/unit/helpers/foo/bar-baz-test.js'))
<add> .to.contain("import { fooBarBaz } from 'dummy/helpers/foo/bar-baz';");
<add> }));
<ide> });
<ide>
<ide> it('dummy helper foo-bar', function() {
<del> return generateAndDestroy(['helper', 'foo-bar', '--dummy'], {
<del> target: 'addon',
<del> files: [
<del> {
<del> file: 'tests/dummy/app/helpers/foo-bar.js',
<del> contains: "import Ember from 'ember';\n\n" +
<del> "export function fooBar(params/*, hash*/) {\n" +
<del> " return params;\n" +
<del> "}\n\n" +
<del> "export default Ember.Helper.helper(fooBar);"
<del> },
<del> {
<del> file: 'app/helpers/foo-bar.js',
<del> exists: false
<del> },
<del> {
<del> file: 'tests/unit/helpers/foo-bar-test.js',
<del> exists: false
<del> }
<del> ]
<del> });
<add> var args = ['helper', 'foo-bar', '--dummy'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/dummy/app/helpers/foo-bar.js'))
<add> .to.contain("import Ember from 'ember';\n\n" +
<add> "export function fooBar(params/*, hash*/) {\n" +
<add> " return params;\n" +
<add> "}\n\n" +
<add> "export default Ember.Helper.helper(fooBar);");
<add>
<add> expect(_file('app/helpers/foo-bar.js'))
<add> .to.not.exist;
<add> expect(_file('tests/unit/helpers/foo-bar-test.js'))
<add> .to.not.exist;
<add> }));
<ide> });
<ide>
<ide> it('dummy helper foo/bar-baz', function() {
<del> return generateAndDestroy(['helper', 'foo/bar-baz', '--dummy'], {
<del> target: 'addon',
<del> files: [
<del> {
<del> file: 'tests/dummy/app/helpers/foo/bar-baz.js',
<del> contains: "import Ember from 'ember';\n\n" +
<del> "export function fooBarBaz(params/*, hash*/) {\n" +
<del> " return params;\n" +
<del> "}\n\n" +
<del> "export default Ember.Helper.helper(fooBarBaz);"
<del> },
<del> {
<del> file: 'app/helpers/foo/bar-baz.js',
<del> exists: false
<del> },
<del> {
<del> file: 'tests/unit/helpers/foo/bar-baz-test.js',
<del> exists: false
<del> }
<del> ]
<del> });
<add> var args = ['helper', 'foo/bar-baz', '--dummy'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/dummy/app/helpers/foo/bar-baz.js'))
<add> .to.contain("import Ember from 'ember';\n\n" +
<add> "export function fooBarBaz(params/*, hash*/) {\n" +
<add> " return params;\n" +
<add> "}\n\n" +
<add> "export default Ember.Helper.helper(fooBarBaz);");
<add>
<add> expect(_file('app/helpers/foo/bar-baz.js'))
<add> .to.not.exist;
<add> expect(_file('tests/unit/helpers/foo/bar-baz-test.js'))
<add> .to.not.exist;
<add> }));
<ide> });
<ide>
<ide> it('in-repo-addon helper foo-bar', function() {
<del> return generateAndDestroy(['helper', 'foo-bar', '--in-repo-addon=my-addon'], {
<del> target: 'inRepoAddon',
<del> files: [
<del> {
<del> file: 'lib/my-addon/addon/helpers/foo-bar.js',
<del> contains: "import Ember from 'ember';\n\n" +
<del> "export function fooBar(params/*, hash*/) {\n" +
<del> " return params;\n" +
<del> "}\n\n" +
<del> "export default Ember.Helper.helper(fooBar);"
<del> },
<del> {
<del> file: 'lib/my-addon/app/helpers/foo-bar.js',
<del> contains: [
<del> "export { default, fooBar } from 'my-addon/helpers/foo-bar';"
<del> ]
<del> },
<del> {
<del> file: 'tests/unit/helpers/foo-bar-test.js',
<del> contains: "import { fooBar } from 'my-app/helpers/foo-bar';"
<del> }
<del> ]
<del> });
<add> var args = ['helper', 'foo-bar', '--in-repo-addon=my-addon'];
<add>
<add> return emberNew({ target: 'in-repo-addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('lib/my-addon/addon/helpers/foo-bar.js'))
<add> .to.contain("import Ember from 'ember';\n\n" +
<add> "export function fooBar(params/*, hash*/) {\n" +
<add> " return params;\n" +
<add> "}\n\n" +
<add> "export default Ember.Helper.helper(fooBar);");
<add>
<add> expect(_file('lib/my-addon/app/helpers/foo-bar.js'))
<add> .to.contain("export { default, fooBar } from 'my-addon/helpers/foo-bar';");
<add> expect(_file('tests/unit/helpers/foo-bar-test.js'))
<add> .to.contain("import { fooBar } from 'my-app/helpers/foo-bar';");
<add> }));
<ide> });
<ide>
<ide> it('in-repo-addon helper foo/bar-baz', function() {
<del> return generateAndDestroy(['helper', 'foo/bar-baz', '--in-repo-addon=my-addon'], {
<del> target: 'inRepoAddon',
<del> files: [
<del> {
<del> file: 'lib/my-addon/addon/helpers/foo/bar-baz.js',
<del> contains: "import Ember from 'ember';\n\n" +
<del> "export function fooBarBaz(params/*, hash*/) {\n" +
<del> " return params;\n" +
<del> "}\n\n" +
<del> "export default Ember.Helper.helper(fooBarBaz);"
<del> },
<del> {
<del> file: 'lib/my-addon/app/helpers/foo/bar-baz.js',
<del> contains: [
<del> "export { default, fooBarBaz } from 'my-addon/helpers/foo/bar-baz';"
<del> ]
<del> },
<del> {
<del> file: 'tests/unit/helpers/foo/bar-baz-test.js',
<del> contains: "import { fooBarBaz } from 'my-app/helpers/foo/bar-baz';"
<del> }
<del> ]
<del> });
<add> var args = ['helper', 'foo/bar-baz', '--in-repo-addon=my-addon'];
<add>
<add> return emberNew({ target: 'in-repo-addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('lib/my-addon/addon/helpers/foo/bar-baz.js'))
<add> .to.contain("import Ember from 'ember';\n\n" +
<add> "export function fooBarBaz(params/*, hash*/) {\n" +
<add> " return params;\n" +
<add> "}\n\n" +
<add> "export default Ember.Helper.helper(fooBarBaz);");
<add>
<add> expect(_file('lib/my-addon/app/helpers/foo/bar-baz.js'))
<add> .to.contain("export { default, fooBarBaz } from 'my-addon/helpers/foo/bar-baz';");
<add> expect(_file('tests/unit/helpers/foo/bar-baz-test.js'))
<add> .to.contain("import { fooBarBaz } from 'my-app/helpers/foo/bar-baz';");
<add> }));
<ide> });
<ide>
<del>/**
<del>* Pod tests
<del>*
<del>*/
<ide> it('helper foo-bar --pod', function() {
<del> return generateAndDestroy(['helper', 'foo-bar', '--pod'], {
<del> files: [
<del> {
<del> file: 'app/helpers/foo-bar.js',
<del> contains: "import Ember from 'ember';\n\n" +
<del> "export function fooBar(params/*, hash*/) {\n" +
<del> " return params;\n" +
<del> "}\n\n" +
<del> "export default Ember.Helper.helper(fooBar);"
<del> },
<del> {
<del> file: 'tests/unit/helpers/foo-bar-test.js',
<del> contains: "import { fooBar } from 'my-app/helpers/foo-bar';"
<del> }
<del> ]
<del> });
<add> var args = ['helper', 'foo-bar', '--pod'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/helpers/foo-bar.js'))
<add> .to.contain("import Ember from 'ember';\n\n" +
<add> "export function fooBar(params/*, hash*/) {\n" +
<add> " return params;\n" +
<add> "}\n\n" +
<add> "export default Ember.Helper.helper(fooBar);");
<add>
<add> expect(_file('tests/unit/helpers/foo-bar-test.js'))
<add> .to.contain("import { fooBar } from 'my-app/helpers/foo-bar';");
<add> }));
<ide> });
<ide>
<ide> it('helper foo-bar --pod podModulePrefix', function() {
<del> return generateAndDestroy(['helper', 'foo-bar', '--pod'], {
<del> podModulePrefix: true,
<del> files: [
<del> {
<del> file: 'app/helpers/foo-bar.js',
<del> contains: "import Ember from 'ember';\n\n" +
<del> "export function fooBar(params/*, hash*/) {\n" +
<del> " return params;\n" +
<del> "}\n\n" +
<del> "export default Ember.Helper.helper(fooBar);"
<del> },
<del> {
<del> file: 'tests/unit/helpers/foo-bar-test.js',
<del> contains: "import { fooBar } from 'my-app/helpers/foo-bar';"
<del> }
<del> ]
<del> });
<add> var args = ['helper', 'foo-bar', '--pod'];
<add>
<add> return emberNew()
<add> .then(() => setupPodConfig({ podModulePrefix: true }))
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/helpers/foo-bar.js'))
<add> .to.contain("import Ember from 'ember';\n\n" +
<add> "export function fooBar(params/*, hash*/) {\n" +
<add> " return params;\n" +
<add> "}\n\n" +
<add> "export default Ember.Helper.helper(fooBar);");
<add>
<add> expect(_file('tests/unit/helpers/foo-bar-test.js'))
<add> .to.contain("import { fooBar } from 'my-app/helpers/foo-bar';");
<add> }));
<ide> });
<ide>
<ide> it('helper foo/bar-baz --pod', function() {
<del> return generateAndDestroy(['helper', 'foo/bar-baz', '--pod'], {
<del> files: [
<del> {
<del> file: 'app/helpers/foo/bar-baz.js',
<del> contains: "import Ember from 'ember';\n\n" +
<del> "export function fooBarBaz(params/*, hash*/) {\n" +
<del> " return params;\n" +
<del> "}\n\n" +
<del> "export default Ember.Helper.helper(fooBarBaz);"
<del> },
<del> {
<del> file: 'tests/unit/helpers/foo/bar-baz-test.js',
<del> contains: "import { fooBarBaz } from 'my-app/helpers/foo/bar-baz';"
<del> }
<del> ]
<del> });
<add> var args = ['helper', 'foo/bar-baz', '--pod'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/helpers/foo/bar-baz.js'))
<add> .to.contain("import Ember from 'ember';\n\n" +
<add> "export function fooBarBaz(params/*, hash*/) {\n" +
<add> " return params;\n" +
<add> "}\n\n" +
<add> "export default Ember.Helper.helper(fooBarBaz);");
<add>
<add> expect(_file('tests/unit/helpers/foo/bar-baz-test.js'))
<add> .to.contain("import { fooBarBaz } from 'my-app/helpers/foo/bar-baz';");
<add> }));
<ide> });
<ide>
<ide> it('helper foo/bar-baz --pod podModulePrefix', function() {
<del> return generateAndDestroy(['helper', 'foo/bar-baz', '--pod'], {
<del> podModulePrefix: true,
<del> files: [
<del> {
<del> file: 'app/helpers/foo/bar-baz.js',
<del> contains: "import Ember from 'ember';\n\n" +
<del> "export function fooBarBaz(params/*, hash*/) {\n" +
<del> " return params;\n" +
<del> "}\n\n" +
<del> "export default Ember.Helper.helper(fooBarBaz);"
<del> },
<del> {
<del> file: 'tests/unit/helpers/foo/bar-baz-test.js',
<del> contains: "import { fooBarBaz } from 'my-app/helpers/foo/bar-baz';"
<del> }
<del> ]
<del> });
<add> var args = ['helper', 'foo/bar-baz', '--pod'];
<add>
<add> return emberNew()
<add> .then(() => setupPodConfig({ podModulePrefix: true }))
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/helpers/foo/bar-baz.js'))
<add> .to.contain("import Ember from 'ember';\n\n" +
<add> "export function fooBarBaz(params/*, hash*/) {\n" +
<add> " return params;\n" +
<add> "}\n\n" +
<add> "export default Ember.Helper.helper(fooBarBaz);");
<add>
<add> expect(_file('tests/unit/helpers/foo/bar-baz-test.js'))
<add> .to.contain("import { fooBarBaz } from 'my-app/helpers/foo/bar-baz';");
<add> }));
<ide> });
<ide>
<ide> it('helper-test foo/bar-baz', function() {
<del> return generateAndDestroy(['helper-test', 'foo/bar-baz'], {
<del> files: [
<del> {
<del> file: 'tests/unit/helpers/foo/bar-baz-test.js',
<del> contains: "import { fooBarBaz } from 'my-app/helpers/foo/bar-baz';"
<del> }
<del> ]
<del> });
<add> var args = ['helper-test', 'foo/bar-baz'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/unit/helpers/foo/bar-baz-test.js'))
<add> .to.contain("import { fooBarBaz } from 'my-app/helpers/foo/bar-baz';");
<add> }));
<ide> });
<ide>
<ide> it('in-addon helper-test foo-bar', function() {
<del> return generateAndDestroy(['helper-test', 'foo-bar'], {
<del> target: 'addon',
<del> files: [
<del> {
<del> file: 'tests/unit/helpers/foo-bar-test.js',
<del> contains: "import { fooBar } from 'dummy/helpers/foo-bar';"
<del> }
<del> ]
<del> });
<add> var args = ['helper-test', 'foo-bar'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/unit/helpers/foo-bar-test.js'))
<add> .to.contain("import { fooBar } from 'dummy/helpers/foo-bar';");
<add> }));
<ide> });
<ide>
<ide> it('helper-test foo/bar-baz for mocha', function() {
<del> return generateAndDestroy(['helper-test', 'foo/bar-baz'], {
<del> packages: [
<del> { name: 'ember-cli-qunit', delete: true },
<del> { name: 'ember-cli-mocha', dev: true }
<del> ],
<del> files: [
<del> {
<del> file: 'tests/unit/helpers/foo/bar-baz-test.js',
<del> contains: [
<del> "import { describe, it } from 'mocha';",
<del> "import { fooBarBaz } from 'my-app/helpers/foo/bar-baz';",
<del> "describe('Unit | Helper | foo/bar baz', function() {"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['helper-test', 'foo/bar-baz'];
<add>
<add> return emberNew()
<add> .then(() => modifyPackages([
<add> {name: 'ember-cli-qunit', delete: true},
<add> {name: 'ember-cli-mocha', dev: true}
<add> ]))
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/unit/helpers/foo/bar-baz-test.js'))
<add> .to.contain("import { describe, it } from 'mocha';")
<add> .to.contain("import { fooBarBaz } from 'my-app/helpers/foo/bar-baz';")
<add> .to.contain("describe('Unit | Helper | foo/bar baz', function() {");
<add> }));
<ide> });
<ide> });
<ide><path>node-tests/blueprints/initializer-addon-test.js
<ide> 'use strict';
<ide>
<del>var setupTestHooks = require('ember-cli-blueprint-test-helpers/lib/helpers/setup');
<del>var BlueprintHelpers = require('ember-cli-blueprint-test-helpers/lib/helpers/blueprint-helper');
<del>var generateAndDestroy = BlueprintHelpers.generateAndDestroy;
<add>var blueprintHelpers = require('ember-cli-blueprint-test-helpers/helpers');
<add>var setupTestHooks = blueprintHelpers.setupTestHooks;
<add>var emberNew = blueprintHelpers.emberNew;
<add>var emberGenerateDestroy = blueprintHelpers.emberGenerateDestroy;
<add>
<add>var chai = require('ember-cli-blueprint-test-helpers/chai');
<add>var expect = chai.expect;
<ide>
<ide> describe('Acceptance: ember generate and destroy initializer-addon', function() {
<ide> setupTestHooks(this);
<ide>
<ide> it('initializer-addon foo', function() {
<del> // pass any additional command line options in the arguments array
<del> return generateAndDestroy(['initializer-addon', 'foo'], {
<del> // define files to assert, and their contents
<del> target: 'addon',
<del> files: [
<del> {
<del> file: 'app/initializers/foo.js',
<del> contains: "export { default, initialize } from 'my-addon/initializers/foo';"
<del> }
<del> ]
<del> });
<del> });
<add> var args = ['initializer-addon', 'foo'];
<ide>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/initializers/foo.js'))
<add> .to.contain("export { default, initialize } from 'my-addon/initializers/foo';");
<add> }));
<add> });
<ide> });
<ide><path>node-tests/blueprints/initializer-test.js
<ide> 'use strict';
<ide>
<del>var setupTestHooks = require('ember-cli-blueprint-test-helpers/lib/helpers/setup');
<del>var BlueprintHelpers = require('ember-cli-blueprint-test-helpers/lib/helpers/blueprint-helper');
<del>var generateAndDestroy = BlueprintHelpers.generateAndDestroy;
<add>var blueprintHelpers = require('ember-cli-blueprint-test-helpers/helpers');
<add>var setupTestHooks = blueprintHelpers.setupTestHooks;
<add>var emberNew = blueprintHelpers.emberNew;
<add>var emberGenerateDestroy = blueprintHelpers.emberGenerateDestroy;
<add>var modifyPackages = blueprintHelpers.modifyPackages;
<add>var setupPodConfig = blueprintHelpers.setupPodConfig;
<add>
<add>var chai = require('ember-cli-blueprint-test-helpers/chai');
<add>var expect = chai.expect;
<ide>
<ide> describe('Acceptance: ember generate and destroy initializer', function() {
<ide> setupTestHooks(this);
<ide>
<ide> it('initializer foo', function() {
<del> return generateAndDestroy(['initializer', 'foo'], {
<del> files: [
<del> {
<del> file:'app/initializers/foo.js',
<del> contains: "export function initialize(/* application */) {\n" +
<del> " // application.inject('route', 'foo', 'service:foo');\n" +
<del> "}\n" +
<del> "\n"+
<del> "export default {\n" +
<del> " name: 'foo',\n" +
<del> " initialize\n" +
<del> "};"
<del> },
<del> {
<del> file:'tests/unit/initializers/foo-test.js',
<del> contains: "import FooInitializer from 'my-app/initializers/foo';"
<del> }
<del> ]
<del> });
<add> var args = ['initializer', 'foo'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/initializers/foo.js'))
<add> .to.contain("export function initialize(/* application */) {\n" +
<add> " // application.inject('route', 'foo', 'service:foo');\n" +
<add> "}\n" +
<add> "\n" +
<add> "export default {\n" +
<add> " name: 'foo',\n" +
<add> " initialize\n" +
<add> "};");
<add>
<add> expect(_file('tests/unit/initializers/foo-test.js'))
<add> .to.contain("import FooInitializer from 'my-app/initializers/foo';");
<add> }));
<ide> });
<ide>
<ide> it('initializer foo/bar', function() {
<del> return generateAndDestroy(['initializer', 'foo/bar'], {
<del> files: [
<del> {
<del> file:'app/initializers/foo/bar.js',
<del> contains: "export function initialize(/* application */) {\n" +
<del> " // application.inject('route', 'foo', 'service:foo');\n" +
<del> "}\n" +
<del> "\n"+
<del> "export default {\n" +
<del> " name: 'foo/bar',\n" +
<del> " initialize\n" +
<del> "};"
<del> },
<del> {
<del> file:'tests/unit/initializers/foo/bar-test.js',
<del> contains: "import FooBarInitializer from 'my-app/initializers/foo/bar';"
<del> }
<del> ]
<del> });
<add> var args = ['initializer', 'foo/bar'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/initializers/foo/bar.js'))
<add> .to.contain("export function initialize(/* application */) {\n" +
<add> " // application.inject('route', 'foo', 'service:foo');\n" +
<add> "}\n" +
<add> "\n" +
<add> "export default {\n" +
<add> " name: 'foo/bar',\n" +
<add> " initialize\n" +
<add> "};");
<add>
<add> expect(_file('tests/unit/initializers/foo/bar-test.js'))
<add> .to.contain("import FooBarInitializer from 'my-app/initializers/foo/bar';");
<add> }));
<ide> });
<ide>
<ide> it('in-addon initializer foo', function() {
<del> return generateAndDestroy(['initializer', 'foo'], {
<del> target: 'addon',
<del> files: [
<del> {
<del> file: 'addon/initializers/foo.js',
<del> contains: "export function initialize(/* application */) {\n" +
<del> " // application.inject('route', 'foo', 'service:foo');\n" +
<del> "}\n" +
<del> "\n"+
<del> "export default {\n" +
<del> " name: 'foo',\n" +
<del> " initialize\n" +
<del> "};"
<del> },
<del> {
<del> file: 'app/initializers/foo.js',
<del> contains: [
<del> "export { default, initialize } from 'my-addon/initializers/foo';"
<del> ]
<del> },
<del> {
<del> file: 'tests/unit/initializers/foo-test.js'
<del> }
<del> ]
<del> });
<add> var args = ['initializer', 'foo'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('addon/initializers/foo.js'))
<add> .to.contain("export function initialize(/* application */) {\n" +
<add> " // application.inject('route', 'foo', 'service:foo');\n" +
<add> "}\n" +
<add> "\n" +
<add> "export default {\n" +
<add> " name: 'foo',\n" +
<add> " initialize\n" +
<add> "};");
<add>
<add> expect(_file('app/initializers/foo.js'))
<add> .to.contain("export { default, initialize } from 'my-addon/initializers/foo';");
<add>
<add> expect(_file('tests/unit/initializers/foo-test.js'))
<add> .to.exist;
<add> }));
<ide> });
<ide>
<ide> it('in-addon initializer foo/bar', function() {
<del> return generateAndDestroy(['initializer', 'foo/bar'], {
<del> target: 'addon',
<del> files: [
<del> {
<del> file: 'addon/initializers/foo/bar.js',
<del> contains: "export function initialize(/* application */) {\n" +
<del> " // application.inject('route', 'foo', 'service:foo');\n" +
<del> "}\n" +
<del> "\n"+
<del> "export default {\n" +
<del> " name: 'foo/bar',\n" +
<del> " initialize\n" +
<del> "};"
<del> },
<del> {
<del> file: 'app/initializers/foo/bar.js',
<del> contains: [
<del> "export { default, initialize } from 'my-addon/initializers/foo/bar';"
<del> ]
<del> },
<del> {
<del> file: 'tests/unit/initializers/foo/bar-test.js'
<del> }
<del> ]
<del> });
<add> var args = ['initializer', 'foo/bar'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('addon/initializers/foo/bar.js'))
<add> .to.contain("export function initialize(/* application */) {\n" +
<add> " // application.inject('route', 'foo', 'service:foo');\n" +
<add> "}\n" +
<add> "\n" +
<add> "export default {\n" +
<add> " name: 'foo/bar',\n" +
<add> " initialize\n" +
<add> "};");
<add>
<add> expect(_file('app/initializers/foo/bar.js'))
<add> .to.contain("export { default, initialize } from 'my-addon/initializers/foo/bar';");
<add>
<add> expect(_file('tests/unit/initializers/foo/bar-test.js'))
<add> .to.exist;
<add> }));
<ide> });
<ide>
<ide> it('dummy initializer foo', function() {
<del> return generateAndDestroy(['initializer', 'foo', '--dummy'], {
<del> target: 'addon',
<del> files: [
<del> {
<del> file: 'tests/dummy/app/initializers/foo.js',
<del> contains: "export function initialize(/* application */) {\n" +
<del> " // application.inject('route', 'foo', 'service:foo');\n" +
<del> "}\n" +
<del> "\n"+
<del> "export default {\n" +
<del> " name: 'foo',\n" +
<del> " initialize\n" +
<del> "};"
<del> },
<del> {
<del> file: 'app/initializers/foo.js',
<del> exists: false
<del> },
<del> {
<del> file: 'tests/unit/initializers/foo-test.js',
<del> exists: false
<del> }
<del> ]
<del> });
<add> var args = ['initializer', 'foo', '--dummy'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/dummy/app/initializers/foo.js'))
<add> .to.contain("export function initialize(/* application */) {\n" +
<add> " // application.inject('route', 'foo', 'service:foo');\n" +
<add> "}\n" +
<add> "\n" +
<add> "export default {\n" +
<add> " name: 'foo',\n" +
<add> " initialize\n" +
<add> "};");
<add>
<add> expect(_file('app/initializers/foo.js'))
<add> .to.not.exist;
<add>
<add> expect(_file('tests/unit/initializers/foo-test.js'))
<add> .to.not.exist;
<add> }));
<ide> });
<ide>
<ide> it('dummy initializer foo/bar', function() {
<del> return generateAndDestroy(['initializer', 'foo/bar', '--dummy'], {
<del> target: 'addon',
<del> files: [
<del> {
<del> file: 'tests/dummy/app/initializers/foo/bar.js',
<del> contains: "export function initialize(/* application */) {\n" +
<del> " // application.inject('route', 'foo', 'service:foo');\n" +
<del> "}\n" +
<del> "\n"+
<del> "export default {\n" +
<del> " name: 'foo/bar',\n" +
<del> " initialize\n" +
<del> "};"
<del> },
<del> {
<del> file: 'app/initializers/foo/bar.js',
<del> exists: false
<del> },
<del> {
<del> file: 'tests/unit/initializers/foo/bar-test.js',
<del> exists: false
<del> }
<del> ]
<del> });
<add> var args = ['initializer', 'foo/bar', '--dummy'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/dummy/app/initializers/foo/bar.js'))
<add> .to.contain("export function initialize(/* application */) {\n" +
<add> " // application.inject('route', 'foo', 'service:foo');\n" +
<add> "}\n" +
<add> "\n" +
<add> "export default {\n" +
<add> " name: 'foo/bar',\n" +
<add> " initialize\n" +
<add> "};");
<add>
<add> expect(_file('app/initializers/foo/bar.js'))
<add> .to.not.exist;
<add>
<add> expect(_file('tests/unit/initializers/foo/bar-test.js'))
<add> .to.not.exist;
<add> }));
<ide> });
<ide>
<ide> it('in-repo-addon initializer foo', function() {
<del> return generateAndDestroy(['initializer', 'foo', '--in-repo-addon=my-addon'], {
<del> target: 'inRepoAddon',
<del> files: [
<del> {
<del> file: 'lib/my-addon/addon/initializers/foo.js',
<del> contains: "export function initialize(/* application */) {\n" +
<del> " // application.inject('route', 'foo', 'service:foo');\n" +
<del> "}\n" +
<del> "\n"+
<del> "export default {\n" +
<del> " name: 'foo',\n" +
<del> " initialize\n" +
<del> "};"
<del> },
<del> {
<del> file: 'lib/my-addon/app/initializers/foo.js',
<del> contains: [
<del> "export { default, initialize } from 'my-addon/initializers/foo';"
<del> ]
<del> },
<del> {
<del> file: 'tests/unit/initializers/foo-test.js'
<del> }
<del> ]
<del> });
<add> var args = ['initializer', 'foo', '--in-repo-addon=my-addon'];
<add>
<add> return emberNew({ target: 'in-repo-addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('lib/my-addon/addon/initializers/foo.js'))
<add> .to.contain("export function initialize(/* application */) {\n" +
<add> " // application.inject('route', 'foo', 'service:foo');\n" +
<add> "}\n" +
<add> "\n" +
<add> "export default {\n" +
<add> " name: 'foo',\n" +
<add> " initialize\n" +
<add> "};");
<add>
<add> expect(_file('lib/my-addon/app/initializers/foo.js'))
<add> .to.contain("export { default, initialize } from 'my-addon/initializers/foo';");
<add>
<add> expect(_file('tests/unit/initializers/foo-test.js'))
<add> .to.exist;
<add> }));
<ide> });
<ide>
<ide> it('in-repo-addon initializer foo/bar', function() {
<del> return generateAndDestroy(['initializer', 'foo/bar', '--in-repo-addon=my-addon'], {
<del> target: 'inRepoAddon',
<del> files: [
<del> {
<del> file: 'lib/my-addon/addon/initializers/foo/bar.js',
<del> contains: "export function initialize(/* application */) {\n" +
<del> " // application.inject('route', 'foo', 'service:foo');\n" +
<del> "}\n" +
<del> "\n"+
<del> "export default {\n" +
<del> " name: 'foo/bar',\n" +
<del> " initialize\n" +
<del> "};"
<del> },
<del> {
<del> file: 'lib/my-addon/app/initializers/foo/bar.js',
<del> contains: [
<del> "export { default, initialize } from 'my-addon/initializers/foo/bar';"
<del> ]
<del> },
<del> {
<del> file: 'tests/unit/initializers/foo/bar-test.js'
<del> }
<del> ]
<del> });
<add> var args = ['initializer', 'foo/bar', '--in-repo-addon=my-addon'];
<add>
<add> return emberNew({ target: 'in-repo-addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('lib/my-addon/addon/initializers/foo/bar.js'))
<add> .to.contain("export function initialize(/* application */) {\n" +
<add> " // application.inject('route', 'foo', 'service:foo');\n" +
<add> "}\n" +
<add> "\n" +
<add> "export default {\n" +
<add> " name: 'foo/bar',\n" +
<add> " initialize\n" +
<add> "};");
<add>
<add> expect(_file('lib/my-addon/app/initializers/foo/bar.js'))
<add> .to.contain("export { default, initialize } from 'my-addon/initializers/foo/bar';");
<add>
<add> expect(_file('tests/unit/initializers/foo/bar-test.js'))
<add> .to.exist;
<add> }));
<ide> });
<ide>
<ide> /* Pod tests */
<ide>
<ide> it('initializer foo --pod', function() {
<del> return generateAndDestroy(['initializer', 'foo', '--pod'], {
<del> files: [
<del> {
<del> file: 'app/initializers/foo.js',
<del> contains: "export function initialize(/* application */) {\n" +
<del> " // application.inject('route', 'foo', 'service:foo');\n" +
<del> "}\n" +
<del> "\n"+
<del> "export default {\n" +
<del> " name: 'foo',\n" +
<del> " initialize\n" +
<del> "};"
<del> }
<del> ]
<del> });
<add> var args = ['initializer', 'foo', '--pod'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/initializers/foo.js'))
<add> .to.contain("export function initialize(/* application */) {\n" +
<add> " // application.inject('route', 'foo', 'service:foo');\n" +
<add> "}\n" +
<add> "\n" +
<add> "export default {\n" +
<add> " name: 'foo',\n" +
<add> " initialize\n" +
<add> "};");
<add> }));
<ide> });
<ide>
<ide> it('initializer foo --pod podModulePrefix', function() {
<del> return generateAndDestroy(['initializer', 'foo', '--pod'], {
<del> podModulePrefix: true,
<del> files: [
<del> {
<del> file: 'app/initializers/foo.js',
<del> contains: "export function initialize(/* application */) {\n" +
<del> " // application.inject('route', 'foo', 'service:foo');\n" +
<del> "}\n" +
<del> "\n"+
<del> "export default {\n" +
<del> " name: 'foo',\n" +
<del> " initialize\n" +
<del> "};"
<del> }
<del> ]
<del> });
<add> var args = ['initializer', 'foo', '--pod'];
<add>
<add> return emberNew()
<add> .then(() => setupPodConfig({ podModulePrefix: true }))
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/initializers/foo.js'))
<add> .to.contain("export function initialize(/* application */) {\n" +
<add> " // application.inject('route', 'foo', 'service:foo');\n" +
<add> "}\n" +
<add> "\n" +
<add> "export default {\n" +
<add> " name: 'foo',\n" +
<add> " initialize\n" +
<add> "};");
<add> }));
<ide> });
<ide>
<ide> it('initializer foo/bar --pod', function() {
<del> return generateAndDestroy(['initializer', 'foo/bar', '--pod'], {
<del> files: [
<del> {
<del> file: 'app/initializers/foo/bar.js',
<del> contains: "export function initialize(/* application */) {\n" +
<del> " // application.inject('route', 'foo', 'service:foo');\n" +
<del> "}\n" +
<del> "\n"+
<del> "export default {\n" +
<del> " name: 'foo/bar',\n" +
<del> " initialize\n" +
<del> "};"
<del> }
<del> ]
<del> });
<add> var args = ['initializer', 'foo/bar', '--pod'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/initializers/foo/bar.js'))
<add> .to.contain("export function initialize(/* application */) {\n" +
<add> " // application.inject('route', 'foo', 'service:foo');\n" +
<add> "}\n" +
<add> "\n" +
<add> "export default {\n" +
<add> " name: 'foo/bar',\n" +
<add> " initialize\n" +
<add> "};");
<add> }));
<ide> });
<ide>
<ide>
<ide> it('initializer foo/bar --pod podModulePrefix', function() {
<del> return generateAndDestroy(['initializer', 'foo/bar', '--pod'], {
<del> podModulePrefix: true,
<del> files: [
<del> {
<del> file: 'app/initializers/foo/bar.js',
<del> contains: "export function initialize(/* application */) {\n" +
<del> " // application.inject('route', 'foo', 'service:foo');\n" +
<del> "}\n" +
<del> "\n"+
<del> "export default {\n" +
<del> " name: 'foo/bar',\n" +
<del> " initialize\n" +
<del> "};"
<del> }
<del> ]
<del> });
<add> var args = ['initializer', 'foo/bar', '--pod'];
<add>
<add> return emberNew()
<add> .then(() => setupPodConfig({ podModulePrefix: true }))
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/initializers/foo/bar.js'))
<add> .to.contain("export function initialize(/* application */) {\n" +
<add> " // application.inject('route', 'foo', 'service:foo');\n" +
<add> "}\n" +
<add> "\n" +
<add> "export default {\n" +
<add> " name: 'foo/bar',\n" +
<add> " initialize\n" +
<add> "};");
<add> }));
<ide> });
<ide>
<ide>
<ide> it('initializer-test foo', function() {
<del> return generateAndDestroy(['initializer-test', 'foo'], {
<del> files: [
<del> {
<del> file: 'tests/unit/initializers/foo-test.js',
<del> contains: [
<del> "import FooInitializer from 'my-app/initializers/foo';",
<del> "module('Unit | Initializer | foo'",
<del> "application = Ember.Application.create();",
<del> "FooInitializer.initialize(application);"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['initializer-test', 'foo'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/unit/initializers/foo-test.js'))
<add> .to.contain("import FooInitializer from 'my-app/initializers/foo';")
<add> .to.contain("module('Unit | Initializer | foo'")
<add> .to.contain("application = Ember.Application.create();")
<add> .to.contain("FooInitializer.initialize(application);");
<add> }));
<ide> });
<ide>
<ide> it('in-addon initializer-test foo', function() {
<del> return generateAndDestroy(['initializer-test', 'foo'], {
<del> target: 'addon',
<del> files: [
<del> {
<del> file: 'tests/unit/initializers/foo-test.js',
<del> contains: [
<del> "import FooInitializer from 'dummy/initializers/foo';",
<del> "module('Unit | Initializer | foo'",
<del> "application = Ember.Application.create();",
<del> "FooInitializer.initialize(application);"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['initializer-test', 'foo'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/unit/initializers/foo-test.js'))
<add> .to.contain("import FooInitializer from 'dummy/initializers/foo';")
<add> .to.contain("module('Unit | Initializer | foo'")
<add> .to.contain("application = Ember.Application.create();")
<add> .to.contain("FooInitializer.initialize(application);");
<add> }));
<ide> });
<ide>
<ide> it('initializer-test foo for mocha', function() {
<del> return generateAndDestroy(['initializer-test', 'foo'], {
<del> packages: [
<del> { name: 'ember-cli-qunit', delete: true },
<del> { name: 'ember-cli-mocha', dev: true }
<del> ],
<del> files: [
<del> {
<del> file: 'tests/unit/initializers/foo-test.js',
<del> contains: [
<del> "import FooInitializer from 'my-app/initializers/foo';",
<del> "describe('Unit | Initializer | foo', function() {",
<del> "application = Ember.Application.create();",
<del> "FooInitializer.initialize(application);"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['initializer-test', 'foo'];
<add>
<add> return emberNew()
<add> .then(() => modifyPackages([
<add> {name: 'ember-cli-qunit', delete: true},
<add> {name: 'ember-cli-mocha', dev: true}
<add> ]))
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/unit/initializers/foo-test.js'))
<add> .to.contain("import FooInitializer from 'my-app/initializers/foo';")
<add> .to.contain("describe('Unit | Initializer | foo', function() {")
<add> .to.contain("application = Ember.Application.create();")
<add> .to.contain("FooInitializer.initialize(application);");
<add> }));
<ide> });
<ide> });
<ide><path>node-tests/blueprints/instance-initializer-addon-test.js
<ide> 'use strict';
<ide>
<del>var tmpenv = require('ember-cli-blueprint-test-helpers/lib/helpers/tmp-env');
<del>var setupTestHooks = require('ember-cli-blueprint-test-helpers/lib/helpers/setup');
<del>var BlueprintHelpers = require('ember-cli-blueprint-test-helpers/lib/helpers/blueprint-helper');
<del>var generateAndDestroy = BlueprintHelpers.generateAndDestroy;
<add>var blueprintHelpers = require('ember-cli-blueprint-test-helpers/helpers');
<add>var setupTestHooks = blueprintHelpers.setupTestHooks;
<add>var emberNew = blueprintHelpers.emberNew;
<add>var emberGenerateDestroy = blueprintHelpers.emberGenerateDestroy;
<add>
<add>var chai = require('ember-cli-blueprint-test-helpers/chai');
<add>var expect = chai.expect;
<ide>
<ide> describe('Acceptance: ember generate and destroy instance-initializer-addon', function() {
<del> setupTestHooks(this, tmpenv);
<add> setupTestHooks(this);
<ide>
<ide> it('instance-initializer-addon foo', function() {
<del> // pass any additional command line options in the arguments array
<del> return generateAndDestroy(['instance-initializer-addon', 'foo'], {
<del> // define files to assert, and their contents
<del> target: 'addon',
<del> files: [
<del> {
<del> file: 'app/instance-initializers/foo.js',
<del> contains: "export { default, initialize } from 'my-addon/instance-initializers/foo';"
<del> }
<del> ]
<del> });
<del> });
<add> var args = ['instance-initializer-addon', 'foo'];
<ide>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/instance-initializers/foo.js'))
<add> .to.contain("export { default, initialize } from 'my-addon/instance-initializers/foo';");
<add> }));
<add> });
<ide> });
<ide><path>node-tests/blueprints/instance-initializer-test.js
<ide> 'use strict';
<ide>
<del>var setupTestHooks = require('ember-cli-blueprint-test-helpers/lib/helpers/setup');
<del>var BlueprintHelpers = require('ember-cli-blueprint-test-helpers/lib/helpers/blueprint-helper');
<del>var generateAndDestroy = BlueprintHelpers.generateAndDestroy;
<add>var blueprintHelpers = require('ember-cli-blueprint-test-helpers/helpers');
<add>var setupTestHooks = blueprintHelpers.setupTestHooks;
<add>var emberNew = blueprintHelpers.emberNew;
<add>var emberGenerateDestroy = blueprintHelpers.emberGenerateDestroy;
<add>var modifyPackages = blueprintHelpers.modifyPackages;
<add>var setupPodConfig = blueprintHelpers.setupPodConfig;
<add>
<add>var chai = require('ember-cli-blueprint-test-helpers/chai');
<add>var expect = chai.expect;
<ide>
<ide> describe('Acceptance: ember generate and destroy instance-initializer', function() {
<ide> setupTestHooks(this);
<ide>
<ide> it('instance-initializer foo', function() {
<del> return generateAndDestroy(['instance-initializer', 'foo'], {
<del> files: [
<del> {
<del> file:'app/instance-initializers/foo.js',
<del> contains: "export function initialize(/* appInstance */) {\n" +
<del> " // appInstance.inject('route', 'foo', 'service:foo');\n" +
<del> "}\n" +
<del> "\n"+
<del> "export default {\n" +
<del> " name: 'foo',\n" +
<del> " initialize\n" +
<del> "};"
<del> },
<del> {
<del> file:'tests/unit/instance-initializers/foo-test.js',
<del> contains: "import { initialize } from 'my-app/instance-initializers/foo';"
<del> }
<del> ]
<del> });
<add> var args = ['instance-initializer', 'foo'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/instance-initializers/foo.js'))
<add> .to.contain("export function initialize(/* appInstance */) {\n" +
<add> " // appInstance.inject('route', 'foo', 'service:foo');\n" +
<add> "}\n" +
<add> "\n" +
<add> "export default {\n" +
<add> " name: 'foo',\n" +
<add> " initialize\n" +
<add> "};");
<add>
<add> expect(_file('tests/unit/instance-initializers/foo-test.js'))
<add> .to.contain("import { initialize } from 'my-app/instance-initializers/foo';");
<add> }));
<ide> });
<ide>
<ide> it('instance-initializer foo/bar', function() {
<del> return generateAndDestroy(['instance-initializer', 'foo/bar'], {
<del> files: [
<del> {
<del> file:'app/instance-initializers/foo/bar.js',
<del> contains: "export function initialize(/* appInstance */) {\n" +
<del> " // appInstance.inject('route', 'foo', 'service:foo');\n" +
<del> "}\n" +
<del> "\n"+
<del> "export default {\n" +
<del> " name: 'foo/bar',\n" +
<del> " initialize\n" +
<del> "};"
<del> },
<del> {
<del> file:'tests/unit/instance-initializers/foo/bar-test.js',
<del> contains: "import { initialize } from 'my-app/instance-initializers/foo/bar';"
<del> }
<del> ]
<del> });
<add> var args = ['instance-initializer', 'foo/bar'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/instance-initializers/foo/bar.js'))
<add> .to.contain("export function initialize(/* appInstance */) {\n" +
<add> " // appInstance.inject('route', 'foo', 'service:foo');\n" +
<add> "}\n" +
<add> "\n" +
<add> "export default {\n" +
<add> " name: 'foo/bar',\n" +
<add> " initialize\n" +
<add> "};");
<add>
<add> expect(_file('tests/unit/instance-initializers/foo/bar-test.js'))
<add> .to.contain("import { initialize } from 'my-app/instance-initializers/foo/bar';");
<add> }));
<ide> });
<ide>
<ide> it('in-addon instance-initializer foo', function() {
<del> return generateAndDestroy(['instance-initializer', 'foo'], {
<del> target: 'addon',
<del> files: [
<del> {
<del> file: 'addon/instance-initializers/foo.js',
<del> contains: "export function initialize(/* appInstance */) {\n" +
<del> " // appInstance.inject('route', 'foo', 'service:foo');\n" +
<del> "}\n" +
<del> "\n"+
<del> "export default {\n" +
<del> " name: 'foo',\n" +
<del> " initialize\n" +
<del> "};"
<del> },
<del> {
<del> file: 'app/instance-initializers/foo.js',
<del> contains: [
<del> "export { default, initialize } from 'my-addon/instance-initializers/foo';"
<del> ]
<del> },
<del> {
<del> file: 'tests/unit/instance-initializers/foo-test.js'
<del> }
<del> ]
<del> });
<add> var args = ['instance-initializer', 'foo'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('addon/instance-initializers/foo.js'))
<add> .to.contain("export function initialize(/* appInstance */) {\n" +
<add> " // appInstance.inject('route', 'foo', 'service:foo');\n" +
<add> "}\n" +
<add> "\n" +
<add> "export default {\n" +
<add> " name: 'foo',\n" +
<add> " initialize\n" +
<add> "};");
<add>
<add> expect(_file('app/instance-initializers/foo.js'))
<add> .to.contain("export { default, initialize } from 'my-addon/instance-initializers/foo';");
<add>
<add> expect(_file('tests/unit/instance-initializers/foo-test.js'));
<add> }));
<ide> });
<ide>
<ide> it('in-addon instance-initializer foo/bar', function() {
<del> return generateAndDestroy(['instance-initializer', 'foo/bar'], {
<del> target: 'addon',
<del> files: [
<del> {
<del> file: 'addon/instance-initializers/foo/bar.js',
<del> contains: "export function initialize(/* appInstance */) {\n" +
<del> " // appInstance.inject('route', 'foo', 'service:foo');\n" +
<del> "}\n" +
<del> "\n"+
<del> "export default {\n" +
<del> " name: 'foo/bar',\n" +
<del> " initialize\n" +
<del> "};"
<del> },
<del> {
<del> file: 'app/instance-initializers/foo/bar.js',
<del> contains: [
<del> "export { default, initialize } from 'my-addon/instance-initializers/foo/bar';"
<del> ]
<del> },
<del> {
<del> file: 'tests/unit/instance-initializers/foo/bar-test.js'
<del> }
<del> ]
<del> });
<add> var args = ['instance-initializer', 'foo/bar'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('addon/instance-initializers/foo/bar.js'))
<add> .to.contain("export function initialize(/* appInstance */) {\n" +
<add> " // appInstance.inject('route', 'foo', 'service:foo');\n" +
<add> "}\n" +
<add> "\n" +
<add> "export default {\n" +
<add> " name: 'foo/bar',\n" +
<add> " initialize\n" +
<add> "};");
<add>
<add> expect(_file('app/instance-initializers/foo/bar.js'))
<add> .to.contain("export { default, initialize } from 'my-addon/instance-initializers/foo/bar';");
<add>
<add> expect(_file('tests/unit/instance-initializers/foo/bar-test.js'));
<add> }));
<ide> });
<ide>
<ide> it('dummy instance-initializer foo', function() {
<del> return generateAndDestroy(['instance-initializer', 'foo', '--dummy'], {
<del> target: 'addon',
<del> files: [
<del> {
<del> file: 'tests/dummy/app/instance-initializers/foo.js',
<del> contains: "export function initialize(/* appInstance */) {\n" +
<del> " // appInstance.inject('route', 'foo', 'service:foo');\n" +
<del> "}\n" +
<del> "\n"+
<del> "export default {\n" +
<del> " name: 'foo',\n" +
<del> " initialize\n" +
<del> "};"
<del> },
<del> {
<del> file: 'app/instance-initializers/foo.js',
<del> exists: false
<del> },
<del> {
<del> file: 'tests/unit/instance-initializers/foo-test.js',
<del> exists: false
<del> }
<del> ]
<del> });
<add> var args = ['instance-initializer', 'foo', '--dummy'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/dummy/app/instance-initializers/foo.js'))
<add> .to.contain("export function initialize(/* appInstance */) {\n" +
<add> " // appInstance.inject('route', 'foo', 'service:foo');\n" +
<add> "}\n" +
<add> "\n" +
<add> "export default {\n" +
<add> " name: 'foo',\n" +
<add> " initialize\n" +
<add> "};");
<add>
<add> expect(_file('app/instance-initializers/foo.js'))
<add> .to.not.exist;
<add>
<add> expect(_file('tests/unit/instance-initializers/foo-test.js'))
<add> .to.not.exist;
<add> }));
<ide> });
<ide>
<ide> it('dummy instance-initializer foo/bar', function() {
<del> return generateAndDestroy(['instance-initializer', 'foo/bar', '--dummy'], {
<del> target: 'addon',
<del> files: [
<del> {
<del> file: 'tests/dummy/app/instance-initializers/foo/bar.js',
<del> contains: "export function initialize(/* appInstance */) {\n" +
<del> " // appInstance.inject('route', 'foo', 'service:foo');\n" +
<del> "}\n" +
<del> "\n"+
<del> "export default {\n" +
<del> " name: 'foo/bar',\n" +
<del> " initialize\n" +
<del> "};"
<del> },
<del> {
<del> file: 'app/instance-initializers/foo/bar.js',
<del> exists: false
<del> },
<del> {
<del> file: 'tests/unit/instance-initializers/foo/bar-test.js',
<del> exists: false
<del> }
<del> ]
<del> });
<add> var args = ['instance-initializer', 'foo/bar', '--dummy'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/dummy/app/instance-initializers/foo/bar.js'))
<add> .to.contain("export function initialize(/* appInstance */) {\n" +
<add> " // appInstance.inject('route', 'foo', 'service:foo');\n" +
<add> "}\n" +
<add> "\n" +
<add> "export default {\n" +
<add> " name: 'foo/bar',\n" +
<add> " initialize\n" +
<add> "};");
<add>
<add> expect(_file('app/instance-initializers/foo/bar.js'))
<add> .to.not.exist;
<add>
<add> expect(_file('tests/unit/instance-initializers/foo/bar-test.js'))
<add> .to.not.exist;
<add> }));
<ide> });
<ide>
<ide> it('in-repo-addon instance-initializer foo', function() {
<del> return generateAndDestroy(['instance-initializer', 'foo', '--in-repo-addon=my-addon'], {
<del> target: 'inRepoAddon',
<del> files: [
<del> {
<del> file: 'lib/my-addon/addon/instance-initializers/foo.js',
<del> contains: "export function initialize(/* appInstance */) {\n" +
<del> " // appInstance.inject('route', 'foo', 'service:foo');\n" +
<del> "}\n" +
<del> "\n"+
<del> "export default {\n" +
<del> " name: 'foo',\n" +
<del> " initialize\n" +
<del> "};"
<del> },
<del> {
<del> file: 'lib/my-addon/app/instance-initializers/foo.js',
<del> contains: [
<del> "export { default, initialize } from 'my-addon/instance-initializers/foo';"
<del> ]
<del> },
<del> {
<del> file: 'tests/unit/instance-initializers/foo-test.js'
<del> }
<del> ]
<del> });
<add> var args = ['instance-initializer', 'foo', '--in-repo-addon=my-addon'];
<add>
<add> return emberNew({ target: 'in-repo-addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('lib/my-addon/addon/instance-initializers/foo.js'))
<add> .to.contain("export function initialize(/* appInstance */) {\n" +
<add> " // appInstance.inject('route', 'foo', 'service:foo');\n" +
<add> "}\n" +
<add> "\n" +
<add> "export default {\n" +
<add> " name: 'foo',\n" +
<add> " initialize\n" +
<add> "};");
<add>
<add> expect(_file('lib/my-addon/app/instance-initializers/foo.js'))
<add> .to.contain("export { default, initialize } from 'my-addon/instance-initializers/foo';");
<add>
<add> expect(_file('tests/unit/instance-initializers/foo-test.js'))
<add> .to.exist;
<add> }));
<ide> });
<ide>
<ide> it('in-repo-addon instance-initializer foo/bar', function() {
<del> return generateAndDestroy(['instance-initializer', 'foo/bar', '--in-repo-addon=my-addon'], {
<del> target: 'inRepoAddon',
<del> files: [
<del> {
<del> file: 'lib/my-addon/addon/instance-initializers/foo/bar.js',
<del> contains: "export function initialize(/* appInstance */) {\n" +
<del> " // appInstance.inject('route', 'foo', 'service:foo');\n" +
<del> "}\n" +
<del> "\n"+
<del> "export default {\n" +
<del> " name: 'foo/bar',\n" +
<del> " initialize\n" +
<del> "};"
<del> },
<del> {
<del> file: 'lib/my-addon/app/instance-initializers/foo/bar.js',
<del> contains: [
<del> "export { default, initialize } from 'my-addon/instance-initializers/foo/bar';"
<del> ]
<del> },
<del> {
<del> file: 'tests/unit/instance-initializers/foo/bar-test.js'
<del> }
<del> ]
<del> });
<add> var args = ['instance-initializer', 'foo/bar', '--in-repo-addon=my-addon'];
<add>
<add> return emberNew({ target: 'in-repo-addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('lib/my-addon/addon/instance-initializers/foo/bar.js'))
<add> .to.contain("export function initialize(/* appInstance */) {\n" +
<add> " // appInstance.inject('route', 'foo', 'service:foo');\n" +
<add> "}\n" +
<add> "\n" +
<add> "export default {\n" +
<add> " name: 'foo/bar',\n" +
<add> " initialize\n" +
<add> "};");
<add>
<add> expect(_file('lib/my-addon/app/instance-initializers/foo/bar.js'))
<add> .to.contain("export { default, initialize } from 'my-addon/instance-initializers/foo/bar';");
<add>
<add> expect(_file('tests/unit/instance-initializers/foo/bar-test.js'))
<add> .to.exist;
<add> }));
<ide> });
<ide>
<ide> /* Pod tests */
<ide>
<ide> it('instance-initializer foo --pod', function() {
<del> return generateAndDestroy(['instance-initializer', 'foo', '--pod'], {
<del> files: [
<del> {
<del> file: 'app/instance-initializers/foo.js',
<del> contains: "export function initialize(/* appInstance */) {\n" +
<del> " // appInstance.inject('route', 'foo', 'service:foo');\n" +
<del> "}\n" +
<del> "\n"+
<del> "export default {\n" +
<del> " name: 'foo',\n" +
<del> " initialize\n" +
<del> "};"
<del> }
<del> ]
<del> });
<add> var args = ['instance-initializer', 'foo', '--pod'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/instance-initializers/foo.js'))
<add> .to.contain("export function initialize(/* appInstance */) {\n" +
<add> " // appInstance.inject('route', 'foo', 'service:foo');\n" +
<add> "}\n" +
<add> "\n" +
<add> "export default {\n" +
<add> " name: 'foo',\n" +
<add> " initialize\n" +
<add> "};");
<add> }));
<ide> });
<ide>
<ide> it('instance-initializer foo --pod podModulePrefix', function() {
<del> return generateAndDestroy(['instance-initializer', 'foo', '--pod'], {
<del> podModulePrefix: true,
<del> files: [
<del> {
<del> file: 'app/instance-initializers/foo.js',
<del> contains: "export function initialize(/* appInstance */) {\n" +
<del> " // appInstance.inject('route', 'foo', 'service:foo');\n" +
<del> "}\n" +
<del> "\n"+
<del> "export default {\n" +
<del> " name: 'foo',\n" +
<del> " initialize\n" +
<del> "};"
<del> }
<del> ]
<del> });
<add> var args = ['instance-initializer', 'foo', '--pod'];
<add>
<add> return emberNew()
<add> .then(() => setupPodConfig({ podModulePrefix: true }))
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/instance-initializers/foo.js'))
<add> .to.contain("export function initialize(/* appInstance */) {\n" +
<add> " // appInstance.inject('route', 'foo', 'service:foo');\n" +
<add> "}\n" +
<add> "\n" +
<add> "export default {\n" +
<add> " name: 'foo',\n" +
<add> " initialize\n" +
<add> "};");
<add> }));
<ide> });
<ide>
<ide> it('instance-initializer foo/bar --pod', function() {
<del> return generateAndDestroy(['instance-initializer', 'foo/bar', '--pod'], {
<del> files: [
<del> {
<del> file: 'app/instance-initializers/foo/bar.js',
<del> contains: "export function initialize(/* appInstance */) {\n" +
<del> " // appInstance.inject('route', 'foo', 'service:foo');\n" +
<del> "}\n" +
<del> "\n"+
<del> "export default {\n" +
<del> " name: 'foo/bar',\n" +
<del> " initialize\n" +
<del> "};"
<del> }
<del> ]
<del> });
<add> var args = ['instance-initializer', 'foo/bar', '--pod'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/instance-initializers/foo/bar.js'))
<add> .to.contain("export function initialize(/* appInstance */) {\n" +
<add> " // appInstance.inject('route', 'foo', 'service:foo');\n" +
<add> "}\n" +
<add> "\n" +
<add> "export default {\n" +
<add> " name: 'foo/bar',\n" +
<add> " initialize\n" +
<add> "};");
<add> }));
<ide> });
<ide>
<ide>
<ide> it('instance-initializer foo/bar --pod podModulePrefix', function() {
<del> return generateAndDestroy(['instance-initializer', 'foo/bar', '--pod'], {
<del> podModulePrefix: true,
<del> files: [
<del> {
<del> file: 'app/instance-initializers/foo/bar.js',
<del> contains: "export function initialize(/* appInstance */) {\n" +
<del> " // appInstance.inject('route', 'foo', 'service:foo');\n" +
<del> "}\n" +
<del> "\n"+
<del> "export default {\n" +
<del> " name: 'foo/bar',\n" +
<del> " initialize\n" +
<del> "};"
<del> }
<del> ]
<del> });
<add> var args = ['instance-initializer', 'foo/bar', '--pod'];
<add>
<add> return emberNew()
<add> .then(() => setupPodConfig({ podModulePrefix: true }))
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/instance-initializers/foo/bar.js'))
<add> .to.contain("export function initialize(/* appInstance */) {\n" +
<add> " // appInstance.inject('route', 'foo', 'service:foo');\n" +
<add> "}\n" +
<add> "\n" +
<add> "export default {\n" +
<add> " name: 'foo/bar',\n" +
<add> " initialize\n" +
<add> "};");
<add> }));
<ide> });
<ide>
<ide>
<ide> it('instance-initializer-test foo', function() {
<del> return generateAndDestroy(['instance-initializer-test', 'foo'], {
<del> files: [
<del> {
<del> file: 'tests/unit/instance-initializers/foo-test.js',
<del> contains: [
<del> "import { initialize } from 'my-app/instance-initializers/foo';",
<del> "module('Unit | Instance Initializer | foo'",
<del> "application = Ember.Application.create();",
<del> "this.appInstance = this.application.buildInstance();",
<del> "initialize(this.appInstance);"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['instance-initializer-test', 'foo'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/unit/instance-initializers/foo-test.js'))
<add> .to.contain("import { initialize } from 'my-app/instance-initializers/foo';")
<add> .to.contain("module('Unit | Instance Initializer | foo'")
<add> .to.contain("application = Ember.Application.create();")
<add> .to.contain("this.appInstance = this.application.buildInstance();")
<add> .to.contain("initialize(this.appInstance);");
<add> }));
<ide> });
<ide>
<ide> it('in-addon instance-initializer-test foo', function() {
<del> return generateAndDestroy(['instance-initializer-test', 'foo'], {
<del> target: 'addon',
<del> files: [
<del> {
<del> file: 'tests/unit/instance-initializers/foo-test.js',
<del> contains: [
<del> "import { initialize } from 'dummy/instance-initializers/foo';",
<del> "module('Unit | Instance Initializer | foo'",
<del> "application = Ember.Application.create();",
<del> "this.appInstance = this.application.buildInstance();",
<del> "initialize(this.appInstance);"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['instance-initializer-test', 'foo'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/unit/instance-initializers/foo-test.js'))
<add> .to.contain("import { initialize } from 'dummy/instance-initializers/foo';")
<add> .to.contain("module('Unit | Instance Initializer | foo'")
<add> .to.contain("application = Ember.Application.create();")
<add> .to.contain("this.appInstance = this.application.buildInstance();")
<add> .to.contain("initialize(this.appInstance);");
<add> }));
<ide> });
<ide>
<ide> it('instance-initializer-test foo for mocha', function() {
<del> return generateAndDestroy(['instance-initializer-test', 'foo'], {
<del> packages: [
<del> { name: 'ember-cli-qunit', delete: true },
<del> { name: 'ember-cli-mocha', dev: true }
<del> ],
<del> files: [
<del> {
<del> file: 'tests/unit/instance-initializers/foo-test.js',
<del> contains: [
<del> "import { initialize } from 'my-app/instance-initializers/foo';",
<del> "describe('Unit | Instance Initializer | foo', function() {",
<del> "application = Ember.Application.create();",
<del> "appInstance = application.buildInstance();",
<del> "initialize(appInstance);"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['instance-initializer-test', 'foo'];
<add>
<add> return emberNew()
<add> .then(() => modifyPackages([
<add> {name: 'ember-cli-qunit', delete: true},
<add> {name: 'ember-cli-mocha', dev: true}
<add> ]))
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/unit/instance-initializers/foo-test.js'))
<add> .to.contain("import { initialize } from 'my-app/instance-initializers/foo';")
<add> .to.contain("describe('Unit | Instance Initializer | foo', function() {")
<add> .to.contain("application = Ember.Application.create();")
<add> .to.contain("appInstance = application.buildInstance();")
<add> .to.contain("initialize(appInstance);");
<add> }));
<ide> });
<ide> });
<ide><path>node-tests/blueprints/mixin-test.js
<ide> 'use strict';
<ide>
<del>var setupTestHooks = require('ember-cli-blueprint-test-helpers/lib/helpers/setup');
<del>var BlueprintHelpers = require('ember-cli-blueprint-test-helpers/lib/helpers/blueprint-helper');
<del>var generateAndDestroy = BlueprintHelpers.generateAndDestroy;
<add>var blueprintHelpers = require('ember-cli-blueprint-test-helpers/helpers');
<add>var setupTestHooks = blueprintHelpers.setupTestHooks;
<add>var emberNew = blueprintHelpers.emberNew;
<add>var emberGenerateDestroy = blueprintHelpers.emberGenerateDestroy;
<add>var modifyPackages = blueprintHelpers.modifyPackages;
<add>var setupPodConfig = blueprintHelpers.setupPodConfig;
<add>
<add>var chai = require('ember-cli-blueprint-test-helpers/chai');
<add>var expect = chai.expect;
<ide>
<ide> describe('Acceptance: ember generate and destroy mixin', function() {
<ide> setupTestHooks(this);
<ide>
<ide> it('mixin foo', function() {
<del> return generateAndDestroy(['mixin', 'foo'], {
<del> files: [
<del> {
<del> file: 'app/mixins/foo.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> 'export default Ember.Mixin.create({\n});'
<del> ]
<del> },
<del> {
<del> file: 'tests/unit/mixins/foo-test.js',
<del> contains: [
<del> "import FooMixin from 'my-app/mixins/foo';"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['mixin', 'foo'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/mixins/foo.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain('export default Ember.Mixin.create({\n});');
<add>
<add> expect(_file('tests/unit/mixins/foo-test.js'))
<add> .to.contain("import FooMixin from 'my-app/mixins/foo';");
<add> }));
<ide> });
<ide>
<ide> it('mixin foo/bar', function() {
<del> return generateAndDestroy(['mixin', 'foo/bar'], {
<del> files: [
<del> {
<del> file: 'app/mixins/foo/bar.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> 'export default Ember.Mixin.create({\n});'
<del> ]
<del> },
<del> {
<del> file: 'tests/unit/mixins/foo/bar-test.js',
<del> contains: [
<del> "import FooBarMixin from 'my-app/mixins/foo/bar';"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['mixin', 'foo/bar'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/mixins/foo/bar.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain('export default Ember.Mixin.create({\n});');
<add>
<add> expect(_file('tests/unit/mixins/foo/bar-test.js'))
<add> .to.contain("import FooBarMixin from 'my-app/mixins/foo/bar';");
<add> }));
<ide> });
<ide>
<ide> it('mixin foo/bar/baz', function() {
<del> return generateAndDestroy(['mixin', 'foo/bar/baz'], {
<del> files: [
<del> {
<del> file: 'tests/unit/mixins/foo/bar/baz-test.js',
<del> contains: [
<del> "import FooBarBazMixin from 'my-app/mixins/foo/bar/baz';"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['mixin', 'foo/bar/baz'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/unit/mixins/foo/bar/baz-test.js'))
<add> .to.contain("import FooBarBazMixin from 'my-app/mixins/foo/bar/baz';");
<add> }));
<ide> });
<ide>
<ide> it('in-addon mixin foo', function() {
<del> return generateAndDestroy(['mixin', 'foo'], {
<del> target: 'addon',
<del> files: [
<del> {
<del> file: 'addon/mixins/foo.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> 'export default Ember.Mixin.create({\n});'
<del> ]
<del> },
<del> {
<del> file: 'tests/unit/mixins/foo-test.js',
<del> contains: [
<del> "import FooMixin from 'my-addon/mixins/foo';"
<del> ]
<del> },
<del> {
<del> file: 'app/mixins/foo.js',
<del> exists: false
<del> }
<del> ]
<del> });
<add> var args = ['mixin', 'foo'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('addon/mixins/foo.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain('export default Ember.Mixin.create({\n});');
<add>
<add> expect(_file('tests/unit/mixins/foo-test.js'))
<add> .to.contain("import FooMixin from 'my-addon/mixins/foo';");
<add>
<add> expect(_file('app/mixins/foo.js'))
<add> .to.not.exist;
<add> }));
<ide> });
<ide>
<ide> it('in-addon mixin foo/bar', function() {
<del> return generateAndDestroy(['mixin', 'foo/bar'], {
<del> target: 'addon',
<del> files: [
<del> {
<del> file: 'addon/mixins/foo/bar.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> 'export default Ember.Mixin.create({\n});'
<del> ]
<del> },
<del> {
<del> file: 'tests/unit/mixins/foo/bar-test.js',
<del> contains: [
<del> "import FooBarMixin from 'my-addon/mixins/foo/bar';"
<del> ]
<del> },
<del> {
<del> file: 'app/mixins/foo/bar.js',
<del> exists: false
<del> }
<del> ]
<del> });
<add> var args = ['mixin', 'foo/bar'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('addon/mixins/foo/bar.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain('export default Ember.Mixin.create({\n});');
<add>
<add> expect(_file('tests/unit/mixins/foo/bar-test.js'))
<add> .to.contain("import FooBarMixin from 'my-addon/mixins/foo/bar';");
<add>
<add> expect(_file('app/mixins/foo/bar.js'))
<add> .to.not.exist;
<add> }));
<ide> });
<ide>
<ide> it('in-addon mixin foo/bar/baz', function() {
<del> return generateAndDestroy(['mixin', 'foo/bar/baz'], {
<del> target: 'addon',
<del> files: [
<del> {
<del> file: 'addon/mixins/foo/bar/baz.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> 'export default Ember.Mixin.create({\n});'
<del> ]
<del> },
<del> {
<del> file: 'tests/unit/mixins/foo/bar/baz-test.js',
<del> contains: [
<del> "import FooBarBazMixin from 'my-addon/mixins/foo/bar/baz';"
<del> ]
<del> },
<del> {
<del> file: 'app/mixins/foo/bar/baz.js',
<del> exists: false
<del> }
<del> ]
<del> });
<del> })
<add> var args = ['mixin', 'foo/bar/baz'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('addon/mixins/foo/bar/baz.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain('export default Ember.Mixin.create({\n});');
<add>
<add> expect(_file('tests/unit/mixins/foo/bar/baz-test.js'))
<add> .to.contain("import FooBarBazMixin from 'my-addon/mixins/foo/bar/baz';");
<add>
<add> expect(_file('app/mixins/foo/bar/baz.js'))
<add> .to.not.exist;
<add> }));
<add> });
<ide>
<ide> it('in-repo-addon mixin foo', function() {
<del> return generateAndDestroy(['mixin', 'foo', '--in-repo-addon=my-addon'], {
<del> target: 'inRepoAddon',
<del> files: [
<del> {
<del> file: 'lib/my-addon/addon/mixins/foo.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> 'export default Ember.Mixin.create({\n});'
<del> ]
<del> },
<del> {
<del> file: 'tests/unit/mixins/foo-test.js',
<del> contains: [
<del> "import FooMixin from 'my-addon/mixins/foo';"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['mixin', 'foo', '--in-repo-addon=my-addon'];
<add>
<add> return emberNew({ target: 'in-repo-addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('lib/my-addon/addon/mixins/foo.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain('export default Ember.Mixin.create({\n});');
<add>
<add> expect(_file('tests/unit/mixins/foo-test.js'))
<add> .to.contain("import FooMixin from 'my-addon/mixins/foo';");
<add> }));
<ide> });
<ide>
<ide> it('in-repo-addon mixin foo/bar', function() {
<del> return generateAndDestroy(['mixin', 'foo/bar', '--in-repo-addon=my-addon'], {
<del> target: 'inRepoAddon',
<del> files: [
<del> {
<del> file: 'lib/my-addon/addon/mixins/foo/bar.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> 'export default Ember.Mixin.create({\n});'
<del> ]
<del> },
<del> {
<del> file: 'tests/unit/mixins/foo/bar-test.js',
<del> contains: [
<del> "import FooBarMixin from 'my-addon/mixins/foo/bar';"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['mixin', 'foo/bar', '--in-repo-addon=my-addon'];
<add>
<add> return emberNew({ target: 'in-repo-addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('lib/my-addon/addon/mixins/foo/bar.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain('export default Ember.Mixin.create({\n});');
<add>
<add> expect(_file('tests/unit/mixins/foo/bar-test.js'))
<add> .to.contain("import FooBarMixin from 'my-addon/mixins/foo/bar';");
<add> }));
<ide> });
<ide>
<ide> it('in-repo-addon mixin foo/bar/baz', function() {
<del> return generateAndDestroy(['mixin', 'foo/bar/baz', '--in-repo-addon=my-addon'], {
<del> target: 'inRepoAddon',
<del> files: [
<del> {
<del> file: 'tests/unit/mixins/foo/bar/baz-test.js',
<del> contains: [
<del> "import FooBarBazMixin from 'my-addon/mixins/foo/bar/baz';"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['mixin', 'foo/bar/baz', '--in-repo-addon=my-addon'];
<add>
<add> return emberNew({ target: 'in-repo-addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/unit/mixins/foo/bar/baz-test.js'))
<add> .to.contain("import FooBarBazMixin from 'my-addon/mixins/foo/bar/baz';");
<add> }));
<ide> });
<ide>
<ide> /* Pod tests */
<ide>
<ide> it('mixin foo --pod', function() {
<del> return generateAndDestroy(['mixin', 'foo', '--pod'], {
<del> files: [
<del> {
<del> file: 'app/mixins/foo.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> 'export default Ember.Mixin.create({\n});'
<del> ]
<del> },
<del> {
<del> file: 'tests/unit/mixins/foo-test.js',
<del> contains: [
<del> "import FooMixin from 'my-app/mixins/foo';"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['mixin', 'foo', '--pod'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/mixins/foo.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain('export default Ember.Mixin.create({\n});');
<add>
<add> expect(_file('tests/unit/mixins/foo-test.js'))
<add> .to.contain("import FooMixin from 'my-app/mixins/foo';");
<add> }));
<ide> });
<ide>
<ide> it('mixin foo --pod podModulePrefix', function() {
<del> return generateAndDestroy(['mixin', 'foo', '--pod'], {
<del> podModulePrefix: true,
<del> files: [
<del> {
<del> file: 'app/mixins/foo.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> 'export default Ember.Mixin.create({\n});'
<del> ]
<del> },
<del> {
<del> file: 'tests/unit/mixins/foo-test.js',
<del> contains: [
<del> "import FooMixin from 'my-app/mixins/foo';"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['mixin', 'foo', '--pod'];
<add>
<add> return emberNew()
<add> .then(() => setupPodConfig({ podModulePrefix: true }))
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/mixins/foo.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain('export default Ember.Mixin.create({\n});');
<add>
<add> expect(_file('tests/unit/mixins/foo-test.js'))
<add> .to.contain("import FooMixin from 'my-app/mixins/foo';");
<add> }));
<ide> });
<ide>
<ide> it('mixin foo/bar --pod', function() {
<del> return generateAndDestroy(['mixin', 'foo/bar', '--pod'], {
<del> files: [
<del> {
<del> file: 'app/mixins/foo/bar.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> 'export default Ember.Mixin.create({\n});'
<del> ]
<del> },
<del> {
<del> file: 'tests/unit/mixins/foo/bar-test.js',
<del> contains: [
<del> "import FooBarMixin from 'my-app/mixins/foo/bar';"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['mixin', 'foo/bar', '--pod'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/mixins/foo/bar.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain('export default Ember.Mixin.create({\n});');
<add>
<add> expect(_file('tests/unit/mixins/foo/bar-test.js'))
<add> .to.contain("import FooBarMixin from 'my-app/mixins/foo/bar';");
<add> }));
<ide> });
<ide>
<ide> it('mixin foo/bar --pod podModulePrefix', function() {
<del> return generateAndDestroy(['mixin', 'foo/bar', '--pod'], {
<del> podModulePrefix: true,
<del> files: [
<del> {
<del> file: 'app/mixins/foo/bar.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> 'export default Ember.Mixin.create({\n});'
<del> ]
<del> },
<del> {
<del> file: 'tests/unit/mixins/foo/bar-test.js',
<del> contains: [
<del> "import FooBarMixin from 'my-app/mixins/foo/bar';"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['mixin', 'foo/bar', '--pod'];
<add>
<add> return emberNew()
<add> .then(() => setupPodConfig({ podModulePrefix: true }))
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/mixins/foo/bar.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain('export default Ember.Mixin.create({\n});');
<add>
<add> expect(_file('tests/unit/mixins/foo/bar-test.js'))
<add> .to.contain("import FooBarMixin from 'my-app/mixins/foo/bar';");
<add> }));
<ide> });
<ide>
<ide> it('mixin foo/bar/baz --pod', function() {
<del> return generateAndDestroy(['mixin', 'foo/bar/baz', '--pod'], {
<del> files: [
<del> {
<del> file: 'tests/unit/mixins/foo/bar/baz-test.js',
<del> contains: [
<del> "import FooBarBazMixin from 'my-app/mixins/foo/bar/baz';"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['mixin', 'foo/bar/baz', '--pod'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/unit/mixins/foo/bar/baz-test.js'))
<add> .to.contain("import FooBarBazMixin from 'my-app/mixins/foo/bar/baz';");
<add> }));
<ide> });
<ide>
<ide> it('mixin-test foo', function() {
<del> return generateAndDestroy(['mixin-test', 'foo'], {
<del> files: [
<del> {
<del> file: 'tests/unit/mixins/foo-test.js',
<del> contains: [
<del> "import FooMixin from 'my-app/mixins/foo';"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['mixin-test', 'foo'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/unit/mixins/foo-test.js'))
<add> .to.contain("import FooMixin from 'my-app/mixins/foo';");
<add> }));
<ide> });
<ide>
<ide> it('in-addon mixin-test foo', function() {
<del> return generateAndDestroy(['mixin-test', 'foo'], {
<del> target: 'addon',
<del> files: [
<del> {
<del> file: 'tests/unit/mixins/foo-test.js',
<del> contains: [
<del> "import FooMixin from 'my-addon/mixins/foo';"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['mixin-test', 'foo'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/unit/mixins/foo-test.js'))
<add> .to.contain("import FooMixin from 'my-addon/mixins/foo';");
<add> }));
<ide> });
<ide>
<ide> it('mixin-test foo for mocha', function() {
<del> return generateAndDestroy(['mixin-test', 'foo'], {
<del> packages: [
<del> { name: 'ember-cli-qunit', delete: true },
<del> { name: 'ember-cli-mocha', dev: true }
<del> ],
<del> files: [
<del> {
<del> file: 'tests/unit/mixins/foo-test.js',
<del> contains: [
<del> "import { describe, it } from 'mocha';",
<del> "import FooMixin from 'my-app/mixins/foo';",
<del> "describe('Unit | Mixin | foo', function() {"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['mixin-test', 'foo'];
<add>
<add> return emberNew()
<add> .then(() => modifyPackages([
<add> {name: 'ember-cli-qunit', delete: true},
<add> {name: 'ember-cli-mocha', dev: true}
<add> ]))
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/unit/mixins/foo-test.js'))
<add> .to.contain("import { describe, it } from 'mocha';")
<add> .to.contain("import FooMixin from 'my-app/mixins/foo';")
<add> .to.contain("describe('Unit | Mixin | foo', function() {");
<add> }));
<ide> });
<ide> });
<ide><path>node-tests/blueprints/route-addon-test.js
<ide> 'use strict';
<ide>
<del>var setupTestHooks = require('ember-cli-blueprint-test-helpers/lib/helpers/setup');
<del>var BlueprintHelpers = require('ember-cli-blueprint-test-helpers/lib/helpers/blueprint-helper');
<del>var generateAndDestroy = BlueprintHelpers.generateAndDestroy;
<add>var blueprintHelpers = require('ember-cli-blueprint-test-helpers/helpers');
<add>var setupTestHooks = blueprintHelpers.setupTestHooks;
<add>var emberNew = blueprintHelpers.emberNew;
<add>var emberGenerateDestroy = blueprintHelpers.emberGenerateDestroy;
<add>
<add>var chai = require('ember-cli-blueprint-test-helpers/chai');
<add>var expect = chai.expect;
<ide>
<ide> describe('Acceptance: ember generate and destroy route-addon', function() {
<ide> setupTestHooks(this);
<ide>
<ide> it('route-addon foo', function() {
<del> return generateAndDestroy(['route-addon', 'foo'], {
<del> target: 'addon',
<del> files: [
<del> {
<del> file: 'app/routes/foo.js',
<del> contains: [
<del> "export { default } from 'my-addon/routes/foo';"
<del> ]
<del> },
<del> {
<del> file: 'app/templates/foo.js',
<del> contains: [
<del> "export { default } from 'my-addon/templates/foo';"
<del> ]
<del> },
<del> ]
<del> });
<del> });
<add> var args = ['route-addon', 'foo'];
<ide>
<add> return emberNew({ target: 'addon' }).then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/routes/foo.js'))
<add> .to.contain("export { default } from 'my-addon/routes/foo';");
<add>
<add> expect(_file('app/templates/foo.js'))
<add> .to.contain("export { default } from 'my-addon/templates/foo';");
<add> }));
<add> });
<ide> });
<ide><path>node-tests/blueprints/route-test.js
<ide> var fs = require('fs-extra');
<ide> var path = require('path');
<ide> var RSVP = require('rsvp');
<ide> var remove = RSVP.denodeify(fs.remove);
<del>var setupTestHooks = require('ember-cli-blueprint-test-helpers/lib/helpers/setup');
<del>var initProject = require('ember-cli-blueprint-test-helpers/lib/helpers/project-init');
<del>var BlueprintHelpers = require('ember-cli-blueprint-test-helpers/lib/helpers/blueprint-helper');
<del>var generateAndDestroy = BlueprintHelpers.generateAndDestroy;
<del>var destroy = BlueprintHelpers.destroy;
<ide>
<add>var blueprintHelpers = require('ember-cli-blueprint-test-helpers/helpers');
<add>var setupTestHooks = blueprintHelpers.setupTestHooks;
<add>var emberNew = blueprintHelpers.emberNew;
<add>var emberGenerate = blueprintHelpers.emberGenerate;
<add>var emberDestroy = blueprintHelpers.emberDestroy;
<add>var emberGenerateDestroy = blueprintHelpers.emberGenerateDestroy;
<add>var modifyPackages = blueprintHelpers.modifyPackages;
<add>var setupPodConfig = blueprintHelpers.setupPodConfig;
<add>
<add>var chai = require('ember-cli-blueprint-test-helpers/chai');
<add>var expect = chai.expect;
<add>var file = chai.file;
<ide>
<ide> describe('Acceptance: ember generate and destroy route', function() {
<ide> setupTestHooks(this);
<ide>
<ide> it('route foo', function() {
<del> var files = [
<del> {
<del> file: 'app/router.js',
<del> contains: 'this.route(\'foo\')'
<del> },
<del> {
<del> file: 'app/routes/foo.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "export default Ember.Route.extend({\n});"
<del> ]
<del> },
<del> {
<del> file: 'app/templates/foo.hbs',
<del> contains: '{{outlet}}'
<del> },
<del> {
<del> file: 'tests/unit/routes/foo-test.js',
<del> contains: [
<del> "import { moduleFor, test } from 'ember-qunit';",
<del> "moduleFor('route:foo'"
<del> ]
<del> }
<del> ];
<del>
<del> return generateAndDestroy(['route', 'foo'], {
<del> afterDestroy: function() {
<del> // remove `app/router.js` to work around https://github.com/ember-cli/ember-cli-blueprint-test-helpers/issues/38
<del> files.shift();
<del> },
<del> files: files,
<del> });
<add> var args = ['route', 'foo'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, (_file) => {
<add> expect(_file('app/routes/foo.js'))
<add> .to.contain('import Ember from \'ember\';')
<add> .to.contain('export default Ember.Route.extend({\n});');
<add>
<add> expect(_file('app/templates/foo.hbs'))
<add> .to.contain('{{outlet}}');
<add>
<add> expect(_file('tests/unit/routes/foo-test.js'))
<add> .to.contain('import { moduleFor, test } from \'ember-qunit\';')
<add> .to.contain('moduleFor(\'route:foo\'');
<add>
<add> expect(file('app/router.js'))
<add> .to.contain('this.route(\'foo\')');
<add> }))
<add> .then(() => expect(file('app/router.js'))
<add> .to.not.contain('this.route(\'foo\')'));
<ide> });
<ide>
<ide> it('route foo with --skip-router', function() {
<del> var files = [
<del> {
<del> file: 'app/router.js',
<del> doesNotContain: 'this.route(\'foo\')'
<del> },
<del> {
<del> file: 'app/routes/foo.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "export default Ember.Route.extend({\n});"
<del> ]
<del> },
<del> {
<del> file: 'app/templates/foo.hbs',
<del> contains: '{{outlet}}'
<del> },
<del> {
<del> file: 'tests/unit/routes/foo-test.js',
<del> contains: [
<del> "import { moduleFor, test } from 'ember-qunit';",
<del> "moduleFor('route:foo'"
<del> ]
<del> }
<del> ];
<del>
<del> return generateAndDestroy(['route', 'foo', '--skip-router'], {
<del> afterDestroy: function() {
<del> // remove `app/router.js` to work around https://github.com/ember-cli/ember-cli-blueprint-test-helpers/issues/38
<del> files.shift();
<del> },
<del> files: files,
<del> });
<add> var args = ['route', 'foo', '--skip-router'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, (_file) => {
<add> expect(_file('app/routes/foo.js')).to.exist;
<add> expect(_file('app/templates/foo.hbs')).to.exist;
<add> expect(_file('tests/unit/routes/foo-test.js')).to.exist;
<add> expect(file('app/router.js')).to.not.contain('this.route(\'foo\')');
<add> }))
<add> .then(() => expect(file('app/router.js')).to.not.contain('this.route(\'foo\')'));
<ide> });
<ide>
<ide> it('route foo with --path', function() {
<del> var files = [
<del> {
<del> file: 'app/router.js',
<del> contains: [
<del> 'this.route(\'foo\', {',
<del> 'path: \':foo_id/show\'',
<del> '});'
<del> ]
<del> }
<del> ];
<del>
<del> return generateAndDestroy(['route', 'foo', '--path=:foo_id/show'], {
<del> afterDestroy: function() {
<del> // remove `app/router.js` to work around https://github.com/ember-cli/ember-cli-blueprint-test-helpers/issues/38
<del> files.shift();
<del> },
<del> files: files,
<del> });
<add> var args = ['route', 'foo', '--path=:foo_id/show'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, (_file) => {
<add> expect(_file('app/routes/foo.js'))
<add> .to.contain('import Ember from \'ember\';')
<add> .to.contain('export default Ember.Route.extend({\n});');
<add>
<add> expect(_file('app/templates/foo.hbs'))
<add> .to.contain('{{outlet}}');
<add>
<add> expect(_file('tests/unit/routes/foo-test.js'))
<add> .to.contain('import { moduleFor, test } from \'ember-qunit\';')
<add> .to.contain('moduleFor(\'route:foo\'');
<add>
<add> expect(file('app/router.js'))
<add> .to.contain('this.route(\'foo\', {')
<add> .to.contain('path: \':foo_id/show\'')
<add> .to.contain('});');
<add> }))
<add> .then(() => expect(file('app/router.js'))
<add> .to.not.contain('this.route(\'foo\'')
<add> .to.not.contain('path: \':foo_id/show\''));
<ide> });
<ide>
<ide> it('route index', function() {
<del> var files = [
<del> {
<del> file: 'app/router.js',
<del> doesNotContain: "this.route('index');"
<del> }
<del> ];
<del>
<del> return generateAndDestroy(['route', 'index'], {
<del> afterDestroy: function() {
<del> // remove `app/router.js` to work around https://github.com/ember-cli/ember-cli-blueprint-test-helpers/issues/38
<del> files.shift();
<del> },
<del> files: files,
<del> });
<add> var args = ['route', 'index'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, (_file) => {
<add> expect(_file('app/routes/index.js')).to.exist;
<add> expect(_file('app/templates/index.hbs')).to.exist;
<add> expect(_file('tests/unit/routes/index-test.js')).to.exist;
<add> expect(file('app/router.js')).to.not.contain('this.route(\'index\')');
<add> }))
<add> .then(() => expect(file('app/router.js')).to.not.contain('this.route(\'index\')'));
<ide> });
<ide>
<ide> it('route application', function() {
<del> return generateAndDestroy(['route', 'foo'], {
<del> afterGenerate: function(){
<del> return remove(path.join('app', 'templates', 'application.hbs'))
<del> .then(function() {
<del> var files = [
<del> {
<del> file: 'app/router.js',
<del> doesNotContain: "this.route('application');"
<del> }
<del> ];
<del>
<del> return generateAndDestroy(['route', 'application'], {
<del> skipInit: true,
<del> afterDestroy: function() {
<del> // remove `app/router.js` to work around https://github.com/ember-cli/ember-cli-blueprint-test-helpers/issues/38
<del> files.shift();
<del> },
<del> files: files,
<del> });
<del> });
<del> }
<del> });
<add> var args = ['route', 'application'];
<add>
<add> return emberNew()
<add> .then(() => remove(path.resolve('app/templates/application.hbs')))
<add> .then(() => emberGenerate(args))
<add> .then(() => expect(file('app/router.js')).to.not.contain('this.route(\'application\')'));
<ide> });
<ide>
<ide> it('route basic isn\'t added to router', function() {
<del> var files = [
<del> {
<del> file: 'app/router.js',
<del> doesNotContain: "this.route('basic');"
<del> },
<del> {
<del> file: 'app/routes/basic.js'
<del> }
<del> ];
<del>
<del> return generateAndDestroy(['route', 'basic'], {
<del> afterDestroy: function() {
<del> // remove `app/router.js` to work around https://github.com/ember-cli/ember-cli-blueprint-test-helpers/issues/38
<del> files.shift();
<del> },
<del> files: files,
<del> });
<add> var args = ['route', 'basic'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, (_file) => {
<add> expect(_file('app/routes/basic.js')).to.exist;
<add> expect(file('app/router.js')).to.not.contain('this.route(\'basic\')');
<add> }))
<add> .then(() => expect(file('app/router.js')).to.not.contain('this.route(\'basic\')'));
<ide> });
<ide>
<ide> it('in-addon route foo', function() {
<del> var files = [
<del> {
<del> file: 'addon/routes/foo.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "export default Ember.Route.extend({\n});"
<del> ]
<del> },
<del> {
<del> file: 'app/routes/foo.js',
<del> contains: [
<del> "export { default } from 'my-addon/routes/foo';"
<del> ]
<del> },
<del> {
<del> file: 'addon/templates/foo.hbs',
<del> contains: '{{outlet}}'
<del> },
<del> {
<del> file: 'app/templates/foo.js',
<del> contains: "export { default } from 'my-addon/templates/foo';"
<del> },
<del> {
<del> file: 'tests/unit/routes/foo-test.js',
<del> contains: [
<del> "import { moduleFor, test } from 'ember-qunit';",
<del> "moduleFor('route:foo'"
<del> ]
<del> },
<del> {
<del> file: 'tests/dummy/app/router.js',
<del> doesNotContain: "this.route('foo');"
<del> }
<del> ];
<del>
<del> return generateAndDestroy(['route', 'foo'], {
<del> target: 'addon',
<del> afterDestroy: function() {
<del> // remove `app/router.js` to work around https://github.com/ember-cli/ember-cli-blueprint-test-helpers/issues/38
<del> files.pop();
<del> },
<del> files: files,
<del> });
<add> var args = ['route', 'foo'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, (_file) => {
<add> expect(_file('addon/routes/foo.js'))
<add> .to.contain('import Ember from \'ember\';')
<add> .to.contain('export default Ember.Route.extend({\n});');
<add>
<add> expect(_file('addon/templates/foo.hbs'))
<add> .to.contain('{{outlet}}');
<add>
<add> expect(_file('app/routes/foo.js'))
<add> .to.contain('export { default } from \'my-addon/routes/foo\';');
<add>
<add> expect(_file('app/templates/foo.js'))
<add> .to.contain('export { default } from \'my-addon/templates/foo\';');
<add>
<add> expect(_file('tests/unit/routes/foo-test.js'))
<add> .to.contain('import { moduleFor, test } from \'ember-qunit\';')
<add> .to.contain('moduleFor(\'route:foo\'');
<add>
<add> expect(file('tests/dummy/app/router.js'))
<add> .to.not.contain('this.route(\'foo\')');
<add> }))
<add> .then(() => expect(file('tests/dummy/app/router.js'))
<add> .to.not.contain('this.route(\'foo\')'));
<ide> });
<ide>
<ide> it('in-addon route foo/bar', function() {
<del> var files = [
<del> {
<del> file: 'addon/routes/foo/bar.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "export default Ember.Route.extend({\n});"
<del> ]
<del> },
<del> {
<del> file: 'app/routes/foo/bar.js',
<del> contains: "export { default } from 'my-addon/routes/foo/bar';"
<del> },
<del> {
<del> file: 'app/templates/foo/bar.js',
<del> contains: "export { default } from 'my-addon/templates/foo/bar';"
<del> },
<del> {
<del> file: 'tests/unit/routes/foo/bar-test.js',
<del> contains: [
<del> "import { moduleFor, test } from 'ember-qunit';",
<del> "moduleFor('route:foo/bar'"
<del> ]
<del> },
<del> {
<del> file: 'tests/dummy/app/router.js',
<del> doesNotContain: "this.route('bar');"
<del> }
<del> ];
<del>
<del> return generateAndDestroy(['route', 'foo/bar'], {
<del> target: 'addon',
<del> afterDestroy: function() {
<del> // remove `app/router.js` to work around https://github.com/ember-cli/ember-cli-blueprint-test-helpers/issues/38
<del> files.pop();
<del> },
<del> files: files,
<del> });
<add> var args = ['route', 'foo/bar'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, (_file) => {
<add> expect(_file('addon/routes/foo/bar.js'))
<add> .to.contain('import Ember from \'ember\';')
<add> .to.contain('export default Ember.Route.extend({\n});');
<add>
<add> expect(_file('addon/templates/foo/bar.hbs'))
<add> .to.contain('{{outlet}}');
<add>
<add> expect(_file('app/routes/foo/bar.js'))
<add> .to.contain('export { default } from \'my-addon/routes/foo/bar\';');
<add>
<add> expect(_file('app/templates/foo/bar.js'))
<add> .to.contain('export { default } from \'my-addon/templates/foo/bar\';');
<add>
<add> expect(_file('tests/unit/routes/foo/bar-test.js'))
<add> .to.contain('import { moduleFor, test } from \'ember-qunit\';')
<add> .to.contain('moduleFor(\'route:foo/bar\'');
<add>
<add> expect(file('tests/dummy/app/router.js'))
<add> .to.not.contain('this.route(\'bar\')');
<add> }))
<add> .then(() => expect(file('tests/dummy/app/router.js'))
<add> .to.not.contain('this.route(\'bar\')'));
<ide> });
<ide>
<ide> it('dummy route foo', function() {
<del> var files = [
<del> {
<del> file: 'tests/dummy/app/router.js',
<del> contains: "this.route('foo');"
<del> },
<del> {
<del> file: 'tests/dummy/app/routes/foo.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "export default Ember.Route.extend({\n});"
<del> ]
<del> },
<del> {
<del> file: 'app/routes/foo.js',
<del> exists: false
<del> },
<del> {
<del> file: 'tests/dummy/app/templates/foo.hbs',
<del> contains: '{{outlet}}'
<del> },
<del> {
<del> file: 'app/templates/foo.js',
<del> exists: false
<del> },
<del> {
<del> file: 'tests/unit/routes/foo-test.js',
<del> exists: false
<del> }
<del> ];
<del>
<del> return generateAndDestroy(['route', 'foo', '--dummy'], {
<del> target: 'addon',
<del> afterDestroy: function() {
<del> // remove `app/router.js` to work around https://github.com/ember-cli/ember-cli-blueprint-test-helpers/issues/38
<del> files.shift();
<del> },
<del> files: files,
<del> });
<add> var args = ['route', 'foo', '--dummy'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, (_file) => {
<add> expect(_file('tests/dummy/app/routes/foo.js'))
<add> .to.contain('import Ember from \'ember\';')
<add> .to.contain('export default Ember.Route.extend({\n});');
<add>
<add> expect(_file('tests/dummy/app/templates/foo.hbs'))
<add> .to.contain('{{outlet}}');
<add>
<add> expect(_file('app/routes/foo.js')).to.not.exist;
<add> expect(_file('app/templates/foo.hbs')).to.not.exist;
<add> expect(_file('tests/unit/routes/foo-test.js')).to.not.exist;
<add>
<add> expect(file('tests/dummy/app/router.js'))
<add> .to.contain('this.route(\'foo\')');
<add> }))
<add> .then(() => expect(file('tests/dummy/app/router.js'))
<add> .to.not.contain('this.route(\'foo\')'));
<ide> });
<ide>
<ide> it('dummy route foo/bar', function() {
<del> var files = [
<del> {
<del> file: 'tests/dummy/app/router.js',
<del> contains: [
<del> "this.route('foo', function() {",
<del> "this.route('bar');",
<del> ]
<del> },
<del> {
<del> file: 'tests/dummy/app/routes/foo/bar.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "export default Ember.Route.extend({\n});"
<del> ]
<del> },
<del> {
<del> file: 'app/routes/foo/bar.js',
<del> exists: false
<del> },
<del> {
<del> file: 'tests/dummy/app/templates/foo/bar.hbs',
<del> contains: '{{outlet}}'
<del> },
<del> {
<del> file: 'tests/unit/routes/foo/bar-test.js',
<del> exists: false
<del> }
<del> ];
<del>
<del> return generateAndDestroy(['route', 'foo/bar', '--dummy'], {
<del> target: 'addon',
<del> afterDestroy: function() {
<del> // remove `app/router.js` to work around https://github.com/ember-cli/ember-cli-blueprint-test-helpers/issues/38
<del> files.shift();
<del> },
<del> files: files,
<del> });
<add> var args = ['route', 'foo/bar', '--dummy'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, (_file) => {
<add> expect(_file('tests/dummy/app/routes/foo/bar.js'))
<add> .to.contain('import Ember from \'ember\';')
<add> .to.contain('export default Ember.Route.extend({\n});');
<add>
<add> expect(_file('tests/dummy/app/templates/foo/bar.hbs'))
<add> .to.contain('{{outlet}}');
<add>
<add> expect(_file('app/routes/foo/bar.js')).to.not.exist;
<add> expect(_file('app/templates/foo/bar.hbs')).to.not.exist;
<add> expect(_file('tests/unit/routes/foo/bar-test.js')).to.not.exist;
<add>
<add> expect(file('tests/dummy/app/router.js'))
<add> .to.contain('this.route(\'foo\', function() {')
<add> .to.contain('this.route(\'bar\')');
<add> }))
<add> .then(() => expect(file('tests/dummy/app/router.js'))
<add> .to.not.contain('this.route(\'bar\')'));
<ide> });
<ide>
<ide> it('in-repo-addon route foo', function() {
<del> return generateAndDestroy(['route', 'foo', '--in-repo-addon=my-addon'], {
<del> target: 'inRepoAddon',
<del> files: [
<del> {
<del> file: 'lib/my-addon/addon/routes/foo.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "export default Ember.Route.extend({\n});"
<del> ]
<del> },
<del> {
<del> file: 'lib/my-addon/app/routes/foo.js',
<del> contains: "export { default } from 'my-addon/routes/foo';"
<del> },
<del> {
<del> file: 'lib/my-addon/addon/templates/foo.hbs',
<del> contains: '{{outlet}}'
<del> },
<del> {
<del> file: 'lib/my-addon/app/templates/foo.js',
<del> contains: "export { default } from 'my-addon/templates/foo';"
<del> },
<del> {
<del> file: 'tests/unit/routes/foo-test.js',
<del> contains: [
<del> "import { moduleFor, test } from 'ember-qunit';",
<del> "moduleFor('route:foo'"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['route', 'foo', '--in-repo-addon=my-addon'];
<add>
<add> return emberNew({ target: 'in-repo-addon' })
<add> .then(() => emberGenerateDestroy(args, (_file) => {
<add> expect(_file('lib/my-addon/addon/routes/foo.js'))
<add> .to.contain('import Ember from \'ember\';')
<add> .to.contain('export default Ember.Route.extend({\n});');
<add>
<add> expect(_file('lib/my-addon/addon/templates/foo.hbs'))
<add> .to.contain('{{outlet}}');
<add>
<add> expect(_file('lib/my-addon/app/routes/foo.js'))
<add> .to.contain('export { default } from \'my-addon/routes/foo\';');
<add>
<add> expect(_file('lib/my-addon/app/templates/foo.js'))
<add> .to.contain('export { default } from \'my-addon/templates/foo\';');
<add>
<add> expect(_file('tests/unit/routes/foo-test.js'))
<add> .to.contain('import { moduleFor, test } from \'ember-qunit\';')
<add> .to.contain('moduleFor(\'route:foo\'');
<add> }));
<ide> });
<ide>
<ide> it('in-repo-addon route foo/bar', function() {
<del> return generateAndDestroy(['route', 'foo/bar', '--in-repo-addon=my-addon'], {
<del> target: 'inRepoAddon',
<del> files: [
<del> {
<del> file: 'lib/my-addon/addon/routes/foo/bar.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "export default Ember.Route.extend({\n});"
<del> ]
<del> },
<del> {
<del> file: 'lib/my-addon/app/routes/foo/bar.js',
<del> contains: "export { default } from 'my-addon/routes/foo/bar';"
<del> },
<del> {
<del> file: 'lib/my-addon/addon/templates/foo/bar.hbs',
<del> contains: '{{outlet}}'
<del> },
<del> {
<del> file: 'lib/my-addon/app/templates/foo/bar.js',
<del> contains: "export { default } from 'my-addon/templates/foo/bar';"
<del> },
<del> {
<del> file: 'tests/unit/routes/foo/bar-test.js',
<del> contains: [
<del> "import { moduleFor, test } from 'ember-qunit';",
<del> "moduleFor('route:foo/bar'"
<del> ]
<del> }
<del> ]
<del> });
<del> });
<add> var args = ['route', 'foo/bar', '--in-repo-addon=my-addon'];
<ide>
<del>/**
<del>* Pod tests
<del>*
<del>*/
<add> return emberNew({ target: 'in-repo-addon' })
<add> .then(() => emberGenerateDestroy(args, (_file) => {
<add> expect(_file('lib/my-addon/addon/routes/foo/bar.js'))
<add> .to.contain('import Ember from \'ember\';')
<add> .to.contain('export default Ember.Route.extend({\n});');
<ide>
<del> it('in-addon route foo --pod', function() {
<del> return generateAndDestroy(['route', 'foo', '--pod'], {
<del> target: 'addon',
<del> files: [
<del> {
<del> file: 'addon/foo/route.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "export default Ember.Route.extend({\n});"
<del> ]
<del> },
<del> {
<del> file: 'addon/foo/template.hbs',
<del> contains: "{{outlet}}"
<del> },
<del> {
<del> file: 'app/foo/route.js',
<del> contains: [
<del> "export { default } from 'my-addon/foo/route';"
<del> ]
<del> },
<del> {
<del> file: 'app/foo/template.js',
<del> contains: [
<del> "export { default } from 'my-addon/foo/template';"
<del> ]
<del> },
<del> {
<del> file: 'tests/unit/foo/route-test.js',
<del> contains: [
<del> "import { moduleFor, test } from 'ember-qunit';",
<del> "moduleFor('route:foo'"
<del> ]
<del> }
<del> ]
<del> });
<del> });
<add> expect(_file('lib/my-addon/addon/templates/foo/bar.hbs'))
<add> .to.contain('{{outlet}}');
<add>
<add> expect(_file('lib/my-addon/app/routes/foo/bar.js'))
<add> .to.contain('export { default } from \'my-addon/routes/foo/bar\';');
<ide>
<add> expect(_file('lib/my-addon/app/templates/foo/bar.js'))
<add> .to.contain('export { default } from \'my-addon/templates/foo/bar\';');
<add>
<add> expect(_file('tests/unit/routes/foo/bar-test.js'))
<add> .to.contain('import { moduleFor, test } from \'ember-qunit\';')
<add> .to.contain('moduleFor(\'route:foo/bar\'');
<add> }));
<add> });
<ide>
<ide> it('route foo --pod', function() {
<del> var files = [
<del> {
<del> file: 'app/router.js',
<del> contains: 'this.route(\'foo\')'
<del> },
<del> {
<del> file: 'app/foo/route.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "export default Ember.Route.extend({\n});"
<del> ]
<del> },
<del> {
<del> file: 'app/foo/template.hbs',
<del> contains: '{{outlet}}'
<del> },
<del> {
<del> file: 'tests/unit/foo/route-test.js',
<del> contains: [
<del> "import { moduleFor, test } from 'ember-qunit';",
<del> "moduleFor('route:foo'"
<del> ]
<del> }
<del> ];
<del>
<del> return generateAndDestroy(['route', 'foo', '--pod'], {
<del> afterDestroy: function() {
<del> // remove `app/router.js` to work around https://github.com/ember-cli/ember-cli-blueprint-test-helpers/issues/38
<del> files.shift();
<del> },
<del> files: files,
<del> });
<add> var args = ['route', 'foo', '--pod'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, (_file) => {
<add> expect(_file('app/foo/route.js'))
<add> .to.contain('import Ember from \'ember\';')
<add> .to.contain('export default Ember.Route.extend({\n});');
<add>
<add> expect(_file('app/foo/template.hbs'))
<add> .to.contain('{{outlet}}');
<add>
<add> expect(_file('tests/unit/foo/route-test.js'))
<add> .to.contain('import { moduleFor, test } from \'ember-qunit\';')
<add> .to.contain('moduleFor(\'route:foo\'');
<add>
<add> expect(file('app/router.js'))
<add> .to.contain('this.route(\'foo\')');
<add> }))
<add> .then(() => expect(file('app/router.js'))
<add> .to.not.contain('this.route(\'foo\')'));
<ide> });
<ide>
<ide> it('route foo --pod with --path', function() {
<del> var files = [
<del> {
<del> file: 'app/router.js',
<del> contains: [
<del> 'this.route(\'foo\', {',
<del> 'path: \':foo_id/show\'',
<del> '});'
<del> ]
<del> }
<del> ];
<del>
<del> return generateAndDestroy(['route', 'foo', '--pod', '--path=:foo_id/show'], {
<del> afterDestroy: function() {
<del> // remove `app/router.js` to work around https://github.com/ember-cli/ember-cli-blueprint-test-helpers/issues/38
<del> files.shift();
<del> },
<del> files: files,
<del> });
<add> var args = ['route', 'foo', '--pod', '--path=:foo_id/show'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerate(args))
<add> .then(() => expect(file('app/router.js'))
<add> .to.contain('this.route(\'foo\', {')
<add> .to.contain('path: \':foo_id/show\'')
<add> .to.contain('});'))
<add>
<add> .then(() => emberDestroy(args))
<add> .then(() => expect(file('app/router.js'))
<add> .to.not.contain('this.route(\'foo\', {')
<add> .to.not.contain('path: \':foo_id/show\''));
<ide> });
<ide>
<del>
<ide> it('route foo --pod podModulePrefix', function() {
<del> var files = [
<del> {
<del> file: 'app/router.js',
<del> contains: 'this.route(\'foo\')'
<del> },
<del> {
<del> file: 'app/pods/foo/route.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> "export default Ember.Route.extend({\n});"
<del> ]
<del> },
<del> {
<del> file: 'app/pods/foo/template.hbs',
<del> contains: '{{outlet}}'
<del> },
<del> {
<del> file: 'tests/unit/pods/foo/route-test.js',
<del> contains: [
<del> "import { moduleFor, test } from 'ember-qunit';",
<del> "moduleFor('route:foo'"
<del> ]
<del> }
<del> ];
<del>
<del> return generateAndDestroy(['route', 'foo', '--pod'], {
<del> podModulePrefix: true,
<del> afterDestroy: function() {
<del> // remove `app/router.js` to work around https://github.com/ember-cli/ember-cli-blueprint-test-helpers/issues/38
<del> files.shift();
<del> },
<del> files: files,
<del> });
<add> var args = ['route', 'foo', '--pod'];
<add>
<add> return emberNew()
<add> .then(() => setupPodConfig({ podModulePrefix: true }))
<add> .then(() => emberGenerateDestroy(args, (_file) => {
<add> expect(_file('app/pods/foo/route.js'))
<add> .to.contain('import Ember from \'ember\';')
<add> .to.contain('export default Ember.Route.extend({\n});');
<add>
<add> expect(_file('app/pods/foo/template.hbs'))
<add> .to.contain('{{outlet}}');
<add>
<add> expect(_file('tests/unit/pods/foo/route-test.js'))
<add> .to.contain('import { moduleFor, test } from \'ember-qunit\';')
<add> .to.contain('moduleFor(\'route:foo\'');
<add>
<add> expect(file('app/router.js'))
<add> .to.contain('this.route(\'foo\')');
<add> }))
<add> .then(() => expect(file('app/router.js'))
<add> .to.not.contain('this.route(\'foo\')'));
<ide> });
<ide>
<ide> it('route index --pod', function() {
<del> var files = [
<del> {
<del> file: 'app/router.js',
<del> doesNotContain: "this.route('index');"
<del> }
<del> ];
<del>
<del> return generateAndDestroy(['route', 'index', '--pod'], {
<del> afterDestroy: function() {
<del> // remove `app/router.js` to work around https://github.com/ember-cli/ember-cli-blueprint-test-helpers/issues/38
<del> files.shift();
<del> },
<del> files: files,
<del> });
<add> var args = ['route', 'index', '--pod'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerate(args))
<add> .then(() => expect(file('app/router.js'))
<add> .to.not.contain('this.route(\'index\')'));
<ide> });
<ide>
<ide> it('route application --pod', function() {
<del> return generateAndDestroy(['route', 'foo'], {
<del> afterGenerate: function(){
<del> return remove(path.join('app', 'templates', 'application.hbs'))
<del> .then(function() {
<del> var files = [
<del> {
<del> file: 'app/router.js',
<del> doesNotContain: "this.route('application');"
<del> }
<del> ];
<del>
<del> return generateAndDestroy(['route', 'application', '--pod'], {
<del> skipInit: true,
<del> afterDestroy: function() {
<del> // remove `app/router.js` to work around https://github.com/ember-cli/ember-cli-blueprint-test-helpers/issues/38
<del> files.shift();
<del> },
<del> files: files,
<del> });
<del> });
<del> }
<del> });
<add> var args = ['route', 'application', '--pod'];
<add>
<add> return emberNew()
<add> .then(() => remove(path.resolve('app/templates/application.hbs')))
<add> .then(() => emberGenerate(args))
<add> .then(() => expect(file('app/application/route.js')).to.exist)
<add> .then(() => expect(file('app/application/template.hbs')).to.exist)
<add> .then(() => expect(file('app/router.js')).to.not.contain('this.route(\'application\')'));
<ide> });
<ide>
<ide> it('route basic --pod isn\'t added to router', function() {
<del> var files = [
<del> {
<del> file: 'app/router.js',
<del> doesNotContain: "this.route('basic');"
<del> },
<del> {
<del> file: 'app/basic/route.js'
<del> }
<del> ];
<del>
<del> return generateAndDestroy(['route', 'basic', '--pod'], {
<del> afterDestroy: function() {
<del> // remove `app/router.js` to work around https://github.com/ember-cli/ember-cli-blueprint-test-helpers/issues/38
<del> files.shift();
<del> },
<del> files: files,
<del> });
<add> var args = ['route', 'basic', '--pod'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, (_file) => {
<add> expect(_file('app/basic/route.js')).to.exist;
<add> expect(file('app/router.js'))
<add> .to.not.contain('this.route(\'index\')');
<add> }));
<ide> });
<ide>
<del> it('route-test foo', function() {
<del> return generateAndDestroy(['route-test', 'foo'], {
<del> files: [
<del> {
<del> file: 'tests/unit/routes/foo-test.js',
<del> contains: [
<del> "import { moduleFor, test } from 'ember-qunit';",
<del> "moduleFor('route:foo'"
<del> ]
<del> }
<del> ]
<del> });
<del> });
<add> it('in-addon route foo --pod', function() {
<add> var args = ['route', 'foo', '--pod'];
<ide>
<del> it('in-addon route-test foo', function() {
<del> return generateAndDestroy(['route-test', 'foo'], {
<del> target: 'addon',
<del> files: [
<del> {
<del> file: 'tests/unit/routes/foo-test.js',
<del> contains: [
<del> "import { moduleFor, test } from 'ember-qunit';",
<del> "moduleFor('route:foo'"
<del> ]
<del> },
<del> {
<del> file: 'app/route-test/foo.js',
<del> exists: false
<del> }
<del> ]
<del> });
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, (_file) => {
<add> expect(_file('addon/foo/route.js'))
<add> .to.contain('import Ember from \'ember\';')
<add> .to.contain('export default Ember.Route.extend({\n});');
<add>
<add> expect(_file('addon/foo/template.hbs'))
<add> .to.contain('{{outlet}}');
<add>
<add> expect(_file('app/foo/route.js'))
<add> .to.contain('export { default } from \'my-addon/foo/route\';');
<add>
<add> expect(_file('app/foo/template.js'))
<add> .to.contain('export { default } from \'my-addon/foo/template\';');
<add>
<add> expect(_file('tests/unit/foo/route-test.js'))
<add> .to.contain('import { moduleFor, test } from \'ember-qunit\';')
<add> .to.contain('moduleFor(\'route:foo\'');
<add> }));
<ide> });
<ide>
<add> it('route-test foo', function() {
<add> var args = ['route-test', 'foo'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, (_file) => {
<add> expect(_file('tests/unit/routes/foo-test.js'))
<add> .to.contain('import { moduleFor, test } from \'ember-qunit\';')
<add> .to.contain('moduleFor(\'route:foo\'');
<add> }));
<add> });
<ide>
<del> it('dummy route-test foo', function() {
<del> return generateAndDestroy(['route-test', 'foo'], {
<del> target: 'addon',
<del> files: [
<del> {
<del> file: 'tests/unit/routes/foo-test.js',
<del> contains: [
<del> "import { moduleFor, test } from 'ember-qunit';",
<del> "moduleFor('route:foo'"
<del> ]
<del> },
<del> {
<del> file: 'app/route-test/foo.js',
<del> exists: false
<del> }
<del> ]
<del> });
<add> it('in-addon route-test foo', function() {
<add> var args = ['route-test', 'foo'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, (_file) => {
<add> expect(_file('tests/unit/routes/foo-test.js'))
<add> .to.contain('import { moduleFor, test } from \'ember-qunit\';')
<add> .to.contain('moduleFor(\'route:foo\'');
<add> }));
<ide> });
<ide>
<ide> it('route-test foo for mocha', function() {
<del> return generateAndDestroy(['route-test', 'foo'], {
<del> packages: [
<add> var args = ['route-test', 'foo'];
<add>
<add> return emberNew()
<add> .then(() => modifyPackages([
<ide> { name: 'ember-cli-qunit', delete: true },
<ide> { name: 'ember-cli-mocha', dev: true }
<del> ],
<del> files: [
<del> {
<del> file: 'tests/unit/routes/foo-test.js',
<del> contains: [
<del> "import { describeModule, it } from 'ember-mocha';",
<del> "describeModule('route:foo', 'Unit | Route | foo'"
<del> ]
<del> }
<del> ]
<del> });
<add> ]))
<add>
<add> .then(() => emberGenerateDestroy(args, (_file) => {
<add> expect(_file('tests/unit/routes/foo-test.js'))
<add> .to.contain('import { describeModule, it } from \'ember-mocha\';')
<add> .to.contain('describeModule(\'route:foo\', \'Unit | Route | foo\'');
<add> }));
<ide> });
<ide> });
<ide><path>node-tests/blueprints/service-test.js
<ide> 'use strict';
<ide>
<del>var setupTestHooks = require('ember-cli-blueprint-test-helpers/lib/helpers/setup');
<del>var BlueprintHelpers = require('ember-cli-blueprint-test-helpers/lib/helpers/blueprint-helper');
<del>var generateAndDestroy = BlueprintHelpers.generateAndDestroy;
<add>var blueprintHelpers = require('ember-cli-blueprint-test-helpers/helpers');
<add>var setupTestHooks = blueprintHelpers.setupTestHooks;
<add>var emberNew = blueprintHelpers.emberNew;
<add>var emberGenerateDestroy = blueprintHelpers.emberGenerateDestroy;
<add>var modifyPackages = blueprintHelpers.modifyPackages;
<add>var setupPodConfig = blueprintHelpers.setupPodConfig;
<add>
<add>var chai = require('ember-cli-blueprint-test-helpers/chai');
<add>var expect = chai.expect;
<ide>
<ide> describe('Acceptance: ember generate and destroy service', function() {
<ide> setupTestHooks(this);
<ide>
<ide> it('service foo', function() {
<del> return generateAndDestroy(['service', 'foo'], {
<del> files: [
<del> {
<del> file: 'app/services/foo.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> 'export default Ember.Service.extend({\n});'
<del> ]
<del> },
<del> {
<del> file: 'tests/unit/services/foo-test.js',
<del> contains: [
<del> "import { moduleFor, test } from 'ember-qunit';",
<del> "moduleFor('service:foo'"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['service', 'foo'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/services/foo.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain('export default Ember.Service.extend({\n});');
<add>
<add> expect(_file('tests/unit/services/foo-test.js'))
<add> .to.contain("import { moduleFor, test } from 'ember-qunit';")
<add> .to.contain("moduleFor('service:foo'");
<add> }));
<ide> });
<ide>
<ide> it('service foo/bar', function() {
<del> return generateAndDestroy(['service', 'foo/bar'], {
<del> files: [
<del> {
<del> file: 'app/services/foo/bar.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> 'export default Ember.Service.extend({\n});'
<del> ]
<del> },
<del> {
<del> file: 'tests/unit/services/foo/bar-test.js',
<del> contains: [
<del> "import { moduleFor, test } from 'ember-qunit';",
<del> "moduleFor('service:foo/bar'"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['service', 'foo/bar'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/services/foo/bar.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain('export default Ember.Service.extend({\n});');
<add>
<add> expect(_file('tests/unit/services/foo/bar-test.js'))
<add> .to.contain("import { moduleFor, test } from 'ember-qunit';")
<add> .to.contain("moduleFor('service:foo/bar'");
<add> }));
<ide> });
<ide> it('in-addon service foo', function() {
<del> return generateAndDestroy(['service', 'foo'], {
<del> target: 'addon',
<del> files: [
<del> {
<del> file: 'addon/services/foo.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> 'export default Ember.Service.extend({\n});'
<del> ]
<del> },
<del> {
<del> file: 'app/services/foo.js',
<del> contains: [
<del> "export { default } from 'my-addon/services/foo';"
<del> ]
<del> },
<del> {
<del> file: 'tests/unit/services/foo-test.js',
<del> contains: [
<del> "import { moduleFor, test } from 'ember-qunit';",
<del> "moduleFor('service:foo'"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['service', 'foo'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('addon/services/foo.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain('export default Ember.Service.extend({\n});');
<add>
<add> expect(_file('app/services/foo.js'))
<add> .to.contain("export { default } from 'my-addon/services/foo';");
<add>
<add> expect(_file('tests/unit/services/foo-test.js'))
<add> .to.contain("import { moduleFor, test } from 'ember-qunit';")
<add> .to.contain("moduleFor('service:foo'");
<add> }));
<ide> });
<ide>
<ide> it('in-addon service foo/bar', function() {
<del> return generateAndDestroy(['service', 'foo/bar'], {
<del> target: 'addon',
<del> files: [
<del> {
<del> file: 'addon/services/foo/bar.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> 'export default Ember.Service.extend({\n});'
<del> ]
<del> },
<del> {
<del> file: 'app/services/foo/bar.js',
<del> contains: [
<del> "export { default } from 'my-addon/services/foo/bar';"
<del> ]
<del> },
<del> {
<del> file: 'tests/unit/services/foo/bar-test.js',
<del> contains: [
<del> "import { moduleFor, test } from 'ember-qunit';",
<del> "moduleFor('service:foo/bar'"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['service', 'foo/bar'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('addon/services/foo/bar.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain('export default Ember.Service.extend({\n});');
<add>
<add> expect(_file('app/services/foo/bar.js'))
<add> .to.contain("export { default } from 'my-addon/services/foo/bar';");
<add>
<add> expect(_file('tests/unit/services/foo/bar-test.js'))
<add> .to.contain("import { moduleFor, test } from 'ember-qunit';")
<add> .to.contain("moduleFor('service:foo/bar'");
<add> }));
<ide> });
<del>/**
<del>* Pod tests
<del>*
<del>*/
<ide>
<ide> it('service foo --pod', function() {
<del> return generateAndDestroy(['service', 'foo', '--pod'], {
<del> files: [
<del> {
<del> file: 'app/foo/service.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> 'export default Ember.Service.extend({\n});'
<del> ]
<del> },
<del> {
<del> file: 'tests/unit/foo/service-test.js',
<del> contains: [
<del> "import { moduleFor, test } from 'ember-qunit';",
<del> "moduleFor('service:foo'"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['service', 'foo', '--pod'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/foo/service.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain('export default Ember.Service.extend({\n});');
<add>
<add> expect(_file('tests/unit/foo/service-test.js'))
<add> .to.contain("import { moduleFor, test } from 'ember-qunit';")
<add> .to.contain("moduleFor('service:foo'");
<add> }));
<ide> });
<ide>
<ide> it('service foo/bar --pod', function() {
<del> return generateAndDestroy(['service', 'foo/bar', '--pod'], {
<del> files: [
<del> {
<del> file: 'app/foo/bar/service.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> 'export default Ember.Service.extend({\n});'
<del> ]
<del> },
<del> {
<del> file: 'tests/unit/foo/bar/service-test.js',
<del> contains: [
<del> "import { moduleFor, test } from 'ember-qunit';",
<del> "moduleFor('service:foo/bar'"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['service', 'foo/bar', '--pod'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/foo/bar/service.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain('export default Ember.Service.extend({\n});');
<add>
<add> expect(_file('tests/unit/foo/bar/service-test.js'))
<add> .to.contain("import { moduleFor, test } from 'ember-qunit';")
<add> .to.contain("moduleFor('service:foo/bar'");
<add> }));
<ide> });
<ide>
<ide> it('service foo --pod podModulePrefix', function() {
<del> return generateAndDestroy(['service', 'foo', '--pod'], {
<del> podModulePrefix: true,
<del> files: [
<del> {
<del> file: 'app/pods/foo/service.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> 'export default Ember.Service.extend({\n});'
<del> ]
<del> },
<del> {
<del> file: 'tests/unit/pods/foo/service-test.js',
<del> contains: [
<del> "import { moduleFor, test } from 'ember-qunit';",
<del> "moduleFor('service:foo'"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['service', 'foo', '--pod'];
<add>
<add> return emberNew()
<add> .then(() => setupPodConfig({ podModulePrefix: true }))
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/pods/foo/service.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain('export default Ember.Service.extend({\n});');
<add>
<add> expect(_file('tests/unit/pods/foo/service-test.js'))
<add> .to.contain("import { moduleFor, test } from 'ember-qunit';")
<add> .to.contain("moduleFor('service:foo'");
<add> }));
<ide> });
<ide>
<ide> it('service foo/bar --pod podModulePrefix', function() {
<del> return generateAndDestroy(['service', 'foo/bar', '--pod'], {
<del> podModulePrefix: true,
<del> files: [
<del> {
<del> file: 'app/pods/foo/bar/service.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> 'export default Ember.Service.extend({\n});'
<del> ]
<del> },
<del> {
<del> file: 'tests/unit/pods/foo/bar/service-test.js',
<del> contains: [
<del> "import { moduleFor, test } from 'ember-qunit';",
<del> "moduleFor('service:foo/bar'"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['service', 'foo/bar', '--pod'];
<add>
<add> return emberNew()
<add> .then(() => setupPodConfig({ podModulePrefix: true }))
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/pods/foo/bar/service.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain('export default Ember.Service.extend({\n});');
<add>
<add> expect(_file('tests/unit/pods/foo/bar/service-test.js'))
<add> .to.contain("import { moduleFor, test } from 'ember-qunit';")
<add> .to.contain("moduleFor('service:foo/bar'");
<add> }));
<ide> });
<ide>
<ide> it('service-test foo', function() {
<del> return generateAndDestroy(['service-test', 'foo'], {
<del> files: [
<del> {
<del> file: 'tests/unit/services/foo-test.js',
<del> contains: [
<del> "import { moduleFor, test } from 'ember-qunit';",
<del> "moduleFor('service:foo'"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['service-test', 'foo'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/unit/services/foo-test.js'))
<add> .to.contain("import { moduleFor, test } from 'ember-qunit';")
<add> .to.contain("moduleFor('service:foo'");
<add> }));
<ide> });
<ide>
<ide> it('in-addon service-test foo', function() {
<del> return generateAndDestroy(['service-test', 'foo'], {
<del> target: 'addon',
<del> files: [
<del> {
<del> file: 'tests/unit/services/foo-test.js',
<del> contains: [
<del> "import { moduleFor, test } from 'ember-qunit';",
<del> "moduleFor('service:foo'"
<del> ]
<del> },
<del> {
<del> file: 'app/service-test/foo.js',
<del> exists: false
<del> }
<del> ]
<del> });
<add> var args = ['service-test', 'foo'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/unit/services/foo-test.js'))
<add> .to.contain("import { moduleFor, test } from 'ember-qunit';")
<add> .to.contain("moduleFor('service:foo'");
<add>
<add> expect(_file('app/service-test/foo.js'))
<add> .to.not.exist;
<add> }));
<ide> });
<ide>
<ide> it('service-test foo for mocha', function() {
<del> return generateAndDestroy(['service-test', 'foo'], {
<del> packages: [
<del> { name: 'ember-cli-qunit', delete: true },
<del> { name: 'ember-cli-mocha', dev: true }
<del> ],
<del> files: [
<del> {
<del> file: 'tests/unit/services/foo-test.js',
<del> contains: [
<del> "import { describeModule, it } from 'ember-mocha';",
<del> "describeModule('service:foo', 'Unit | Service | foo'"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['service-test', 'foo'];
<add>
<add> return emberNew()
<add> .then(() => modifyPackages([
<add> {name: 'ember-cli-qunit', delete: true},
<add> {name: 'ember-cli-mocha', dev: true}
<add> ]))
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/unit/services/foo-test.js'))
<add> .to.contain("import { describeModule, it } from 'ember-mocha';")
<add> .to.contain("describeModule('service:foo', 'Unit | Service | foo'");
<add> }));
<ide> });
<ide> });
<ide><path>node-tests/blueprints/template-test.js
<ide> 'use strict';
<ide>
<del>var setupTestHooks = require('ember-cli-blueprint-test-helpers/lib/helpers/setup');
<del>var BlueprintHelpers = require('ember-cli-blueprint-test-helpers/lib/helpers/blueprint-helper');
<del>var generateAndDestroy = BlueprintHelpers.generateAndDestroy;
<add>var blueprintHelpers = require('ember-cli-blueprint-test-helpers/helpers');
<add>var setupTestHooks = blueprintHelpers.setupTestHooks;
<add>var emberNew = blueprintHelpers.emberNew;
<add>var emberGenerateDestroy = blueprintHelpers.emberGenerateDestroy;
<add>var setupPodConfig = blueprintHelpers.setupPodConfig;
<add>
<add>var chai = require('ember-cli-blueprint-test-helpers/chai');
<add>var expect = chai.expect;
<ide>
<ide> describe('Acceptance: ember generate and destroy template', function() {
<ide> setupTestHooks(this);
<ide>
<ide> it('template foo', function() {
<del> return generateAndDestroy(['template', 'foo'], {
<del> files: [
<del> { file: 'app/templates/foo.hbs', isEmpty: true }
<del> ]
<del> });
<add> var args = ['template', 'foo'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/templates/foo.hbs')).to.equal('');
<add> }));
<ide> });
<ide>
<ide> it('template foo/bar', function() {
<del> return generateAndDestroy(['template', 'foo/bar'], {
<del> files: [
<del> { file: 'app/templates/foo/bar.hbs', isEmpty: true }
<del> ]
<del> });
<add> var args = ['template', 'foo/bar'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/templates/foo/bar.hbs')).to.equal('');
<add> }));
<ide> });
<ide>
<ide> it('template foo --pod', function() {
<del> return generateAndDestroy(['template', 'foo'], {
<del> usePods: true,
<del> files: [
<del> { file: 'app/foo/template.hbs', isEmpty: true }
<del> ]
<del> });
<add> var args = ['template', 'foo'];
<add>
<add> return emberNew()
<add> .then(() => setupPodConfig({
<add> usePods: true
<add> }))
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/foo/template.hbs')).to.equal('');
<add> }));
<ide> });
<ide>
<ide> it('template foo/bar --pod', function() {
<del> return generateAndDestroy(['template', 'foo/bar'], {
<del> usePods: true,
<del> files: [
<del> { file: 'app/foo/bar/template.hbs', isEmpty: true }
<del> ]
<del> });
<add> var args = ['template', 'foo/bar'];
<add>
<add> return emberNew()
<add> .then(() => setupPodConfig({
<add> usePods: true
<add> }))
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/foo/bar/template.hbs')).to.equal('');
<add> }));
<ide> });
<ide>
<ide> it('template foo --pod podModulePrefix', function() {
<del> return generateAndDestroy(['template', 'foo'], {
<del> usePods: true,
<del> podModulePrefix: true,
<del> files: [
<del> { file: 'app/pods/foo/template.hbs', isEmpty: true }
<del> ]
<del> });
<add> var args = ['template', 'foo'];
<add>
<add> return emberNew()
<add> .then(() => setupPodConfig({
<add> usePods: true,
<add> podModulePrefix: true
<add> }))
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/pods/foo/template.hbs')).to.equal('');
<add> }));
<ide> });
<ide>
<ide> it('template foo/bar --pod podModulePrefix', function() {
<del> return generateAndDestroy(['template', 'foo/bar'], {
<del> usePods: true,
<del> podModulePrefix: true,
<del> files: [
<del> { file: 'app/pods/foo/bar/template.hbs', isEmpty: true }
<del> ]
<del> });
<add> var args = ['template', 'foo/bar'];
<add>
<add> return emberNew()
<add> .then(() => setupPodConfig({
<add> usePods: true,
<add> podModulePrefix: true
<add> }))
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/pods/foo/bar/template.hbs')).to.equal('');
<add> }));
<ide> });
<ide>
<ide> it('in-addon template foo', function() {
<del> return generateAndDestroy(['template', 'foo'], {
<del> target: 'addon',
<del> files: [
<del> { file: 'addon/templates/foo.hbs', isEmpty: true }
<del> ]
<del> });
<add> var args = ['template', 'foo'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('addon/templates/foo.hbs')).to.equal('');
<add> }));
<ide> });
<ide>
<ide> it('in-addon template foo/bar', function() {
<del> return generateAndDestroy(['template', 'foo/bar'], {
<del> target: 'addon',
<del> files: [
<del> { file: 'addon/templates/foo/bar.hbs', isEmpty: true }
<del> ]
<del> });
<add> var args = ['template', 'foo/bar'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('addon/templates/foo/bar.hbs')).to.equal('');
<add> }));
<ide> });
<ide>
<ide> it('dummy template foo', function() {
<del> return generateAndDestroy(['template', 'foo', '--dummy'], {
<del> target: 'addon',
<del> files: [
<del> { file: 'tests/dummy/app/templates/foo.hbs', isEmpty: true }
<del> ]
<del> });
<add> var args = ['template', 'foo', '--dummy'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/dummy/app/templates/foo.hbs')).to.equal('');
<add> }));
<ide> });
<ide>
<ide> it('dummy template foo/bar', function() {
<del> return generateAndDestroy(['template', 'foo/bar', '--dummy'], {
<del> target: 'addon',
<del> files: [
<del> { file: 'tests/dummy/app/templates/foo/bar.hbs', isEmpty: true }
<del> ]
<del> });
<add> var args = ['template', 'foo/bar', '--dummy'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/dummy/app/templates/foo/bar.hbs')).to.equal('');
<add> }));
<ide> });
<ide>
<ide> it('in-repo-addon template foo', function() {
<del> return generateAndDestroy(['template', 'foo', '--in-repo-addon=my-addon'], {
<del> target: 'inRepoAddon',
<del> files: [
<del> { file: 'lib/my-addon/addon/templates/foo.hbs', isEmpty: true }
<del> ]
<del> });
<add> var args = ['template', 'foo', '--in-repo-addon=my-addon'];
<add>
<add> return emberNew({ target: 'in-repo-addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('lib/my-addon/addon/templates/foo.hbs')).to.equal('');
<add> }));
<ide> });
<ide>
<ide> it('in-repo-addon template foo/bar', function() {
<del> return generateAndDestroy(['template', 'foo/bar', '--in-repo-addon=my-addon'], {
<del> target: 'inRepoAddon',
<del> files: [
<del> { file: 'lib/my-addon/addon/templates/foo/bar.hbs', isEmpty: true }
<del> ]
<del> });
<add> var args = ['template', 'foo/bar', '--in-repo-addon=my-addon'];
<add>
<add> return emberNew({ target: 'in-repo-addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('lib/my-addon/addon/templates/foo/bar.hbs')).to.equal('');
<add> }));
<ide> });
<ide>
<ide> });
<ide><path>node-tests/blueprints/test-helper-test.js
<ide> 'use strict';
<ide>
<del>var setupTestHooks = require('ember-cli-blueprint-test-helpers/lib/helpers/setup');
<del>var BlueprintHelpers = require('ember-cli-blueprint-test-helpers/lib/helpers/blueprint-helper');
<del>var generateAndDestroy = BlueprintHelpers.generateAndDestroy;
<add>var blueprintHelpers = require('ember-cli-blueprint-test-helpers/helpers');
<add>var setupTestHooks = blueprintHelpers.setupTestHooks;
<add>var emberNew = blueprintHelpers.emberNew;
<add>var emberGenerateDestroy = blueprintHelpers.emberGenerateDestroy;
<add>
<add>var chai = require('ember-cli-blueprint-test-helpers/chai');
<add>var expect = chai.expect;
<ide>
<ide> describe('Acceptance: ember generate and destroy test-helper', function() {
<ide> setupTestHooks(this);
<ide>
<ide> it('test-helper foo', function() {
<del> return generateAndDestroy(['test-helper', 'foo'], {
<del> files: [
<del> {
<del> file: 'tests/helpers/foo.js',
<del> contains: [
<del> "import Ember from 'ember';",
<del> 'export default Ember.Test.registerAsyncHelper(\'foo\', function(app) {\n\n}'
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['test-helper', 'foo'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/helpers/foo.js'))
<add> .to.contain("import Ember from 'ember';")
<add> .to.contain('export default Ember.Test.registerAsyncHelper(\'foo\', function(app) {\n\n}');
<add> }));
<ide> });
<ide> });
<ide><path>node-tests/blueprints/util-test.js
<ide> 'use strict';
<ide>
<del>var setupTestHooks = require('ember-cli-blueprint-test-helpers/lib/helpers/setup');
<del>var BlueprintHelpers = require('ember-cli-blueprint-test-helpers/lib/helpers/blueprint-helper');
<del>var generateAndDestroy = BlueprintHelpers.generateAndDestroy;
<add>var blueprintHelpers = require('ember-cli-blueprint-test-helpers/helpers');
<add>var setupTestHooks = blueprintHelpers.setupTestHooks;
<add>var emberNew = blueprintHelpers.emberNew;
<add>var emberGenerateDestroy = blueprintHelpers.emberGenerateDestroy;
<add>var modifyPackages = blueprintHelpers.modifyPackages;
<add>var setupPodConfig = blueprintHelpers.setupPodConfig;
<add>
<add>var chai = require('ember-cli-blueprint-test-helpers/chai');
<add>var expect = chai.expect;
<ide>
<ide> describe('Acceptance: ember generate and destroy util', function() {
<ide> setupTestHooks(this);
<ide>
<ide> it('util foo-bar', function() {
<del> return generateAndDestroy(['util', 'foo-bar'], {
<del> files: [
<del> {
<del> file: 'app/utils/foo-bar.js',
<del> contains: 'export default function fooBar() {\n' +
<del> ' return true;\n' +
<del> '}'
<del> },
<del> {
<del> file: 'tests/unit/utils/foo-bar-test.js',
<del> contains: [
<del> "import fooBar from 'my-app/utils/foo-bar';"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['util', 'foo-bar'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/utils/foo-bar.js'))
<add> .to.contain('export default function fooBar() {\n' +
<add> ' return true;\n' +
<add> '}');
<add>
<add> expect(_file('tests/unit/utils/foo-bar-test.js'))
<add> .to.contain("import fooBar from 'my-app/utils/foo-bar';");
<add> }));
<ide> });
<ide>
<ide> it('util foo-bar/baz', function() {
<del> return generateAndDestroy(['util', 'foo/bar-baz'], {
<del> files: [
<del> {
<del> file: 'app/utils/foo/bar-baz.js',
<del> contains: 'export default function fooBarBaz() {\n' +
<del> ' return true;\n' +
<del> '}'
<del> },
<del> {
<del> file: 'tests/unit/utils/foo/bar-baz-test.js',
<del> contains: [
<del> "import fooBarBaz from 'my-app/utils/foo/bar-baz';"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['util', 'foo/bar-baz'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/utils/foo/bar-baz.js'))
<add> .to.contain('export default function fooBarBaz() {\n' +
<add> ' return true;\n' +
<add> '}');
<add>
<add> expect(_file('tests/unit/utils/foo/bar-baz-test.js'))
<add> .to.contain("import fooBarBaz from 'my-app/utils/foo/bar-baz';");
<add> }));
<ide> });
<ide>
<ide> it('in-addon util foo-bar', function() {
<del> return generateAndDestroy(['util', 'foo-bar'], {
<del> target: 'addon',
<del> files: [
<del> {
<del> file: 'addon/utils/foo-bar.js',
<del> contains: 'export default function fooBar() {\n' +
<del> ' return true;\n' +
<del> '}'
<del> },
<del> {
<del> file: 'app/utils/foo-bar.js',
<del> contains: [
<del> "export { default } from 'my-addon/utils/foo-bar';"
<del> ]
<del> },
<del> {
<del> file: 'tests/unit/utils/foo-bar-test.js',
<del> contains: [
<del> "import fooBar from 'dummy/utils/foo-bar';"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['util', 'foo-bar'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('addon/utils/foo-bar.js'))
<add> .to.contain('export default function fooBar() {\n' +
<add> ' return true;\n' +
<add> '}');
<add>
<add> expect(_file('app/utils/foo-bar.js'))
<add> .to.contain("export { default } from 'my-addon/utils/foo-bar';");
<add>
<add> expect(_file('tests/unit/utils/foo-bar-test.js'))
<add> .to.contain("import fooBar from 'dummy/utils/foo-bar';");
<add> }));
<ide> });
<ide>
<ide> it('in-addon util foo-bar/baz', function() {
<del> return generateAndDestroy(['util', 'foo/bar-baz'], {
<del> target: 'addon',
<del> files: [
<del> {
<del> file: 'addon/utils/foo/bar-baz.js',
<del> contains: 'export default function fooBarBaz() {\n' +
<del> ' return true;\n' +
<del> '}'
<del> },
<del> {
<del> file: 'app/utils/foo/bar-baz.js',
<del> contains: [
<del> "export { default } from 'my-addon/utils/foo/bar-baz';"
<del> ]
<del> },
<del> {
<del> file: 'tests/unit/utils/foo/bar-baz-test.js',
<del> contains: [
<del> "import fooBarBaz from 'dummy/utils/foo/bar-baz';"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['util', 'foo/bar-baz'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('addon/utils/foo/bar-baz.js'))
<add> .to.contain('export default function fooBarBaz() {\n' +
<add> ' return true;\n' +
<add> '}');
<add>
<add> expect(_file('app/utils/foo/bar-baz.js'))
<add> .to.contain("export { default } from 'my-addon/utils/foo/bar-baz';");
<add>
<add> expect(_file('tests/unit/utils/foo/bar-baz-test.js'))
<add> .to.contain("import fooBarBaz from 'dummy/utils/foo/bar-baz';");
<add> }));
<ide> });
<del>/**
<del>* Pod tests
<del>*
<del>*/
<ide>
<ide> it('util foo-bar --pod', function() {
<del> return generateAndDestroy(['util', 'foo-bar', '--pod'], {
<del> files: [
<del> {
<del> file: 'app/utils/foo-bar.js',
<del> contains: 'export default function fooBar() {\n' +
<del> ' return true;\n' +
<del> '}'
<del> },
<del> {
<del> file: 'tests/unit/utils/foo-bar-test.js',
<del> contains: [
<del> "import fooBar from 'my-app/utils/foo-bar';"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['util', 'foo-bar', '--pod'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/utils/foo-bar.js'))
<add> .to.contain('export default function fooBar() {\n' +
<add> ' return true;\n' +
<add> '}');
<add>
<add> expect(_file('tests/unit/utils/foo-bar-test.js'))
<add> .to.contain("import fooBar from 'my-app/utils/foo-bar';");
<add> }));
<ide> });
<ide>
<ide> it('util foo-bar --pod podModulePrefix', function() {
<del> return generateAndDestroy(['util', 'foo-bar', '--pod'], {
<del> podModulePrefix: true,
<del> files: [
<del> {
<del> file: 'app/utils/foo-bar.js',
<del> contains: 'export default function fooBar() {\n' +
<del> ' return true;\n' +
<del> '}'
<del> },
<del> {
<del> file: 'tests/unit/utils/foo-bar-test.js',
<del> contains: [
<del> "import fooBar from 'my-app/utils/foo-bar';"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['util', 'foo-bar', '--pod'];
<add>
<add> return emberNew()
<add> .then(() => setupPodConfig({ podModulePrefix: true }))
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/utils/foo-bar.js'))
<add> .to.contain('export default function fooBar() {\n' +
<add> ' return true;\n' +
<add> '}');
<add>
<add> expect(_file('tests/unit/utils/foo-bar-test.js'))
<add> .to.contain("import fooBar from 'my-app/utils/foo-bar';");
<add> }));
<ide> });
<ide>
<ide> it('util foo-bar/baz --pod', function() {
<del> return generateAndDestroy(['util', 'foo/bar-baz', '--pod'], {
<del> files: [
<del> {
<del> file: 'app/utils/foo/bar-baz.js',
<del> contains: 'export default function fooBarBaz() {\n' +
<del> ' return true;\n' +
<del> '}'
<del> },
<del> {
<del> file: 'tests/unit/utils/foo/bar-baz-test.js',
<del> contains: [
<del> "import fooBarBaz from 'my-app/utils/foo/bar-baz';"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['util', 'foo/bar-baz', '--pod'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('app/utils/foo/bar-baz.js'))
<add> .to.contain('export default function fooBarBaz() {\n' +
<add> ' return true;\n' +
<add> '}');
<add>
<add> expect(_file('tests/unit/utils/foo/bar-baz-test.js'))
<add> .to.contain("import fooBarBaz from 'my-app/utils/foo/bar-baz';");
<add> }));
<ide> });
<ide>
<ide> it('util-test foo-bar', function() {
<del> return generateAndDestroy(['util-test', 'foo-bar'], {
<del> files: [
<del> {
<del> file: 'tests/unit/utils/foo-bar-test.js',
<del> contains: [
<del> "import fooBar from 'my-app/utils/foo-bar';"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['util-test', 'foo-bar'];
<add>
<add> return emberNew()
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/unit/utils/foo-bar-test.js'))
<add> .to.contain("import fooBar from 'my-app/utils/foo-bar';");
<add> }));
<ide> });
<ide>
<ide> it('in-addon util-test foo-bar', function() {
<del> return generateAndDestroy(['util-test', 'foo-bar'], {
<del> target: 'addon',
<del> files: [
<del> {
<del> file: 'tests/unit/utils/foo-bar-test.js',
<del> contains: [
<del> "import fooBar from 'dummy/utils/foo-bar';"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['util-test', 'foo-bar'];
<add>
<add> return emberNew({ target: 'addon' })
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/unit/utils/foo-bar-test.js'))
<add> .to.contain("import fooBar from 'dummy/utils/foo-bar';");
<add> }));
<ide> });
<ide>
<ide> it('util-test foo-bar for mocha', function() {
<del> return generateAndDestroy(['util-test', 'foo-bar'], {
<del> packages: [
<del> { name: 'ember-cli-qunit', delete: true },
<del> { name: 'ember-cli-mocha', dev: true }
<del> ],
<del> files: [
<del> {
<del> file: 'tests/unit/utils/foo-bar-test.js',
<del> contains: [
<del> "import { describe, it } from 'mocha';",
<del> "import fooBar from 'my-app/utils/foo-bar';",
<del> "describe('Unit | Utility | foo bar', function() {"
<del> ]
<del> }
<del> ]
<del> });
<add> var args = ['util-test', 'foo-bar'];
<add>
<add> return emberNew()
<add> .then(() => modifyPackages([
<add> {name: 'ember-cli-qunit', delete: true},
<add> {name: 'ember-cli-mocha', dev: true}
<add> ]))
<add> .then(() => emberGenerateDestroy(args, _file => {
<add> expect(_file('tests/unit/utils/foo-bar-test.js'))
<add> .to.contain("import { describe, it } from 'mocha';")
<add> .to.contain("import fooBar from 'my-app/utils/foo-bar';")
<add> .to.contain("describe('Unit | Utility | foo bar', function() {");
<add> }));
<ide> });
<ide> }); | 17 |
PHP | PHP | update version constant | 80835ab0d0c2b11b2781de209fc257f08bf5963a | <ide><path>src/Illuminate/Foundation/Application.php
<ide> class Application extends Container implements ApplicationContract, CachesConfig
<ide> *
<ide> * @var string
<ide> */
<del> const VERSION = '8.17.0';
<add> const VERSION = '8.17.1';
<ide>
<ide> /**
<ide> * The base path for the Laravel installation. | 1 |
Javascript | Javascript | ensure mock $sce delegate is implemented correctly | 9d08b33a0dd9d4a45dda512c95db12555baa9d17 | <ide><path>test/ngRoute/routeSpec.js
<ide> describe('$route', function() {
<ide> $routeProvider = _$routeProvider_;
<ide>
<ide> $provide.decorator('$sce', function($delegate) {
<add> function getVal(v) { return v.getVal ? v.getVal() : v; }
<ide> $delegate.trustAsResourceUrl = function(url) { return new MySafeResourceUrl(url); };
<del> $delegate.getTrustedResourceUrl = function(v) { return v.getVal(); };
<del> $delegate.valueOf = function(v) { return v.getVal(); };
<add> $delegate.getTrustedResourceUrl = function(v) { return getVal(v); };
<add> $delegate.valueOf = function(v) { return getVal(v); };
<ide> return $delegate;
<ide> });
<ide> }); | 1 |
Javascript | Javascript | increase coverage in lib/internal/dns/promises.js | eac8f50ca664186d099c03dcac71a22fde89671f | <ide><path>test/parallel/test-dns-lookupService.js
<ide> assert.throws(
<ide> syscall: 'getnameinfo'
<ide> }
<ide> );
<add>
<add>assert.rejects(
<add> dns.promises.lookupService('127.0.0.1', 80),
<add> {
<add> code: 'ENOENT',
<add> message: 'getnameinfo ENOENT 127.0.0.1',
<add> syscall: 'getnameinfo'
<add> }
<add>); | 1 |
Javascript | Javascript | convert bind(this) to arrow functions | 15f4894ebe7d9b8e6658748573e18aed702f33fe | <ide><path>lib/Compiler.js
<ide> class Compiler extends Tapable {
<ide> });
<ide> });
<ide> },
<del> apply: function() {
<add> apply: () => {
<ide> const args = arguments;
<ide> if(!deprecationReported) {
<ide> console.warn("webpack: Using compiler.parser is deprecated.\n" +
<ide> class Compiler extends Tapable {
<ide> parser.apply.apply(parser, args);
<ide> });
<ide> });
<del> }.bind(this)
<add> }
<ide> };
<ide>
<ide> this.options = {};
<ide> class Compiler extends Tapable {
<ide> emitAssets(compilation, callback) {
<ide> let outputPath;
<ide>
<del> this.applyPluginsAsync("emit", compilation, err => {
<del> if(err) return callback(err);
<del> outputPath = compilation.getPath(this.outputPath);
<del> this.outputFileSystem.mkdirp(outputPath, emitFiles.bind(this));
<del> });
<del>
<del> function emitFiles(err) {
<add> const emitFiles = (err) => {
<ide> if(err) return callback(err);
<ide>
<ide> require("async").forEach(Object.keys(compilation.assets), (file, callback) => {
<ide> class Compiler extends Tapable {
<ide> targetFile = targetFile.substr(0, queryStringIdx);
<ide> }
<ide>
<del> if(targetFile.match(/\/|\\/)) {
<del> const dir = path.dirname(targetFile);
<del> this.outputFileSystem.mkdirp(this.outputFileSystem.join(outputPath, dir), writeOut.bind(this));
<del> } else writeOut.call(this);
<del>
<del> function writeOut(err) {
<add> const writeOut = (err) => {
<ide> if(err) return callback(err);
<ide> const targetPath = this.outputFileSystem.join(outputPath, targetFile);
<ide> const source = compilation.assets[file];
<ide> class Compiler extends Tapable {
<ide> source.existsAt = targetPath;
<ide> source.emitted = true;
<ide> this.outputFileSystem.writeFile(targetPath, content, callback);
<del> }
<add> };
<add>
<add> if(targetFile.match(/\/|\\/)) {
<add> const dir = path.dirname(targetFile);
<add> this.outputFileSystem.mkdirp(this.outputFileSystem.join(outputPath, dir), writeOut);
<add> } else writeOut();
<ide>
<ide> }, err => {
<ide> if(err) return callback(err);
<ide>
<ide> afterEmit.call(this);
<ide> });
<del> }
<add> };
<add>
<add> this.applyPluginsAsync("emit", compilation, err => {
<add> if(err) return callback(err);
<add> outputPath = compilation.getPath(this.outputPath);
<add> this.outputFileSystem.mkdirp(outputPath, emitFiles);
<add> });
<ide>
<ide> function afterEmit() {
<ide> this.applyPluginsAsyncSeries1("after-emit", compilation, err => {
<ide><path>lib/ContextModuleFactory.js
<ide> module.exports = class ContextModuleFactory extends Tapable {
<ide> if(!regExp || !resource)
<ide> return callback(null, []);
<ide> (function addDirectory(directory, callback) {
<del> fs.readdir(directory, function(err, files) {
<add> fs.readdir(directory, (err, files) => {
<ide> if(err) return callback(err);
<ide> if(!files || files.length === 0) return callback(null, []);
<ide> asyncLib.map(files.filter(function(p) {
<ide> return p.indexOf(".") !== 0;
<del> }), function(seqment, callback) {
<add> }), (seqment, callback) => {
<ide>
<ide> const subResource = path.join(directory, seqment);
<ide>
<del> fs.stat(subResource, function(err, stat) {
<add> fs.stat(subResource, (err, stat) => {
<ide> if(err) return callback(err);
<ide>
<ide> if(stat.isDirectory()) {
<ide> module.exports = class ContextModuleFactory extends Tapable {
<ide>
<ide> } else callback();
<ide>
<del> }.bind(this));
<add> });
<ide>
<del> }.bind(this), (err, result) => {
<add> }, (err, result) => {
<ide> if(err) return callback(err);
<ide>
<ide> if(!result) return callback(null, []);
<ide> module.exports = class ContextModuleFactory extends Tapable {
<ide> return a.concat(i);
<ide> }, []));
<ide> });
<del> }.bind(this));
<add> });
<ide> }.call(this, resource, callback));
<ide> }
<ide> };
<ide><path>lib/Parser.js
<ide> class Parser extends Tapable {
<ide> statement.params.forEach(param => {
<ide> this.walkPattern(param);
<ide> });
<del> this.inScope(statement.params, function() {
<add> this.inScope(statement.params, () => {
<ide> if(statement.body.type === "BlockStatement") {
<ide> this.prewalkStatement(statement.body);
<ide> this.walkStatement(statement.body);
<ide> } else {
<ide> this.walkExpression(statement.body);
<ide> }
<del> }.bind(this));
<add> });
<ide> }
<ide>
<ide> prewalkImportDeclaration(statement) {
<ide> class Parser extends Tapable {
<ide> }
<ide>
<ide> walkCatchClause(catchClause) {
<del> this.inScope([catchClause.param], function() {
<add> this.inScope([catchClause.param], () => {
<ide> this.prewalkStatement(catchClause.body);
<ide> this.walkStatement(catchClause.body);
<del> }.bind(this));
<add> });
<ide> }
<ide>
<ide> prewalkVariableDeclarators(declarators) {
<ide> class Parser extends Tapable {
<ide> expression.params.forEach(param => {
<ide> this.walkPattern(param);
<ide> });
<del> this.inScope(expression.params, function() {
<add> this.inScope(expression.params, () => {
<ide> if(expression.body.type === "BlockStatement") {
<ide> this.prewalkStatement(expression.body);
<ide> this.walkStatement(expression.body);
<ide> } else {
<ide> this.walkExpression(expression.body);
<ide> }
<del> }.bind(this));
<add> });
<ide> }
<ide>
<ide> walkArrowFunctionExpression(expression) {
<ide> expression.params.forEach(param => {
<ide> this.walkPattern(param);
<ide> });
<del> this.inScope(expression.params, function() {
<add> this.inScope(expression.params, () => {
<ide> if(expression.body.type === "BlockStatement") {
<ide> this.prewalkStatement(expression.body);
<ide> this.walkStatement(expression.body);
<ide> } else {
<ide> this.walkExpression(expression.body);
<ide> }
<del> }.bind(this));
<add> });
<ide> }
<ide>
<ide> walkSequenceExpression(expression) {
<ide> class Parser extends Tapable {
<ide> const args = options.map(renameArgOrThis, this);
<ide> this.inScope(params.filter(function(identifier, idx) {
<ide> return !args[idx];
<del> }), function() {
<add> }), () => {
<ide> if(renameThis) {
<ide> this.scope.renames.$this = renameThis;
<ide> }
<ide> class Parser extends Tapable {
<ide> this.walkStatement(functionExpression.body);
<ide> } else
<ide> this.walkExpression(functionExpression.body);
<del> }.bind(this));
<add> });
<ide> }
<ide> if(expression.callee.type === "MemberExpression" &&
<ide> expression.callee.object.type === "FunctionExpression" &&
<ide><path>lib/UmdMainTemplatePlugin.js
<ide> class UmdMainTemplatePlugin {
<ide>
<ide> apply(compilation) {
<ide> const mainTemplate = compilation.mainTemplate;
<del> compilation.templatesPlugin("render-with-entry", function(source, chunk, hash) {
<add> compilation.templatesPlugin("render-with-entry", (source, chunk, hash) => {
<ide> let externals = chunk.getModules().filter(m => m.external);
<ide> const optionalExternals = [];
<ide> let requiredExternals = [];
<ide> class UmdMainTemplatePlugin {
<ide> " }\n"
<ide> ) +
<ide> "})(this, function(" + externalsArguments(externals) + ") {\nreturn ", "webpack/universalModuleDefinition"), source, ";\n})");
<del> }.bind(this));
<del> mainTemplate.plugin("global-hash-paths", function(paths) {
<add> });
<add> mainTemplate.plugin("global-hash-paths", (paths) => {
<ide> if(this.names.root) paths = paths.concat(this.names.root);
<ide> if(this.names.amd) paths = paths.concat(this.names.amd);
<ide> if(this.names.commonjs) paths = paths.concat(this.names.commonjs);
<ide> return paths;
<del> }.bind(this));
<del> mainTemplate.plugin("hash", function(hash) {
<add> });
<add> mainTemplate.plugin("hash", (hash) => {
<ide> hash.update("umd");
<ide> hash.update(`${this.names.root}`);
<ide> hash.update(`${this.names.amd}`);
<ide> hash.update(`${this.names.commonjs}`);
<del> }.bind(this));
<add> });
<ide> }
<ide> }
<ide> | 4 |
Ruby | Ruby | add harmless dylibs check | 47fe2149638a85bc956593c12abd5aa5bb15452c | <ide><path>Library/Homebrew/os/mac/linkage_checker.rb
<ide> def check_dylibs
<ide> rescue NotAKegError
<ide> @system_dylibs << dylib
<ide> rescue Errno::ENOENT
<add> next if harmless_broken_link?(dylib)
<ide> @broken_dylibs << dylib
<ide> else
<ide> tap = Tab.for_keg(owner).tap
<ide> def undeclared_deps?
<ide>
<ide> private
<ide>
<add> # Whether or not dylib is a harmless broken link, meaning that it's
<add> # okay to skip (and not report) as broken.
<add> def harmless_broken_link?(dylib)
<add> # libgcc_s_ppc64 is referenced by programs that use the Java Service Wrapper,
<add> # and is harmless on x86(_64) machines
<add> ["/usr/lib/libgcc_s_ppc64.1.dylib"].include?(dylib)
<add> end
<add>
<ide> # Display a list of things.
<ide> # Things may either be an array, or a hash of (label -> array)
<ide> def display_items(label, things) | 1 |
Ruby | Ruby | make use of config.perform_caching | a618ad358a51beead39eca3bf3ee029b66f34f73 | <ide><path>actionpack/lib/action_controller/caching.rb
<ide> def cache_store=(store)
<ide> private
<ide>
<ide> def cache_configured?
<del> perform_caching && cache_store
<add> config.perform_caching && cache_store
<ide> end
<ide> end
<ide>
<ide><path>actionpack/lib/action_controller/caching/pages.rb
<ide> module ClassMethods
<ide> # Expires the page that was cached with the +path+ as a key. Example:
<ide> # expire_page "/lists/show"
<ide> def expire_page(path)
<del> return unless perform_caching
<add> return unless config.perform_caching
<ide> path = page_cache_path(path)
<ide>
<ide> instrument_page_cache :expire_page, path do
<ide> def expire_page(path)
<ide> # Manually cache the +content+ in the key determined by +path+. Example:
<ide> # cache_page "I'm the cached content", "/lists/show"
<ide> def cache_page(content, path)
<del> return unless perform_caching
<add> return unless config.perform_caching
<ide> path = page_cache_path(path)
<ide>
<ide> instrument_page_cache :write_page, path do
<ide> def cache_page(content, path)
<ide> # # cache the index action except for JSON requests
<ide> # caches_page :index, :if => Proc.new { |c| !c.request.format.json? }
<ide> def caches_page(*actions)
<del> return unless perform_caching
<add> return unless config.perform_caching
<ide> options = actions.extract_options!
<ide> after_filter({:only => actions}.merge(options)) { |c| c.cache_page }
<ide> end
<ide> def instrument_page_cache(name, path)
<ide> # Expires the page that was cached with the +options+ as a key. Example:
<ide> # expire_page :controller => "lists", :action => "show"
<ide> def expire_page(options = {})
<del> return unless perform_caching
<add> return unless config.perform_caching
<ide>
<ide> if options.is_a?(Hash)
<ide> if options[:action].is_a?(Array)
<ide> def expire_page(options = {})
<ide> # If no options are provided, the requested url is used. Example:
<ide> # cache_page "I'm the cached content", :controller => "lists", :action => "show"
<ide> def cache_page(content = nil, options = nil)
<del> return unless perform_caching && caching_allowed
<add> return unless config.perform_caching && caching_allowed
<ide>
<ide> path = case options
<ide> when Hash
<ide><path>actionpack/lib/action_view/helpers/cache_helper.rb
<ide> def cache(name = {}, options = nil, &block)
<ide> private
<ide> # TODO: Create an object that has caching read/write on it
<ide> def fragment_for(name = {}, options = nil, &block) #:nodoc:
<del> if controller.perform_caching
<add> if controller.config.perform_caching
<ide> if controller.fragment_exist?(name, options)
<ide> controller.read_fragment(name, options)
<ide> else | 3 |
Python | Python | fix typo in numpy.loadtxt documentation | 905dd9a34707cf4bd4b5533b12a68e027751ab92 | <ide><path>numpy/lib/npyio.py
<ide> def loadtxt(fname, dtype=float, comments='#', delimiter=None,
<ide> fname : file, str, or pathlib.Path
<ide> File, filename, or generator to read. If the filename extension is
<ide> ``.gz`` or ``.bz2``, the file is first decompressed. Note that
<del> generators should return byte strings for Python 3k.
<add> generators should return byte strings for Python 3.
<ide> dtype : data-type, optional
<ide> Data-type of the resulting array; default: float. If this is a
<ide> structured data-type, the resulting array will be 1-dimensional, and | 1 |
Javascript | Javascript | add util namespace | 2aa09fd15aecdf366f355725e6c788d73f7aab97 | <ide><path>build/source-loader.js
<ide> var sourceFiles = [
<ide> "src/js/core-object.js",
<ide> "src/js/events.js",
<ide> "src/js/lib.js",
<add> "src/js/util.js",
<ide> "src/js/component.js",
<ide> "src/js/button.js",
<ide> "src/js/slider.js",
<ide><path>src/js/component.js
<ide> vjs.Component.prototype.options_;
<ide> vjs.Component.prototype.options = function(obj){
<ide> if (obj === undefined) return this.options_;
<ide>
<del> return this.options_ = vjs.obj.deepMerge(this.options_, obj);
<add> return this.options_ = vjs.util.mergeOptions(this.options_, obj);
<ide> };
<ide>
<ide> /**
<ide><path>src/js/util.js
<add>/**
<add> * Utility functions namespace
<add> * @namespace
<add> * @type {Object}
<add> */
<add>vjs.util = {};
<add>
<add>/**
<add> * Merge two options objects,
<add> * recursively merging any plain object properties as well.
<add> * Previously `deepMerge`
<add> *
<add> * @param {Object} obj1 Object to override values in
<add> * @param {Object} obj2 Overriding object
<add> * @return {Object} New object -- obj1 and obj2 will be untouched
<add> */
<add>vjs.util.mergeOptions = function(obj1, obj2){
<add> var key, val1, val2;
<add>
<add> // make a copy of obj1 so we're not ovewriting original values.
<add> // like prototype.options_ and all sub options objects
<add> obj1 = vjs.obj.copy(obj1);
<add>
<add> for (key in obj2){
<add> if (obj2.hasOwnProperty(key)) {
<add> val1 = obj1[key];
<add> val2 = obj2[key];
<add>
<add> // Check if both properties are pure objects and do a deep merge if so
<add> if (vjs.obj.isPlain(val1) && vjs.obj.isPlain(val2)) {
<add> obj1[key] = vjs.util.mergeOptions(val1, val2);
<add> } else {
<add> obj1[key] = obj2[key];
<add> }
<add> }
<add> }
<add> return obj1;
<add>};
<add>
<add>
<ide><path>test/unit/util.js
<add>module('util');
<add>
<add>test('should merge options objects', function(){
<add> var ob1, ob2, ob3;
<add>
<add> ob1 = {
<add> a: true,
<add> b: { b1: true, b2: true, b3: true },
<add> c: true
<add> };
<add>
<add> ob2 = {
<add> // override value
<add> a: false,
<add> // merge sub-option values
<add> b: { b1: true, b2: false, b4: true },
<add> // add new option
<add> d: true
<add> };
<add>
<add> ob3 = vjs.util.mergeOptions(ob1, ob2);
<add>
<add> deepEqual(ob3, {
<add> a: false,
<add> b: { b1: true, b2: false, b3: true, b4: true },
<add> c: true,
<add> d: true
<add> }, 'options objects merged correctly');
<add>});
<ide>\ No newline at end of file | 4 |
Mixed | Python | fix conftest getoption | 73255091f88b20f74ce410fc2d5e71a33e3420bd | <ide><path>.github/contributors/njsmith.md
<add># spaCy contributor agreement
<add>
<add>This spaCy Contributor Agreement (**"SCA"**) is based on the
<add>[Oracle Contributor Agreement](http://www.oracle.com/technetwork/oca-405177.pdf).
<add>The SCA applies to any contribution that you make to any product or project
<add>managed by us (the **"project"**), and sets out the intellectual property rights
<add>you grant to us in the contributed materials. The term **"us"** shall mean
<add>[ExplosionAI UG (haftungsbeschränkt)](https://explosion.ai/legal). The term
<add>**"you"** shall mean the person or entity identified below.
<add>
<add>If you agree to be bound by these terms, fill in the information requested
<add>below and include the filled-in version with your first pull request, under the
<add>folder [`.github/contributors/`](/.github/contributors/). The name of the file
<add>should be your GitHub username, with the extension `.md`. For example, the user
<add>example_user would create the file `.github/contributors/example_user.md`.
<add>
<add>Read this agreement carefully before signing. These terms and conditions
<add>constitute a binding legal agreement.
<add>
<add>## Contributor Agreement
<add>
<add>1. The term "contribution" or "contributed materials" means any source code,
<add>object code, patch, tool, sample, graphic, specification, manual,
<add>documentation, or any other material posted or submitted by you to the project.
<add>
<add>2. With respect to any worldwide copyrights, or copyright applications and
<add>registrations, in your contribution:
<add>
<add> * you hereby assign to us joint ownership, and to the extent that such
<add> assignment is or becomes invalid, ineffective or unenforceable, you hereby
<add> grant to us a perpetual, irrevocable, non-exclusive, worldwide, no-charge,
<add> royalty-free, unrestricted license to exercise all rights under those
<add> copyrights. This includes, at our option, the right to sublicense these same
<add> rights to third parties through multiple levels of sublicensees or other
<add> licensing arrangements;
<add>
<add> * you agree that each of us can do all things in relation to your
<add> contribution as if each of us were the sole owners, and if one of us makes
<add> a derivative work of your contribution, the one who makes the derivative
<add> work (or has it made will be the sole owner of that derivative work;
<add>
<add> * you agree that you will not assert any moral rights in your contribution
<add> against us, our licensees or transferees;
<add>
<add> * you agree that we may register a copyright in your contribution and
<add> exercise all ownership rights associated with it; and
<add>
<add> * you agree that neither of us has any duty to consult with, obtain the
<add> consent of, pay or render an accounting to the other for any use or
<add> distribution of your contribution.
<add>
<add>3. With respect to any patents you own, or that you can license without payment
<add>to any third party, you hereby grant to us a perpetual, irrevocable,
<add>non-exclusive, worldwide, no-charge, royalty-free license to:
<add>
<add> * make, have made, use, sell, offer to sell, import, and otherwise transfer
<add> your contribution in whole or in part, alone or in combination with or
<add> included in any product, work or materials arising out of the project to
<add> which your contribution was submitted, and
<add>
<add> * at our option, to sublicense these same rights to third parties through
<add> multiple levels of sublicensees or other licensing arrangements.
<add>
<add>4. Except as set out above, you keep all right, title, and interest in your
<add>contribution. The rights that you grant to us under these terms are effective
<add>on the date you first submitted a contribution to us, even if your submission
<add>took place before the date you sign these terms.
<add>
<add>5. You covenant, represent, warrant and agree that:
<add>
<add> * Each contribution that you submit is and shall be an original work of
<add> authorship and you can legally grant the rights set out in this SCA;
<add>
<add> * to the best of your knowledge, each contribution will not violate any
<add> third party's copyrights, trademarks, patents, or other intellectual
<add> property rights; and
<add>
<add> * each contribution shall be in compliance with U.S. export control laws and
<add> other applicable export and import laws. You agree to notify us if you
<add> become aware of any circumstance which would make any of the foregoing
<add> representations inaccurate in any respect. We may publicly disclose your
<add> participation in the project, including the fact that you have signed the SCA.
<add>
<add>6. This SCA is governed by the laws of the State of California and applicable
<add>U.S. Federal law. Any choice of law rules will not apply.
<add>
<add>7. Please place an “x” on one of the applicable statement below. Please do NOT
<add>mark both statements:
<add>
<add> * [x] I am signing on behalf of myself as an individual and no other person
<add> or entity, including my employer, has or will have rights with respect to my
<add> contributions.
<add>
<add> * [ ] I am signing on behalf of my employer or a legal entity and I have the
<add> actual authority to contractually bind that entity.
<add>
<add>## Contributor Details
<add>
<add>| Field | Entry |
<add>|------------------------------- | -------------------- |
<add>| Name | Nathaniel J. Smith |
<add>| Company name (if applicable) | |
<add>| Title or role (if applicable) | |
<add>| Date | 2018-08-26 |
<add>| GitHub username | njsmith |
<add>| Website (optional) | https://vorpus.org |
<ide><path>spacy/tests/conftest.py
<ide> def ur_tokenizer():
<ide> def ru_tokenizer():
<ide> pymorphy = pytest.importorskip("pymorphy2")
<ide> return get_lang_class("ru").Defaults.create_tokenizer()
<add>
<add>def pytest_runtest_setup(item):
<add> def getopt(opt):
<add> # When using 'pytest --pyargs spacy' to test an installed copy of
<add> # spacy, pytest skips running our pytest_addoption() hook. Later, when
<add> # we call getoption(), pytest raises an error, because it doesn't
<add> # recognize the option we're asking about. To avoid this, we need to
<add> # pass a default value. We default to False, i.e., we act like all the
<add> # options weren't given.
<add> return item.config.getoption("--%s" % opt, False)
<add>
<add> for opt in ['models', 'vectors', 'slow']:
<add> if opt in item.keywords and not getopt(opt):
<add> pytest.skip("need --%s option to run" % opt)
<add>
<add> # Check if test is marked with models and has arguments set, i.e. specific
<add> # language. If so, skip test if flag not set.
<add> if item.get_marker('models'):
<add> for arg in item.get_marker('models').args:
<add> if not getopt(arg) and not getopt("all"):
<add> pytest.skip("need --%s or --all option to run" % arg) | 2 |
Java | Java | replace readcancellationexception with takewhile | 3a48682226615aaea3b63755c25763877c35dfd8 | <ide><path>spring-webflux/src/main/java/org/springframework/web/reactive/function/BodyExtractors.java
<ide> /*
<del> * Copyright 2002-2018 the original author or authors.
<add> * Copyright 2002-2019 the original author or authors.
<ide> *
<ide> * Licensed under the Apache License, Version 2.0 (the "License");
<ide> * you may not use this file except in compliance with the License.
<ide> private static <T> Supplier<Mono<T>> skipBodyAsMono(ReactiveHttpInputMessage mes
<ide> () -> consumeAndCancel(message).then(Mono.empty()) : Mono::empty;
<ide> }
<ide>
<del> private static Mono<Void> consumeAndCancel(ReactiveHttpInputMessage message) {
<del> return message.getBody()
<del> .map(buffer -> {
<del> DataBufferUtils.release(buffer);
<del> throw new ReadCancellationException();
<del> })
<del> .onErrorResume(ReadCancellationException.class, ex -> Mono.empty())
<del> .then();
<del> }
<del>
<del> @SuppressWarnings("serial")
<del> private static class ReadCancellationException extends RuntimeException {
<add> private static Flux<DataBuffer> consumeAndCancel(ReactiveHttpInputMessage message) {
<add> return message.getBody().takeWhile(buffer -> {
<add> DataBufferUtils.release(buffer);
<add> return false;
<add> });
<ide> }
<ide>
<ide> } | 1 |
Ruby | Ruby | fix failing tests in activejob adapter | a70bdfe6e391a35b74c42a96488d4e0e2f7c8200 | <ide><path>activejob/lib/active_job/queue_adapters/test_adapter.rb
<ide> module QueueAdapters
<ide> class TestAdapter
<ide> attr_accessor(:perform_enqueued_jobs) { false }
<ide> attr_accessor(:perform_enqueued_at_jobs) { false }
<add> delegate :name, to: :class
<ide>
<ide> # Provides a store of all the enqueued jobs with the TestAdapter so you can check them.
<ide> def enqueued_jobs | 1 |
Text | Text | add deprecation policy to release notes | a08fa7c71ed026cad0ec9832b34f95fe38725e53 | <ide><path>docs/topics/release-notes.md
<ide>
<ide> Minor version numbers (0.0.x) are used for changes that are API compatible. You should be able to upgrade between minor point releases without any other code changes.
<ide>
<del>Medium version numbers (0.x.0) may include minor API changes. You should read the release notes carefully before upgrading between medium point releases.
<add>Medium version numbers (0.x.0) may include API changes, in line with the [deprecation policy][deprecation-policy]. You should read the release notes carefully before upgrading between medium point releases.
<ide>
<del>Major version numbers (x.0.0) are reserved for project milestones. No major point releases are currently planned.
<add>Major version numbers (x.0.0) are reserved for substantial project milestones. No major point releases are currently planned.
<add>
<add>## Deprecation policy
<add>
<add>REST framework releases follow a formal deprecation policy, which is in line with [Django's deprecation policy][django-deprecation-policy].
<add>
<add>The timeline for deprecation of a feature present in version 1.0 would work as follows:
<add>
<add>* Version 1.1 would remain **fully backwards compatible** with 1.0, but would raise `PendingDeprecationWarning` warnings if you use the feature that are due to be deprecated. These warnings are **silent by default**, but can be explicitly enabled when you're ready to start migrating any required changes. For example if you start running your tests using `python -Wd manage.py test`, you'll be warned of any API changes you need to make.
<add>
<add>* Version 1.2 would escalate these warnings to `DeprecationWarning`, which is loud by default.
<add>
<add>* Version 1.3 would remove the deprecated bits of API entirely.
<add>
<add>Note that in line with Django's policy, any parts of the framework not mentioned in the documentation should generally be considered private API, and may be subject to change.
<ide>
<ide> ## Upgrading
<ide>
<ide> You can determine your currently installed version using `pip freeze`:
<ide>
<ide> ---
<ide>
<del>## 2.1.x series
<add>## 2.2.x series
<add>
<add>### 2.2.0
<ide>
<del>### Master
<add>**Date**: 13th Feb 2013
<ide>
<ide> * Python 3 support.
<ide> * Added a `post_save()` hook to the generic views.
<ide> You can determine your currently installed version using `pip freeze`:
<ide> * Deprecate `null=True` on relations in favor of `required=False`.
<ide> * Deprecate `blank=True` on CharFields, just use `required=False`.
<ide> * Deprecate optional `obj` argument in permissions checks in favor of `has_object_permission`.
<add>* Deprecate implicit hyperlinked relations behavior.
<ide> * Bugfix: Allow serializer output to be cached.
<ide> * Bugfix: Fix styling on browsable API login.
<ide> * Bugfix: Fix issue with deserializing empty to-many relations.
<ide> * Bugfix: Ensure model field validation is still applied for ModelSerializer subclasses with an custom `.restore_object()` method.
<ide>
<add>**Note**: See the [2.2 announcement][2.2-announcement] for full details.
<add>
<add>---
<add>
<add>## 2.1.x series
<add>
<ide> ### 2.1.17
<ide>
<ide> **Date**: 26th Jan 2013
<ide> This change will not affect user code, so long as it's following the recommended
<ide> * Initial release.
<ide>
<ide> [cite]: http://www.catb.org/~esr/writings/cathedral-bazaar/cathedral-bazaar/ar01s04.html
<add>[deprecation-policy]: #deprecation-policy
<add>[django-deprecation-policy]: https://docs.djangoproject.com/en/dev/internals/release-process/#internal-release-deprecation-policy
<add>[2.2-announcement]: 2.2-announcement.md
<ide> [staticfiles14]: https://docs.djangoproject.com/en/1.4/howto/static-files/#with-a-template-tag
<ide> [staticfiles13]: https://docs.djangoproject.com/en/1.3/howto/static-files/#with-a-template-tag
<ide> [2.1.0-notes]: https://groups.google.com/d/topic/django-rest-framework/Vv2M0CMY9bg/discussion | 1 |
Javascript | Javascript | add islocal(), isutc() == isutc(), isutcoffset() | 272fe3c6f8aff6a695564ce9856f2c549362c4b7 | <ide><path>moment.js
<ide> }
<ide> },
<ide>
<add> isLocal : function () {
<add> return !this._isUTC;
<add> },
<add>
<add> isUtcOffset : function () {
<add> return this._isUTC;
<add> },
<add>
<add> isUtc : function () {
<add> return this._isUTC && this._offset === 0;
<add> },
<add>
<ide> zoneAbbr : function () {
<ide> return this._isUTC ? 'UTC' : '';
<ide> },
<ide> // add aliased format methods
<ide> moment.fn.toJSON = moment.fn.toISOString;
<ide>
<add> // alias isUtc for dev-friendliness
<add> moment.fn.isUTC = moment.fn.isUtc;
<add>
<ide> /************************************
<ide> Duration Prototype
<ide> ************************************/
<ide><path>test/moment/offset.js
<ide> exports.offset = {
<ide> test.equal(m.clone().utcOffset('-01:30').utcOffset(), -90, 'utcOffset +01:30 is 90');
<ide> test.equal(m.clone().utcOffset('-0130').utcOffset(), -90, 'utcOffset +0130 is 90');
<ide>
<add> test.done();
<add> },
<add>
<add> 'isLocal, isUtc, isUtcOffset' : function (test) {
<add> test.ok(moment().isLocal(), 'moment() creates objects in local time');
<add> test.ok(!moment.utc().isLocal(), 'moment.utc creates objects NOT in local time');
<add> test.ok(moment.utc().local().isLocal(), 'moment.fn.local() converts to local time');
<add> test.ok(!moment().utcOffset(5).isLocal(), 'moment.fn.utcOffset(N) puts objects NOT in local time');
<add> test.ok(moment().utcOffset(5).local().isLocal(), 'moment.fn.local() converts to local time');
<add>
<add> test.ok(moment.utc().isUtc(), 'moment.utc() creates objects in utc time');
<add> test.ok(moment().utcOffset(0).isUtc(), 'utcOffset(0) is equivalent to utc mode');
<add> test.ok(!moment().utcOffset(1).isUtc(), 'utcOffset(1) is NOT equivalent to utc mode');
<add>
<add> test.ok(!moment().isUtcOffset(), 'moment() creates objects NOT in utc-offset mode');
<add> test.ok(moment.utc().isUtcOffset(), 'moment.utc() creates objects in utc-offset mode');
<add> test.ok(moment().utcOffset(3).isUtcOffset(), 'utcOffset(N != 0) creates objects in utc-offset mode');
<add> test.ok(moment().utcOffset(0).isUtcOffset(), 'utcOffset(0) creates objects in utc-offset mode');
<add>
<add> test.done();
<add> },
<add>
<add> 'isUTC' : function (test) {
<add> test.ok(moment.utc().isUTC(), 'moment.utc() creates objects in utc time');
<add> test.ok(moment().utcOffset(0).isUTC(), 'utcOffset(0) is equivalent to utc mode');
<add> test.ok(!moment().utcOffset(1).isUTC(), 'utcOffset(1) is NOT equivalent to utc mode');
<add>
<ide> test.done();
<ide> }
<ide> }; | 2 |
Text | Text | fix several typos | c0c58b6b46626c0ae5cc9c0b37519c505f5a8484 | <ide><path>docs/sources/articles/networking.md
<ide> Four different options affect container domain name services.
<ide> when a bare unqualified hostname is used inside of the container, by
<ide> writing `search` lines into the container’s `/etc/resolv.conf`.
<ide> When a container process attempts to access `host` and the search
<del> domain `exmaple.com` is set, for instance, the DNS logic will not
<add> domain `example.com` is set, for instance, the DNS logic will not
<ide> only look up `host` but also `host.example.com`.
<ide>
<ide> Note that Docker, in the absence of either of the last two options
<ide> the previous section to go something like this:
<ide> $ sudo ip netns exec 3004 ip route add 10.1.1.1/32 dev B
<ide>
<ide> The two containers should now be able to ping each other and make
<del>connections sucessfully. Point-to-point links like this do not depend
<add>connections successfully. Point-to-point links like this do not depend
<ide> on a subnet nor a netmask, but on the bare assertion made by `ip route`
<ide> that some other single IP address is connected to a particular network
<ide> interface.
<ide><path>docs/sources/articles/security.md
<ide> use traditional UNIX permission checks to limit access to the control
<ide> socket.
<ide>
<ide> You can also expose the REST API over HTTP if you explicitly decide so.
<del>However, if you do that, being aware of the abovementioned security
<add>However, if you do that, being aware of the above mentioned security
<ide> implication, you should ensure that it will be reachable only from a
<ide> trusted network or VPN; or protected with e.g. `stunnel`
<ide> and client SSL certificates.
<ide><path>docs/sources/index.md
<ide> Docker consists of:
<ide> * The Docker Engine - our lightweight and powerful open source container
<ide> virtualization technology combined with a work flow for building
<ide> and containerizing your applications.
<del>* [Docker Hub](https://hub.docker.com) - our SAAS service for
<add>* [Docker Hub](https://hub.docker.com) - our SaaS service for
<ide> sharing and managing your application stacks.
<ide>
<ide> ## Why Docker?
<ide><path>docs/sources/reference/api/docker_io_oauth_api.md
<ide> an Authorization Code.
<ide> ## 3.2 Get an Access Token
<ide>
<ide> Once the user has authorized your application, a request will be made to
<del>your application'sspecified `redirect_uri` which
<add>your application's specified `redirect_uri` which
<ide> includes a `code` parameter that you must then use
<ide> to get an Access Token.
<ide>
<ide><path>docs/sources/reference/api/docker_remote_api.md
<ide> You can now use the force parameter to force delete of an
<ide> `DELETE /containers/(id)`
<ide>
<ide> **New!**
<del>You can now use the force paramter to force delete a
<add>You can now use the force parameter to force delete a
<ide> container, even if it is currently running
<ide>
<ide> ## v1.9
<ide><path>docs/sources/reference/api/hub_registry_spec.md
<ide> GET /v1/users
<ide> The Registry does not know anything about users. Even though
<ide> repositories are under usernames, it's just a namespace for the
<ide> registry. Allowing us to implement organizations or different namespaces
<del>per user later, without modifying the Registry'sAPI.
<add>per user later, without modifying the Registry's API.
<ide>
<ide> The following naming restrictions apply:
<ide>
<ide><path>docs/sources/reference/commandline/cli.md
<ide> To see how the `docker:latest` image was built:
<ide> The default `docker images` will show all top level
<ide> images, their repository and tags, and their virtual size.
<ide>
<del>Docker images have intermediate layers that increase reuseability,
<add>Docker images have intermediate layers that increase reusability,
<ide> decrease disk usage, and speed up `docker build` by
<ide> allowing each step to be cached. These intermediate layers are not shown
<ide> by default.
<ide> removed before the image is removed.
<ide> 'bridge': creates a new network stack for the container on the docker bridge
<ide> 'none': no networking for this container
<ide> 'container:<name|id>': reuses another container network stack
<del> 'host': use the host network stack inside the contaner
<add> 'host': use the host network stack inside the container
<ide> -p, --publish=[] Publish a container's port to the host
<ide> format: ip:hostPort:containerPort | ip::containerPort | hostPort:containerPort
<ide> (use 'docker port' to see the actual mapping)
<ide><path>docs/sources/reference/run.md
<ide> PID files):
<ide> 'bridge': creates a new network stack for the container on the docker bridge
<ide> 'none': no networking for this container
<ide> 'container:<name|id>': reuses another container network stack
<del> 'host': use the host network stack inside the contaner
<add> 'host': use the host network stack inside the container
<ide>
<ide> By default, all containers have networking enabled and they can make any
<ide> outgoing connections. The operator can completely disable networking | 8 |
Javascript | Javascript | remove duplicate `props_helper` module | 80be0ac7c8ab46f6ed09d27ca87bf6877c20229b | <ide><path>packages/ember-metal/tests/accessors/get_test.js
<del>import testBoth from 'ember-metal/tests/props_helper';
<add>import { testBoth } from 'ember-metal/tests/props_helper';
<ide> import {
<ide> get,
<ide> getWithDefault
<ide><path>packages/ember-metal/tests/binding/connect_test.js
<ide> import Ember from 'ember-metal/core';
<del>import testBoth from 'ember-metal/tests/props_helper';
<add>import { testBoth } from 'ember-metal/tests/props_helper';
<ide> import {
<ide> Binding,
<ide> bind
<ide><path>packages/ember-metal/tests/binding/sync_test.js
<del>import testBoth from 'ember-metal/tests/props_helper';
<add>import { testBoth } from 'ember-metal/tests/props_helper';
<ide> import run from 'ember-metal/run_loop';
<ide> import {
<ide> addObserver
<ide><path>packages/ember-metal/tests/computed_test.js
<ide> import Ember from 'ember-metal/core';
<del>import testBoth from 'ember-metal/tests/props_helper';
<add>import { testBoth } from 'ember-metal/tests/props_helper';
<ide> import { create } from 'ember-metal/platform';
<ide> import {
<ide> ComputedProperty,
<ide><path>packages/ember-metal/tests/mixin/observer_test.js
<del>/*globals testBoth */
<del>
<del>import testBoth from 'ember-metal/tests/props_helper';
<add>import { testBoth } from 'ember-metal/tests/props_helper';
<ide> import {
<ide> observer,
<ide> mixin,
<ide><path>packages/ember-metal/tests/observer_test.js
<ide> import Ember from 'ember-metal/core';
<del>import testBoth from 'ember-metal/tests/props_helper';
<add>import { testBoth } from 'ember-metal/tests/props_helper';
<ide> import {
<ide> addObserver,
<ide> removeObserver,
<ide><path>packages/ember-metal/tests/props_helper.js
<del>import { get } from 'ember-metal/property_get';
<del>import { set } from 'ember-metal/property_set';
<add>import Ember from 'ember-metal/core';
<add>import {get as getFromEmberMetal, getWithDefault as getWithDefaultFromEmberMetal} from 'ember-metal/property_get';
<add>import {set as setFromEmberMetal} from 'ember-metal/property_set';
<ide>
<ide> // used by unit tests to test both accessor mode and non-accessor mode
<del>export default function(testname, callback) {
<del> test(testname+' using Ember.get()/Ember.set()', function() {
<del> callback(get, set);
<add>var testBoth = function(testname, callback) {
<add>
<add> function emberget(x,y) { return getFromEmberMetal(x,y); }
<add> function emberset(x,y,z) { return setFromEmberMetal(x,y,z); }
<add> function aget(x,y) { return x[y]; }
<add> function aset(x,y,z) { return (x[y] = z); }
<add>
<add> test(testname+' using getFromEmberMetal()/Ember.set()', function() {
<add> callback(emberget, emberset);
<add> });
<add>
<add> test(testname+' using accessors', function() {
<add> if (Ember.USES_ACCESSORS) callback(aget, aset);
<add> else ok('SKIPPING ACCESSORS');
<add> });
<add>};
<add>
<add>var testWithDefault = function(testname, callback) {
<add> function emberget(x,y) { return getFromEmberMetal(x,y); }
<add> function embergetwithdefault(x,y,z) { return getWithDefaultFromEmberMetal(x,y,z); }
<add> function getwithdefault(x,y,z) { return x.getWithDefault(y,z); }
<add> function emberset(x,y,z) { return setFromEmberMetal(x,y,z); }
<add> function aget(x,y) { return x[y]; }
<add> function aset(x,y,z) { return (x[y] = z); }
<add>
<add> test(testname+' using obj.get()', function() {
<add> callback(emberget, emberset);
<add> });
<add>
<add> test(testname+' using obj.getWithDefault()', function() {
<add> callback(getwithdefault, emberset);
<add> });
<add>
<add> test(testname+' using getFromEmberMetal()', function() {
<add> callback(emberget, emberset);
<add> });
<add>
<add> test(testname+' using Ember.getWithDefault()', function() {
<add> callback(embergetwithdefault, emberset);
<add> });
<add>
<add> test(testname+' using accessors', function() {
<add> if (Ember.USES_ACCESSORS) callback(aget, aset);
<add> else ok('SKIPPING ACCESSORS');
<ide> });
<add>};
<ide>
<del> // test(testname+' using accessors', function() {
<del> // if (Ember.USES_ACCESSORS) callback(aget, aset);
<del> // else ok('SKIPPING ACCESSORS');
<del> // });
<del>}
<add>export {testWithDefault, testBoth};
<ide><path>packages/ember-metal/tests/watching/unwatch_test.js
<del>import testBoth from 'ember-metal/tests/props_helper';
<add>import { testBoth } from 'ember-metal/tests/props_helper';
<ide> import {
<ide> watch,
<ide> unwatch
<ide><path>packages/ember-metal/tests/watching/watch_test.js
<ide> import Ember from 'ember-metal/core';
<del>import testBoth from 'ember-metal/tests/props_helper';
<add>import { testBoth } from 'ember-metal/tests/props_helper';
<ide> import { indexOf } from 'ember-metal/enumerable_utils';
<ide> import { addListener } from "ember-metal/events";
<ide> import {
<ide> function addListeners(obj, keyPath) {
<ide> }
<ide>
<ide> testBoth('watching a computed property', function(get, set) {
<del>
<ide> var obj = {};
<ide> Ember.defineProperty(obj, 'foo', Ember.computed(function(keyName, value) {
<ide> if (value !== undefined) this.__foo = value;
<ide> testBoth('watching a computed property', function(get, set) {
<ide> });
<ide>
<ide> testBoth('watching a regular defined property', function(get, set) {
<del>
<ide> var obj = { foo: 'baz' };
<ide> addListeners(obj, 'foo');
<ide>
<ide> testBoth('watching a regular defined property', function(get, set) {
<ide> });
<ide>
<ide> testBoth('watching a regular undefined property', function(get, set) {
<del>
<ide> var obj = { };
<ide> addListeners(obj, 'foo');
<ide>
<ide> testBoth('watching a regular undefined property', function(get, set) {
<ide> });
<ide>
<ide> testBoth('watches should inherit', function(get, set) {
<del>
<ide> var obj = { foo: 'baz' };
<ide> var objB = Ember.create(obj);
<ide>
<ide> testBoth('watches should inherit', function(get, set) {
<ide> });
<ide>
<ide> test("watching an object THEN defining it should work also", function() {
<del>
<ide> var obj = {};
<ide> addListeners(obj, 'foo');
<ide>
<ide> test("watching a chain then defining the nested property", function () {
<ide> });
<ide>
<ide> testBoth('watching an object value then unwatching should restore old value', function(get, set) {
<del>
<ide> var obj = { foo: { bar: { baz: { biff: 'BIFF' } } } };
<ide> addListeners(obj, 'foo.bar.baz.biff');
<ide>
<ide> testBoth('watching a global object that does not yet exist should queue', functi
<ide> });
<ide>
<ide> test('when watching a global object, destroy should remove chain watchers from the global object', function() {
<del>
<ide> lookup['Global'] = Global = { foo: 'bar' };
<ide> var obj = {};
<ide> addListeners(obj, 'Global.foo');
<ide> test('when watching a global object, destroy should remove chain watchers from t
<ide> });
<ide>
<ide> test('when watching another object, destroy should remove chain watchers from the other object', function() {
<del>
<ide> var objA = {};
<ide> var objB = {foo: 'bar'};
<ide> objA.b = objB;
<ide> test('when watching another object, destroy should remove chain watchers from th
<ide> // TESTS for length property
<ide>
<ide> testBoth('watching "length" property on an object', function(get, set) {
<del>
<ide> var obj = { length: '26.2 miles' };
<ide> addListeners(obj, 'length');
<ide>
<ide> testBoth('watching "length" property on an object', function(get, set) {
<ide> });
<ide>
<ide> testBoth('watching "length" property on an array', function(get, set) {
<del>
<ide> var arr = [];
<ide> addListeners(arr, 'length');
<ide>
<ide><path>packages/ember-runtime/tests/computed/compose_computed_test.js
<ide> import Ember from 'ember-metal/core';
<del>import {addObserver} from 'ember-metal/observer';
<del>import {computed} from 'ember-metal/computed';
<del>import {mapBy, union, sort} from 'ember-runtime/computed/reduce_computed_macros';
<add>import { addObserver } from 'ember-metal/observer';
<add>import { computed } from 'ember-metal/computed';
<add>import { mapBy, union, sort } from 'ember-runtime/computed/reduce_computed_macros';
<ide> import run from 'ember-metal/run_loop';
<del>import {defineProperty} from "ember-metal/properties";
<add>import { defineProperty } from "ember-metal/properties";
<ide> import compare from 'ember-runtime/compare';
<del>import testBoth from 'ember-metal/tests/props_helper';
<add>import { testBoth } from 'ember-metal/tests/props_helper';
<ide> import EmberObject from 'ember-runtime/system/object';
<ide>
<ide> if (Ember.FEATURES.isEnabled('composable-computed-properties')) {
<ide><path>packages/ember-runtime/tests/computed/computed_macros_test.js
<del>import {computed} from "ember-metal/computed";
<add>import { computed } from "ember-metal/computed";
<ide> import EmberObject from "ember-runtime/system/object";
<del>import {testBoth} from "ember-runtime/tests/props_helper";
<add>import { testBoth } from "ember-metal/tests/props_helper";
<ide>
<ide> QUnit.module('CP macros');
<ide>
<ide> testBoth('Ember.computed.notEmpty', function(get, set) {
<ide>
<ide> equal(get(obj, 'bestLannisterSpecified'), true, "empty respects strings");
<ide> equal(get(obj, 'LannistersKnown'), true, "empty respects array mutations");
<del>});
<ide>\ No newline at end of file
<add>});
<ide><path>packages/ember-runtime/tests/ext/function_test.js
<del>import {testBoth} from 'ember-runtime/tests/props_helper';
<add>import { testBoth } from "ember-metal/tests/props_helper";
<ide>
<ide> QUnit.module('Function.prototype.observes() helper');
<ide>
<ide><path>packages/ember-runtime/tests/mixins/array_test.js
<ide> import { set } from "ember-metal/property_set";
<ide> import { addObserver } from "ember-metal/observer";
<ide> import { observer as emberObserver } from "ember-metal/mixin";
<ide> import { computed } from "ember-metal/computed";
<del>import { testBoth } from 'ember-runtime/tests/props_helper';
<del>import { ArrayTests } from 'ember-runtime/tests/suites/array';
<del>import EmberObject from 'ember-runtime/system/object';
<add>import { testBoth } from "ember-metal/tests/props_helper";
<add>import { ArrayTests } from "ember-runtime/tests/suites/array";
<add>import EmberObject from "ember-runtime/system/object";
<ide> import EmberArray from "ember-runtime/mixins/array";
<ide>
<ide> /*
<ide><path>packages/ember-runtime/tests/mixins/observable_test.js
<ide> import { computed } from "ember-metal/computed";
<ide> import { addObserver } from "ember-metal/observer";
<del>import EmberObject from 'ember-runtime/system/object';
<del>import { testBoth } from 'ember-runtime/tests/props_helper';
<add>import EmberObject from "ember-runtime/system/object";
<add>import { testBoth } from "ember-metal/tests/props_helper";
<ide>
<ide> QUnit.module('mixins/observable');
<ide>
<ide><path>packages/ember-runtime/tests/props_helper.js
<del>import Ember from 'ember-metal/core';
<del>import {get as getFromEmberMetal, getWithDefault as getWithDefaultFromEmberMetal} from 'ember-metal/property_get';
<del>import {set as setFromEmberMetal} from 'ember-metal/property_set';
<del>
<del>// used by unit tests to test both accessor mode and non-accessor mode
<del>var testBoth = function(testname, callback) {
<del>
<del> function emberget(x,y) { return getFromEmberMetal(x,y); }
<del> function emberset(x,y,z) { return setFromEmberMetal(x,y,z); }
<del> function aget(x,y) { return x[y]; }
<del> function aset(x,y,z) { return (x[y] = z); }
<del>
<del> test(testname+' using getFromEmberMetal()/Ember.set()', function() {
<del> callback(emberget, emberset);
<del> });
<del>
<del> test(testname+' using accessors', function() {
<del> if (Ember.USES_ACCESSORS) callback(aget, aset);
<del> else ok('SKIPPING ACCESSORS');
<del> });
<del>};
<del>
<del>var testWithDefault = function(testname, callback) {
<del> function emberget(x,y) { return getFromEmberMetal(x,y); }
<del> function embergetwithdefault(x,y,z) { return getWithDefaultFromEmberMetal(x,y,z); }
<del> function getwithdefault(x,y,z) { return x.getWithDefault(y,z); }
<del> function emberset(x,y,z) { return setFromEmberMetal(x,y,z); }
<del> function aget(x,y) { return x[y]; }
<del> function aset(x,y,z) { return (x[y] = z); }
<del>
<del> test(testname+' using obj.get()', function() {
<del> callback(emberget, emberset);
<del> });
<del>
<del> test(testname+' using obj.getWithDefault()', function() {
<del> callback(getwithdefault, emberset);
<del> });
<del>
<del> test(testname+' using getFromEmberMetal()', function() {
<del> callback(emberget, emberset);
<del> });
<del>
<del> test(testname+' using Ember.getWithDefault()', function() {
<del> callback(embergetwithdefault, emberset);
<del> });
<del>
<del> test(testname+' using accessors', function() {
<del> if (Ember.USES_ACCESSORS) callback(aget, aset);
<del> else ok('SKIPPING ACCESSORS');
<del> });
<del>};
<del>
<del>export {testWithDefault, testBoth};
<ide><path>packages/ember-runtime/tests/system/object/computed_test.js
<del>import {computed} from "ember-metal/computed";
<del>import {get as emberGet} from "ember-metal/property_get";
<del>import {observer} from "ember-metal/mixin";
<del>import { testWithDefault } from 'ember-runtime/tests/props_helper';
<add>import { computed } from "ember-metal/computed";
<add>import { get as emberGet } from "ember-metal/property_get";
<add>import { observer } from "ember-metal/mixin";
<add>import { testWithDefault } from "ember-metal/tests/props_helper";
<ide> import EmberObject from "ember-runtime/system/object";
<ide>
<ide> function K() { return this; }
<ide><path>packages/ember-runtime/tests/system/object/destroy_test.js
<ide> import {
<ide> endPropertyChanges
<ide> } from "ember-metal/property_events";
<ide> import objectKeys from "ember-metal/keys";
<del>import { testBoth } from 'ember-runtime/tests/props_helper';
<del>import EmberObject from 'ember-runtime/system/object';
<add>import { testBoth } from "ember-metal/tests/props_helper";
<add>import EmberObject from "ember-runtime/system/object";
<ide>
<ide> QUnit.module('ember-runtime/system/object/destroy_test');
<ide>
<ide><path>packages/ember-runtime/tests/system/object/observer_test.js
<ide> import Ember from "ember-metal/core";
<del>import {observer} from "ember-metal/mixin";
<add>import { observer } from "ember-metal/mixin";
<ide> import run from "ember-metal/run_loop";
<del>import {testBoth} from 'ember-runtime/tests/props_helper';
<add>import { testBoth } from "ember-metal/tests/props_helper";
<ide> import EmberObject from "ember-runtime/system/object";
<ide>
<ide> QUnit.module('EmberObject observer');
<ide><path>packages/ember-runtime/tests/system/object_proxy_test.js
<del>import {addObserver, removeObserver} from "ember-metal/observer";
<del>import {computed} from "ember-metal/computed";
<del>import {isWatching} from "ember-metal/watching";
<del>import {testBoth} from 'ember-runtime/tests/props_helper';
<add>import { addObserver, removeObserver } from "ember-metal/observer";
<add>import { computed } from "ember-metal/computed";
<add>import { isWatching } from "ember-metal/watching";
<add>import { testBoth } from "ember-metal/tests/props_helper";
<ide> import ObjectProxy from "ember-runtime/system/object_proxy";
<ide>
<ide> QUnit.module("ObjectProxy"); | 19 |
PHP | PHP | update the count of engines built-in | 168b640d1745061a1530866727c0098dad8ffe20 | <ide><path>src/Cache/Cache.php
<ide> * In general all Cache operations are supported by all cache engines.
<ide> * However, Cache::increment() and Cache::decrement() are not supported by File caching.
<ide> *
<del> * There are 6 built-in caching engines:
<add> * There are 7 built-in caching engines:
<ide> *
<ide> * - `ApcuEngine` - Uses the APCu object cache, one of the fastest caching engines.
<ide> * - `ArrayEngine` - Uses only memory to store all data, not actually a persistent engin. | 1 |
Python | Python | add extra data | 8e10f52d7032d38be799752d1a6dc7fc373b3025 | <ide><path>libcloud/test/compute/test_openstack.py
<ide> def test_ex_list_routers(self):
<ide> self.assertEqual(len(routers), 2)
<ide> self.assertEqual(router.name, 'router2')
<ide> self.assertEqual(router.status, 'ACTIVE')
<del> self.assertEqual(router.extra['routes'], [])
<add> self.assertEqual(router.extra['routes'], [{'destination': '179.24.1.0/24',
<add> 'nexthop': '172.24.3.99'}])
<ide>
<ide> def test_ex_create_router(self):
<ide> router = self.driver.ex_create_router('router1', admin_state_up = True) | 1 |
PHP | PHP | make seeder and its run() method abstract | 65f69f0ebf1622ae5e0ffb23d8e1ac1e178b03fa | <ide><path>src/Illuminate/Database/Seeder.php
<ide> use Illuminate\Console\Command;
<ide> use Illuminate\Container\Container;
<ide>
<del>class Seeder
<add>abstract class Seeder
<ide> {
<ide> /**
<ide> * The container instance.
<ide> class Seeder
<ide> *
<ide> * @return void
<ide> */
<del> public function run()
<del> {
<del> //
<del> }
<add> abstract public function run();
<ide>
<ide> /**
<ide> * Seed the given connection from the given path.
<ide><path>tests/Database/DatabaseSeederTest.php
<ide> use Mockery as m;
<ide> use Illuminate\Database\Seeder;
<ide>
<add>class TestSeeder extends Seeder
<add>{
<add> public function run()
<add> {
<add> //
<add> }
<add>}
<add>
<ide> class DatabaseSeederTest extends PHPUnit_Framework_TestCase
<ide> {
<ide> public function tearDown()
<ide> public function tearDown()
<ide>
<ide> public function testCallResolveTheClassAndCallsRun()
<ide> {
<del> $seeder = new Seeder;
<add> $seeder = new TestSeeder;
<ide> $seeder->setContainer($container = m::mock('Illuminate\Container\Container'));
<ide> $output = m::mock('Symfony\Component\Console\Output\OutputInterface');
<ide> $output->shouldReceive('writeln')->once()->andReturn('foo');
<ide> public function testCallResolveTheClassAndCallsRun()
<ide>
<ide> public function testSetContainer()
<ide> {
<del> $seeder = new Seeder;
<add> $seeder = new TestSeeder;
<ide> $container = m::mock('Illuminate\Container\Container');
<ide> $this->assertEquals($seeder->setContainer($container), $seeder);
<ide> }
<ide>
<ide> public function testSetCommand()
<ide> {
<del> $seeder = new Seeder;
<add> $seeder = new TestSeeder;
<ide> $command = m::mock('Illuminate\Console\Command');
<ide> $this->assertEquals($seeder->setCommand($command), $seeder);
<ide> } | 2 |
Javascript | Javascript | add all extrude parameters | f04b450af203ecd829516c45ad5cc43b20f9cd96 | <ide><path>editor/js/Sidebar.Geometry.ExtrudeGeometry.js
<ide> * @author Temdog007 / http://github.com/Temdog007
<ide> */
<ide>
<del>Sidebar.Geometry.BoxGeometry = function ( editor, object ) {
<add>Sidebar.Geometry.ExtrudeGeometry = function ( editor, object ) {
<ide>
<ide> var strings = editor.strings;
<ide>
<ide> Sidebar.Geometry.BoxGeometry = function ( editor, object ) {
<ide>
<ide> var geometry = object.geometry;
<ide> var parameters = geometry.parameters;
<del> var options = parameters.options || {
<del> curveSegments : 12,
<del> steps : 1,
<del> depth : 100,
<del> bevelEnabled : true,
<del> bevelThickness : 6,
<del> bevelSize : 4,
<del> bevelOffset : 0,
<del> bevelSegments : 3
<del> };
<add> var options = parameters.options;
<add> options.curveSegments = options.curveSegments != undefined ? options.curveSegments : 12;
<add> options.steps = options.steps != undefined ? options.steps : 1;
<add> options.depth = options.depth != undefined ? options.depth : 100;
<add> options.bevelThickness =options.bevelThickness !== undefined ? options.bevelThickness : 6;
<add> options.bevelSize = options.bevelSize !== undefined ? options.bevelSize : 4;
<add> options.bevelOffset = options.bevelOffset !== undefined ? options.bevelOffset : 0;
<add> options.bevelSegments = options.bevelSegments !== undefined ? options.bevelSegments : 3
<add>
<ide>
<ide> // curveSegments
<ide>
<ide> var curveSegmentsRow = new UI.Row();
<del> var curveSegments = new UI.Number( options.curveSegments ).onChange( update ).setRange(1, Infinity);
<add> var curveSegments = new UI.Integer( options.curveSegments ).onChange( update ).setRange(1, Infinity);
<ide>
<ide> curveSegmentsRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/extrude_geometry/curveSegments' ) ).setWidth( '90px' ) );
<ide> curveSegmentsRow.add( curveSegments );
<ide> Sidebar.Geometry.BoxGeometry = function ( editor, object ) {
<ide> // steps
<ide>
<ide> var stepsRow = new UI.Row();
<del> var steps = new UI.Number( options.steps ).onChange( update ).setRange(1, Infinity);
<add> var steps = new UI.Integer( options.steps ).onChange( update ).setRange(1, Infinity);
<ide>
<ide> stepsRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/extrude_geometry/steps' ) ).setWidth( '90px' ) );
<ide> stepsRow.add( steps );
<ide>
<ide> container.add( stepsRow );
<ide>
<add> // depth
<add>
<add> var depthRow = new UI.Row();
<add> var depth = new UI.Number( options.depth ).onChange( update ).setRange(1, Infinity);
<add>
<add> depthRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/extrude_geometry/depth' ) ).setWidth( '90px' ) );
<add> depthRow.add( depth );
<add>
<add> container.add( depthRow );
<add>
<add> // enabled
<add>
<add> var enabledRow = new UI.Row();
<add> var enabled = new UI.Checkbox( options.bevelEnabled ).onChange( update );
<add>
<add> enabledRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/extrude_geometry/bevelEnabled' ) ).setWidth( '90px' ) );
<add> enabledRow.add( enabled );
<add>
<add> container.add( enabledRow );
<add>
<add> if(options.bevelEnabled === true){
<add>
<add> // thickness
<add>
<add> var thicknessRow = new UI.Row();
<add> var thickness = new UI.Number( options.bevelThickness ).onChange( update );
<add>
<add> thicknessRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/extrude_geometry/bevelThickness' ) ).setWidth( '90px' ) );
<add> thicknessRow.add( thickness );
<add>
<add> container.add( thicknessRow );
<add>
<add> // size
<add>
<add> var sizeRow = new UI.Row();
<add> var size = new UI.Number( options.bevelSize ).onChange( update );
<add>
<add> sizeRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/extrude_geometry/bevelSize' ) ).setWidth( '90px' ) );
<add> sizeRow.add( size );
<add>
<add> container.add( sizeRow );
<add>
<add> // offset
<add>
<add> var offsetRow = new UI.Row();
<add> var offset = new UI.Number( options.bevelOffset ).onChange( update );
<add>
<add> offsetRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/extrude_geometry/bevelOffset' ) ).setWidth( '90px' ) );
<add> offsetRow.add( offset );
<add>
<add> container.add( offsetRow );
<add>
<add> // segments
<add>
<add> var segmentsRow = new UI.Row();
<add> var segments = new UI.Integer( options.bevelSegments ).onChange( update ).setRange(0, Infinity);
<add>
<add> segmentsRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/extrude_geometry/bevelSegments' ) ).setWidth( '90px' ) );
<add> segmentsRow.add( segments );
<add>
<add> container.add( segmentsRow );
<add> }
<add>
<add> var button = new UI.Button(strings.getKey( 'sidebar/geometry/extrude_geometry/shape' )).onClick(toShape).setWidth('90px').setMarginLeft('90px');
<add> container.add(button);
<add>
<ide> //
<ide>
<ide> function update() {
<ide> Sidebar.Geometry.BoxGeometry = function ( editor, object ) {
<ide> parameters.shapes,
<ide> {
<ide> curveSegments : curveSegments.getValue(),
<del> steps : steps.getValue()
<add> steps : steps.getValue(),
<add> depth: depth.getValue(),
<add> bevelEnabled : enabled.getValue(),
<add> bevelThickness : thickness !== undefined ? thickness.getValue() : options.bevelThickness,
<add> bevelSize : size !== undefined ? size.getValue() : options.bevelSize,
<add> bevelOffset : offset !== undefined ? offset.getValue() : options.bevelOffset,
<add> bevelSegments : segments !== undefined ? segments.getValue() : options.bevelSegments
<ide> }
<ide> ) ) );
<ide>
<ide> }
<ide>
<add> function toShape() {
<add> editor.execute( new SetGeometryCommand( object, new THREE.ShapeBufferGeometry(
<add> parameters.shapes,
<add> options.curveSegments
<add> )));
<add> }
<add>
<ide> return container;
<ide>
<ide> };
<ide>
<del>Sidebar.Geometry.BoxBufferGeometry = Sidebar.Geometry.BoxGeometry;
<add>Sidebar.Geometry.ExtrudeBufferGeometry = Sidebar.Geometry.ExtrudeGeometry;
<ide><path>editor/js/Strings.js
<ide> var Strings = function ( config ) {
<ide> 'sidebar/geometry/extrude_geometry/bevelSize': 'Size',
<ide> 'sidebar/geometry/extrude_geometry/bevelOffset': 'Offset',
<ide> 'sidebar/geometry/extrude_geometry/bevelSegments': 'Segments',
<add> 'sidebar/geometry/extrude_geometry/shape': 'Convert to Shape',
<ide>
<ide> 'sidebar/geometry/geometry/vertices': 'Vertices',
<ide> 'sidebar/geometry/geometry/faces': 'Faces', | 2 |
PHP | PHP | add withquerystring method to paginator | ceba11ef3ce9775b04f8169b30c9aab60d0b6810 | <ide><path>src/Illuminate/Pagination/AbstractPaginator.php
<ide> namespace Illuminate\Pagination;
<ide>
<ide> use Closure;
<del>use Illuminate\Contracts\Support\Htmlable;
<ide> use Illuminate\Support\Arr;
<del>use Illuminate\Support\Collection;
<ide> use Illuminate\Support\Str;
<add>use Illuminate\Support\Collection;
<add>use Illuminate\Contracts\Support\Htmlable;
<ide> use Illuminate\Support\Traits\ForwardsCalls;
<ide>
<ide> /**
<ide> abstract class AbstractPaginator implements Htmlable
<ide> */
<ide> protected static $viewFactoryResolver;
<ide>
<add> /**
<add> * The with query string resolver callback.
<add> *
<add> * @var \Closure
<add> */
<add> protected static $queryStringResolver;
<add>
<ide> /**
<ide> * The default pagination view.
<ide> *
<ide> public function appends($key, $value = null)
<ide> return $this->addQuery($key, $value);
<ide> }
<ide>
<add> /**
<add> * Add a set of query string values to the paginator.
<add> *
<add> * @return $this
<add> */
<add> public function withQueryString()
<add> {
<add> if (isset(static::$queryStringResolver)) {
<add> return $this->appends(call_user_func(static::$queryStringResolver));
<add> }
<add>
<add> return $this;
<add> }
<add>
<ide> /**
<ide> * Add an array of query string values.
<ide> *
<ide> public static function viewFactoryResolver(Closure $resolver)
<ide> static::$viewFactoryResolver = $resolver;
<ide> }
<ide>
<add> /**
<add> * Set with query string resolver callback.
<add> *
<add> * @param \Closure $resolver
<add> * @return void
<add> */
<add> public static function withQueryStringResolver(Closure $resolver)
<add> {
<add> static::$queryStringResolver = $resolver;
<add> }
<add>
<ide> /**
<ide> * Set the default pagination view.
<ide> *
<ide><path>src/Illuminate/Pagination/PaginationServiceProvider.php
<ide> public function register()
<ide>
<ide> return 1;
<ide> });
<add>
<add> Paginator::withQueryStringResolver(function () {
<add> return $this->app['request']->query();
<add> });
<ide> }
<ide> } | 2 |
Python | Python | add init vectors | 4925ad760a87d84b7cc4bb2fb48b45845a2e0c30 | <ide><path>spacy/cli/init_pipeline.py
<ide> import typer
<ide>
<ide> from .. import util
<del>from ..training.initialize import init_nlp
<add>from ..training.initialize import init_nlp, convert_vectors
<ide> from ._util import init_cli, Arg, Opt, parse_config_overrides, show_validation_error
<ide> from ._util import import_code, setup_gpu
<ide>
<ide>
<add>@init_cli.command("vectors")
<add>def init_vectors_cli(
<add> # fmt: off
<add> lang: str = Arg(..., help="The language of the nlp object to create"),
<add> vectors_loc: Path = Arg(..., help="Vectors file in Word2Vec format", exists=True),
<add> output_dir: Path = Arg(..., help="Pipeline output directory"),
<add> prune: int = Opt(-1, "--prune", "-p", help="Optional number of vectors to prune to"),
<add> truncate: int = Opt(0, "--truncate", "-t", help="Optional number of vectors to truncate to when reading in vectors file"),
<add> name: Optional[str] = Opt(None, "--name", "-n", help="Optional name for the word vectors, e.g. en_core_web_lg.vectors"),
<add> # fmt: on
<add>):
<add> msg.info(f"Creating blank nlp object for language '{lang}'")
<add> nlp = util.get_lang_class(lang)()
<add> convert_vectors(
<add> nlp, vectors_loc, truncate=truncate, prune=prune, name=name, silent=False
<add> )
<add> nlp.to_disk(output_dir)
<add> msg.good(
<add> "Saved nlp object with vectors to output directory. You can now use the "
<add> "path to it in your config as the 'vectors' setting in [initialize.vocab].",
<add> output_dir,
<add> )
<add>
<add>
<ide> @init_cli.command(
<ide> "nlp",
<ide> context_settings={"allow_extra_args": True, "ignore_unknown_options": True},
<ide><path>spacy/training/initialize.py
<del>from typing import Union, Dict, Optional, Any, List
<add>from typing import Union, Dict, Optional, Any, List, IO
<ide> from thinc.api import Config, fix_random_seed, set_gpu_allocator
<ide> from thinc.api import ConfigValidationError
<ide> from pathlib import Path
<ide> from wasabi import Printer
<ide> import srsly
<add>import numpy
<add>import tarfile
<add>import gzip
<add>import zipfile
<add>import tqdm
<ide>
<ide> from .loop import create_before_to_disk_callback
<ide> from ..language import Language
<ide> from ..lookups import Lookups
<add>from ..vectors import Vectors
<ide> from ..errors import Errors
<ide> from ..schemas import ConfigSchemaTraining, ConfigSchemaInit, ConfigSchemaPretrain
<ide> from ..util import registry, load_model_from_config, resolve_dot_names
<ide> def init_nlp(config: Config, *, use_gpu: int = -1, silent: bool = True) -> Langu
<ide> msg.info(f"Resuming training for: {resume_components}")
<ide> nlp.resume_training(sgd=optimizer)
<ide> with nlp.select_pipes(disable=[*frozen_components, *resume_components]):
<del> nlp.initialize(lambda: train_corpus(nlp), sgd=optimizer)
<del> msg.good(f"Initialized pipeline components")
<add> nlp.initialize(
<add> lambda: train_corpus(nlp), sgd=optimizer, settings=I["components"]
<add> )
<add> msg.good("Initialized pipeline components")
<ide> # Verify the config after calling 'initialize' to ensure labels
<ide> # are properly initialized
<ide> verify_config(nlp)
<ide> def init_vocab(
<ide>
<ide>
<ide> def load_vectors_into_model(
<del> nlp: "Language", name: Union[str, Path], *, add_strings: bool = True
<add> nlp: Language, name: Union[str, Path], *, add_strings: bool = True
<ide> ) -> None:
<ide> """Load word vectors from an installed model or path into a model instance."""
<ide> try:
<ide> def get_sourced_components(config: Union[Dict[str, Any], Config]) -> List[str]:
<ide> for name, cfg in config.get("components", {}).items()
<ide> if "factory" not in cfg and "source" in cfg
<ide> ]
<add>
<add>
<add>def convert_vectors(
<add> nlp: Language,
<add> vectors_loc: Optional[Path],
<add> *,
<add> truncate: int,
<add> prune: int,
<add> name: Optional[str] = None,
<add> silent: bool = True,
<add>) -> None:
<add> msg = Printer(no_print=silent)
<add> vectors_loc = ensure_path(vectors_loc)
<add> if vectors_loc and vectors_loc.parts[-1].endswith(".npz"):
<add> nlp.vocab.vectors = Vectors(data=numpy.load(vectors_loc.open("rb")))
<add> for lex in nlp.vocab:
<add> if lex.rank and lex.rank != OOV_RANK:
<add> nlp.vocab.vectors.add(lex.orth, row=lex.rank)
<add> else:
<add> if vectors_loc:
<add> with msg.loading(f"Reading vectors from {vectors_loc}"):
<add> vectors_data, vector_keys = read_vectors(vectors_loc, truncate)
<add> msg.good(f"Loaded vectors from {vectors_loc}")
<add> else:
<add> vectors_data, vector_keys = (None, None)
<add> if vector_keys is not None:
<add> for word in vector_keys:
<add> if word not in nlp.vocab:
<add> nlp.vocab[word]
<add> if vectors_data is not None:
<add> nlp.vocab.vectors = Vectors(data=vectors_data, keys=vector_keys)
<add> if name is None:
<add> # TODO: Is this correct? Does this matter?
<add> nlp.vocab.vectors.name = f"{nlp.meta['lang']}_{nlp.meta['name']}.vectors"
<add> else:
<add> nlp.vocab.vectors.name = name
<add> nlp.meta["vectors"]["name"] = nlp.vocab.vectors.name
<add> if prune >= 1:
<add> nlp.vocab.prune_vectors(prune)
<add> msg.good(f"Successfully converted {len(nlp.vocab.vectors)} vectors")
<add>
<add>
<add>def read_vectors(vectors_loc: Path, truncate_vectors: int):
<add> f = open_file(vectors_loc)
<add> f = ensure_shape(f)
<add> shape = tuple(int(size) for size in next(f).split())
<add> if truncate_vectors >= 1:
<add> shape = (truncate_vectors, shape[1])
<add> vectors_data = numpy.zeros(shape=shape, dtype="f")
<add> vectors_keys = []
<add> for i, line in enumerate(tqdm.tqdm(f)):
<add> line = line.rstrip()
<add> pieces = line.rsplit(" ", vectors_data.shape[1])
<add> word = pieces.pop(0)
<add> if len(pieces) != vectors_data.shape[1]:
<add> raise ValueError(Errors.E094.format(line_num=i, loc=vectors_loc))
<add> vectors_data[i] = numpy.asarray(pieces, dtype="f")
<add> vectors_keys.append(word)
<add> if i == truncate_vectors - 1:
<add> break
<add> return vectors_data, vectors_keys
<add>
<add>
<add>def open_file(loc: Union[str, Path]) -> IO:
<add> """Handle .gz, .tar.gz or unzipped files"""
<add> loc = ensure_path(loc)
<add> if tarfile.is_tarfile(str(loc)):
<add> return tarfile.open(str(loc), "r:gz")
<add> elif loc.parts[-1].endswith("gz"):
<add> return (line.decode("utf8") for line in gzip.open(str(loc), "r"))
<add> elif loc.parts[-1].endswith("zip"):
<add> zip_file = zipfile.ZipFile(str(loc))
<add> names = zip_file.namelist()
<add> file_ = zip_file.open(names[0])
<add> return (line.decode("utf8") for line in file_)
<add> else:
<add> return loc.open("r", encoding="utf8")
<add>
<add>
<add>def ensure_shape(lines):
<add> """Ensure that the first line of the data is the vectors shape.
<add> If it's not, we read in the data and output the shape as the first result,
<add> so that the reader doesn't have to deal with the problem.
<add> """
<add> first_line = next(lines)
<add> try:
<add> shape = tuple(int(size) for size in first_line.split())
<add> except ValueError:
<add> shape = None
<add> if shape is not None:
<add> # All good, give the data
<add> yield first_line
<add> yield from lines
<add> else:
<add> # Figure out the shape, make it the first value, and then give the
<add> # rest of the data.
<add> width = len(first_line.split()) - 1
<add> captured = [first_line] + list(lines)
<add> length = len(captured)
<add> yield f"{length} {width}"
<add> yield from captured | 2 |
Java | Java | fix @autowired+@postconstruct+@configuration issue | 2afeb08e3c387715374c81a82074bae4235b5082 | <ide><path>org.springframework.beans/src/main/java/org/springframework/beans/factory/config/ConfigurableBeanFactory.java
<ide> public interface ConfigurableBeanFactory extends HierarchicalBeanFactory, Single
<ide> */
<ide> boolean isFactoryBean(String name) throws NoSuchBeanDefinitionException;
<ide>
<add> /**
<add> * Explicitly control in-creation status of the specified bean. For
<add> * container internal use only.
<add> * @param beanName the name of the bean
<add> * @param inCreation whether the bean is currently in creation
<add> * @since 3.1
<add> */
<add> void setCurrentlyInCreation(String beanName, boolean inCreation);
<add>
<ide> /**
<ide> * Determine whether the specified bean is currently in creation.
<ide> * @param beanName the name of the bean
<ide><path>org.springframework.beans/src/main/java/org/springframework/beans/factory/support/DefaultSingletonBeanRegistry.java
<ide> public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements
<ide> /** Names of beans that are currently in creation */
<ide> private final Set<String> singletonsCurrentlyInCreation = Collections.synchronizedSet(new HashSet<String>());
<ide>
<add> /** Names of beans currently excluded from in creation checks */
<add> private final Set<String> inCreationCheckExclusions = new HashSet<String>();
<add>
<ide> /** List of suppressed Exceptions, available for associating related causes */
<ide> private Set<Exception> suppressedExceptions;
<ide>
<ide> public int getSingletonCount() {
<ide> * @see #isSingletonCurrentlyInCreation
<ide> */
<ide> protected void beforeSingletonCreation(String beanName) {
<del> if (!this.singletonsCurrentlyInCreation.add(beanName)) {
<add> if (!this.inCreationCheckExclusions.contains(beanName) && !this.singletonsCurrentlyInCreation.add(beanName)) {
<ide> throw new BeanCurrentlyInCreationException(beanName);
<ide> }
<ide> }
<ide> protected void beforeSingletonCreation(String beanName) {
<ide> * @see #isSingletonCurrentlyInCreation
<ide> */
<ide> protected void afterSingletonCreation(String beanName) {
<del> if (!this.singletonsCurrentlyInCreation.remove(beanName)) {
<add> if (!this.inCreationCheckExclusions.contains(beanName) && !this.singletonsCurrentlyInCreation.remove(beanName)) {
<ide> throw new IllegalStateException("Singleton '" + beanName + "' isn't currently in creation");
<ide> }
<ide> }
<ide>
<add> public final void setCurrentlyInCreation(String beanName, boolean inCreation) {
<add> if (!inCreation) {
<add> this.inCreationCheckExclusions.add(beanName);
<add> } else {
<add> this.inCreationCheckExclusions.remove(beanName);
<add> }
<add> }
<add>
<ide> /**
<ide> * Return whether the specified singleton bean is currently in creation
<ide> * (within the entire factory).
<ide><path>org.springframework.beans/src/main/java/org/springframework/beans/factory/support/SimpleInstantiationStrategy.java
<ide> */
<ide> public class SimpleInstantiationStrategy implements InstantiationStrategy {
<ide>
<add> private static final ThreadLocal<Method> currentlyInvokedFactoryMethod = new ThreadLocal<Method>();
<add>
<ide> public Object instantiate(RootBeanDefinition beanDefinition, String beanName, BeanFactory owner) {
<ide> // Don't override the class with CGLIB if no overrides.
<ide> if (beanDefinition.getMethodOverrides().isEmpty()) {
<ide> public Object run() {
<ide> else {
<ide> ReflectionUtils.makeAccessible(factoryMethod);
<ide> }
<del>
<del> // It's a static method if the target is null.
<del> return factoryMethod.invoke(factoryBean, args);
<add>
<add> Method priorInvokedFactoryMethod = currentlyInvokedFactoryMethod.get();
<add> try {
<add> currentlyInvokedFactoryMethod.set(factoryMethod);
<add> return factoryMethod.invoke(factoryBean, args);
<add> } finally {
<add> if (priorInvokedFactoryMethod != null) {
<add> currentlyInvokedFactoryMethod.set(priorInvokedFactoryMethod);
<add> }
<add> else {
<add> currentlyInvokedFactoryMethod.remove();
<add> }
<add> }
<ide> }
<ide> catch (IllegalArgumentException ex) {
<ide> throw new BeanDefinitionStoreException(
<ide> public Object run() {
<ide> }
<ide> }
<ide>
<add> /**
<add> * Return the factory method currently being invoked or {@code null} if none.
<add> * Allows factory method implementations to determine whether the current
<add> * caller is the container itself as opposed to user code.
<add> */
<add> public static Method getCurrentlyInvokedFactoryMethod() {
<add> return currentlyInvokedFactoryMethod.get();
<add> }
<ide> }
<ide><path>org.springframework.context/src/main/java/org/springframework/context/annotation/ConfigurationClassEnhancer.java
<ide> import org.springframework.beans.factory.FactoryBean;
<ide> import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
<ide> import org.springframework.beans.factory.config.ConfigurableBeanFactory;
<add>import org.springframework.beans.factory.support.SimpleInstantiationStrategy;
<ide> import org.springframework.core.annotation.AnnotationUtils;
<ide> import org.springframework.util.Assert;
<ide>
<ide> public Object intercept(Object enhancedConfigInstance, Method beanMethod, Object
<ide> return enhanceFactoryBean(factoryBean.getClass(), beanName);
<ide> }
<ide> }
<del>
<del> // the bean is not a FactoryBean - check to see if it has been cached
<del> if (factoryContainsBean(beanName)) {
<del> // we have an already existing cached instance of this bean -> retrieve it
<del> return this.beanFactory.getBean(beanName);
<del> }
<ide>
<del> if (BeanFactoryPostProcessor.class.isAssignableFrom(beanMethod.getReturnType())) {
<del> logger.warn(String.format("@Bean method %s.%s is non-static and returns an object " +
<del> "assignable to Spring's BeanFactoryPostProcessor interface. This will " +
<del> "result in a failure to process annotations such as @Autowired, " +
<del> "@Resource and @PostConstruct within the method's declaring " +
<del> "@Configuration class. Add the 'static' modifier to this method to avoid" +
<del> "these container lifecycle issues; see @Bean Javadoc for complete details",
<del> beanMethod.getDeclaringClass().getSimpleName(), beanMethod.getName()));
<add> boolean factoryIsCaller = beanMethod.equals(SimpleInstantiationStrategy.getCurrentlyInvokedFactoryMethod());
<add> boolean factoryAlreadyContainsSingleton = this.beanFactory.containsSingleton(beanName);
<add> if (factoryIsCaller && !factoryAlreadyContainsSingleton) {
<add> // the factory is calling the bean method in order to instantiate and register the bean
<add> // (i.e. via a getBean() call) -> invoke the super implementation of the method to actually
<add> // create the bean instance.
<add> if (BeanFactoryPostProcessor.class.isAssignableFrom(beanMethod.getReturnType())) {
<add> logger.warn(String.format("@Bean method %s.%s is non-static and returns an object " +
<add> "assignable to Spring's BeanFactoryPostProcessor interface. This will " +
<add> "result in a failure to process annotations such as @Autowired, " +
<add> "@Resource and @PostConstruct within the method's declaring " +
<add> "@Configuration class. Add the 'static' modifier to this method to avoid " +
<add> "these container lifecycle issues; see @Bean Javadoc for complete details",
<add> beanMethod.getDeclaringClass().getSimpleName(), beanMethod.getName()));
<add> }
<add> return cglibMethodProxy.invokeSuper(enhancedConfigInstance, beanMethodArgs);
<ide> }
<del> return cglibMethodProxy.invokeSuper(enhancedConfigInstance, beanMethodArgs);
<add> else {
<add> // the user (i.e. not the factory) is requesting this bean through a
<add> // call to the bean method, direct or indirect. The bean may have already been
<add> // marked as 'in creation' in certain autowiring scenarios; if so, temporarily
<add> // set the in-creation status to false in order to avoid an exception.
<add> boolean alreadyInCreation = this.beanFactory.isCurrentlyInCreation(beanName);
<add> try {
<add> if (alreadyInCreation) {
<add> this.beanFactory.setCurrentlyInCreation(beanName, false);
<add> }
<add> return this.beanFactory.getBean(beanName);
<add> } finally {
<add> if (alreadyInCreation) {
<add> this.beanFactory.setCurrentlyInCreation(beanName, true);
<add> }
<add> }
<add> }
<add>
<ide> }
<ide>
<ide> /**
<ide> public Object intercept(Object enhancedConfigInstance, Method beanMethod, Object
<ide> * @return whether <var>beanName</var> already exists in the factory
<ide> */
<ide> private boolean factoryContainsBean(String beanName) {
<del> return (this.beanFactory.containsBean(beanName) && !this.beanFactory.isCurrentlyInCreation(beanName));
<add> boolean containsBean = this.beanFactory.containsBean(beanName);
<add> boolean currentlyInCreation = this.beanFactory.isCurrentlyInCreation(beanName);
<add> return (containsBean && !currentlyInCreation);
<ide> }
<ide>
<ide> /**
<ide><path>org.springframework.context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostConstructAndAutowiringTests.java
<add>/*
<add> * Copyright 2002-2011 the original author or authors.
<add> *
<add> * Licensed under the Apache License, Version 2.0 (the "License");
<add> * you may not use this file except in compliance with the License.
<add> * You may obtain a copy of the License at
<add> *
<add> * http://www.apache.org/licenses/LICENSE-2.0
<add> *
<add> * Unless required by applicable law or agreed to in writing, software
<add> * distributed under the License is distributed on an "AS IS" BASIS,
<add> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<add> * See the License for the specific language governing permissions and
<add> * limitations under the License.
<add> */
<add>
<add>package org.springframework.context.annotation;
<add>
<add>import static org.hamcrest.CoreMatchers.is;
<add>import static org.junit.Assert.assertThat;
<add>
<add>import javax.annotation.PostConstruct;
<add>
<add>import org.junit.Test;
<add>import org.springframework.beans.TestBean;
<add>import org.springframework.beans.factory.annotation.Autowired;
<add>
<add>/**
<add> * Tests cornering the issue reported in SPR-8080. If the product of a @Bean method
<add> * was @Autowired into a configuration class while at the same time the declaring
<add> * configuration class for the @Bean method in question has a @PostConstruct
<add> * (or other initializer) method, the container would become confused about the
<add> * 'currently in creation' status of the autowired bean and result in creating multiple
<add> * instances of the given @Bean, violating container scoping / singleton semantics.
<add> *
<add> * This is resolved through no longer relying on 'currently in creation' status, but
<add> * rather on a thread local that informs the enhanced bean method implementation whether
<add> * the factory is the caller or not.
<add> *
<add> * @author Chris Beams
<add> * @since 3.1
<add> */
<add>public class ConfigurationClassPostConstructAndAutowiringTests {
<add>
<add> /**
<add> * Prior to the fix for SPR-8080, this method would succeed due to ordering of
<add> * configuration class registration.
<add> */
<add> @Test
<add> public void control() {
<add> AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
<add> ctx.register(Config1.class, Config2.class);
<add> ctx.refresh();
<add>
<add> assertions(ctx);
<add>
<add> Config2 config2 = ctx.getBean(Config2.class);
<add> assertThat(config2.testBean, is(ctx.getBean(TestBean.class)));
<add> }
<add>
<add> /**
<add> * Prior to the fix for SPR-8080, this method would fail due to ordering of
<add> * configuration class registration.
<add> */
<add> @Test
<add> public void originalReproCase() {
<add> AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
<add> ctx.register(Config2.class, Config1.class);
<add> ctx.refresh();
<add>
<add> assertions(ctx);
<add> }
<add>
<add> private void assertions(AnnotationConfigApplicationContext ctx) {
<add> Config1 config1 = ctx.getBean(Config1.class);
<add> TestBean testBean = ctx.getBean(TestBean.class);
<add> assertThat(config1.beanMethodCallCount, is(1));
<add> assertThat(testBean.getAge(), is(2));
<add> }
<add>
<add>
<add> @Configuration
<add> static class Config1 {
<add>
<add> int beanMethodCallCount = 0;
<add>
<add> @PostConstruct
<add> public void init() {
<add> beanMethod().setAge(beanMethod().getAge() + 1); // age == 2
<add> }
<add>
<add> @Bean
<add> public TestBean beanMethod() {
<add> beanMethodCallCount++;
<add> TestBean testBean = new TestBean();
<add> testBean.setAge(1);
<add> return testBean;
<add> }
<add> }
<add>
<add>
<add> @Configuration
<add> static class Config2 {
<add> TestBean testBean;
<add>
<add> @Autowired
<add> void setTestBean(TestBean testBean) {
<add> this.testBean = testBean;
<add> }
<add> }
<add>
<add>} | 5 |
Go | Go | use pkg/pidfile for reading and writing pidfile | cea8e9b58353151e4e2fd17341f7b6d2382d0d57 | <ide><path>libcontainerd/supervisor/remote_daemon.go
<ide> package supervisor // import "github.com/docker/docker/libcontainerd/supervisor"
<ide>
<ide> import (
<ide> "context"
<del> "io"
<ide> "os"
<ide> "os/exec"
<ide> "path/filepath"
<ide> "runtime"
<del> "strconv"
<ide> "strings"
<ide> "time"
<ide>
<ide> "github.com/containerd/containerd"
<ide> "github.com/containerd/containerd/services/server/config"
<ide> "github.com/containerd/containerd/sys"
<add> "github.com/docker/docker/pkg/pidfile"
<ide> "github.com/docker/docker/pkg/process"
<ide> "github.com/docker/docker/pkg/system"
<ide> "github.com/pelletier/go-toml"
<ide> func (r *remote) WaitTimeout(d time.Duration) error {
<ide> func (r *remote) Address() string {
<ide> return r.GRPC.Address
<ide> }
<del>func (r *remote) getContainerdPid() (int, error) {
<del> f, err := os.OpenFile(r.pidFile, os.O_RDWR, 0600)
<del> if err != nil {
<del> if os.IsNotExist(err) {
<del> return -1, nil
<del> }
<del> return -1, err
<del> }
<del> defer f.Close()
<del>
<del> b := make([]byte, 8)
<del> n, err := f.Read(b)
<del> if err != nil && err != io.EOF {
<del> return -1, err
<del> }
<del>
<del> if n > 0 {
<del> pid, err := strconv.ParseUint(string(b[:n]), 10, 64)
<del> if err != nil {
<del> return -1, err
<del> }
<del> if process.Alive(int(pid)) {
<del> return int(pid), nil
<del> }
<del> }
<del>
<del> return -1, nil
<del>}
<ide>
<ide> func (r *remote) getContainerdConfig() (string, error) {
<ide> f, err := os.OpenFile(r.configFile, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0600)
<ide> func (r *remote) getContainerdConfig() (string, error) {
<ide> }
<ide>
<ide> func (r *remote) startContainerd() error {
<del> pid, err := r.getContainerdPid()
<del> if err != nil {
<add> pid, err := pidfile.Read(r.pidFile)
<add> if err != nil && !errors.Is(err, os.ErrNotExist) {
<ide> return err
<ide> }
<ide>
<del> if pid != -1 {
<add> if pid > 0 {
<ide> r.daemonPid = pid
<ide> r.logger.WithField("pid", pid).Infof("%s is still running", binaryName)
<ide> return nil
<ide> }
<ide>
<del> configFile, err := r.getContainerdConfig()
<add> cfgFile, err := r.getContainerdConfig()
<ide> if err != nil {
<ide> return err
<ide> }
<del>
<del> args := []string{"--config", configFile}
<add> args := []string{"--config", cfgFile}
<ide>
<ide> if r.logLevel != "" {
<ide> args = append(args, "--log-level", r.logLevel)
<ide> func (r *remote) startContainerd() error {
<ide> r.logger.WithError(err).Warn("failed to adjust OOM score")
<ide> }
<ide>
<del> err = os.WriteFile(r.pidFile, []byte(strconv.Itoa(r.daemonPid)), 0660)
<add> err = pidfile.Write(r.pidFile, r.daemonPid)
<ide> if err != nil {
<ide> process.Kill(r.daemonPid)
<ide> return errors.Wrap(err, "libcontainerd: failed to save daemon pid to disk") | 1 |
Javascript | Javascript | remove "derequire" from minified bundles | 5c5fc5e3169828607a3ddb8e6b95139d1fd18946 | <ide><path>grunt/config/browserify.js
<ide> var min = {
<ide> standalone: 'React',
<ide> transforms: [envify({NODE_ENV: 'production'}), uglifyify],
<ide> plugins: [collapser],
<del> after: [es3ify.transform, derequire, minify, bannerify]
<add> // No need to derequire because the minifier will mangle
<add> // the "require" calls.
<add>
<add> after: [es3ify.transform, /*derequire,*/ minify, bannerify]
<ide> };
<ide>
<ide> var transformer = {
<ide> var addonsMin = {
<ide> packageName: 'React (with addons)',
<ide> transforms: [envify({NODE_ENV: 'production'}), uglifyify],
<ide> plugins: [collapser],
<del> after: [es3ify.transform, derequire, minify, bannerify]
<add> // No need to derequire because the minifier will mangle
<add> // the "require" calls.
<add>
<add> after: [es3ify.transform, /*derequire,*/ minify, bannerify]
<ide> };
<ide>
<ide> var withCodeCoverageLogging = { | 1 |
Text | Text | add sandboxes to the examples in the docs | c1953b04cf48b2973aa8e2197d5b46ec36adbd59 | <ide><path>docs/introduction/Examples.md
<ide> # Examples
<ide>
<del>Redux is distributed with a few examples in its [source code](https://github.com/reactjs/redux/tree/master/examples).
<add>Redux is distributed with a few examples in its [source code](https://github.com/reactjs/redux/tree/master/examples). Most of these examples are also on [CodeSandbox](https://codesandbox.io), this is an online editor that lets you play with the examples online.
<ide>
<ide> ## Counter Vanilla
<ide>
<ide> npm start
<ide> open http://localhost:3000/
<ide> ```
<ide>
<add>Or check out the [sandbox](https://codesandbox.io/s/github/reactjs/redux/tree/master/examples/counter).
<add>
<ide> This is the most basic example of using Redux together with React. For simplicity, it re-renders the React component manually when the store changes. In real projects, you will likely want to use the highly performant [React Redux](https://github.com/reactjs/react-redux) bindings instead.
<ide>
<ide> This example includes tests.
<ide> npm start
<ide> open http://localhost:3000/
<ide> ```
<ide>
<add>Or check out the [sandbox](https://codesandbox.io/s/github/reactjs/redux/tree/master/examples/todos).
<add>
<ide> This is the best example to get a deeper understanding of how the state updates work together with components in Redux. It shows how reducers can delegate handling actions to other reducers, and how you can use [React Redux](https://github.com/reactjs/react-redux) to generate container components from your presentational components.
<ide>
<ide> This example includes tests.
<ide> npm start
<ide> open http://localhost:3000/
<ide> ```
<ide>
<add>Or check out the [sandbox](https://codesandbox.io/s/github/reactjs/redux/tree/master/examples/todos-with-undo).
<add>
<ide> This is a variation on the previous example. It is almost identical, but additionally shows how wrapping your reducer with [Redux Undo](https://github.com/omnidan/redux-undo) lets you add a Undo/Redo functionality to your app with a few lines of code.
<ide>
<ide> ## TodoMVC
<ide> npm start
<ide> open http://localhost:3000/
<ide> ```
<ide>
<add>Or check out the [sandbox](https://codesandbox.io/s/github/reactjs/redux/tree/master/examples/todomvc).
<add>
<ide> This is the classical [TodoMVC](http://todomvc.com/) example. It's here for the sake of comparison, but it covers the same points as the Todos example.
<ide>
<ide> This example includes tests.
<ide> npm start
<ide> open http://localhost:3000/
<ide> ```
<ide>
<add>Or check out the [sandbox](https://codesandbox.io/s/github/reactjs/redux/tree/master/examples/shopping-cart).
<add>
<ide> This example shows important idiomatic Redux patterns that become important as your app grows. In particular, it shows how to store entities in a normalized way by their IDs, how to compose reducers on several levels, and how to define selectors alongside the reducers so the knowledge about the state shape is encapsulated. It also demonstrates logging with [Redux Logger](https://github.com/fcomb/redux-logger) and conditional dispatching of actions with [Redux Thunk](https://github.com/gaearon/redux-thunk) middleware.
<ide>
<ide> ## Tree View
<ide> npm start
<ide> open http://localhost:3000/
<ide> ```
<ide>
<add>Or check out the [sandbox](https://codesandbox.io/s/github/reactjs/redux/tree/master/examples/tree-view).
<add>
<ide> This example demonstrates rendering a deeply nested tree view and representing its state in a normalized form so it is easy to update from reducers. Good rendering performance is achieved by the container components granularly subscribing only to the tree nodes that they render.
<ide>
<ide> This example includes tests.
<ide> npm start
<ide> open http://localhost:3000/
<ide> ```
<ide>
<add>Or check out the [sandbox](https://codesandbox.io/s/github/reactjs/redux/tree/master/examples/async).
<add>
<ide> This example includes reading from an asynchronous API, fetching data in response to user input, showing loading indicators, caching the response, and invalidating the cache. It uses [Redux Thunk](https://github.com/gaearon/redux-thunk) middleware to encapsulate asynchronous side effects.
<ide>
<ide> ## Universal
<ide> npm start
<ide> open http://localhost:3000/
<ide> ```
<ide>
<add>Or check out the [sandbox](https://codesandbox.io/s/github/reactjs/redux/tree/master/examples/real-world).
<add>
<ide> This is the most advanced example. It is dense by design. It covers keeping fetched entities in a normalized cache, implementing a custom middleware for API calls, rendering partially loaded data, pagination, caching responses, displaying error messages, and routing. Additionally, it includes Redux DevTools.
<ide>
<ide> ## More Examples | 1 |
Python | Python | fix broken namignizer code | fdc0c4ab1b039b6085478b36b5cd3cad038941ec | <ide><path>namignizer/names.py
<ide> def namignator(checkpoint_path, config):
<ide> print(map(lambda x: chr(x + 96), name))
<ide>
<ide>
<del>if __name__ == "__main__":
<del> # train("data/SmallNames.txt", "model/namignizer", SmallConfig)
<add> if __name__ == "__main__":
<add> train("data/SmallNames.txt", "model/namignizer", SmallConfig)
<ide>
<del> # namignize(["mary", "ida", "gazorbazorb", "mmmhmm", "bob"],
<del> # tf.train.latest_checkpoint("model"), SmallConfig)
<add> namignize(["mary", "ida", "gazorbazorb", "mmmhmm", "bob"],
<add> tf.train.latest_checkpoint("model"), SmallConfig)
<ide>
<del> # namignator(tf.train.latest_checkpoint("model"), SmallConfig)
<add> namignator(tf.train.latest_checkpoint("model"), SmallConfig) | 1 |
Javascript | Javascript | remove todo comment | d9ddd7d345213cd2eb7008b55d0b22142664cc90 | <ide><path>test/parallel/test-preload.js
<ide> var nodeBinary = process.argv[0];
<ide> var preloadOption = function(preloads) {
<ide> var option = '';
<ide> preloads.forEach(function(preload, index) {
<del> // TODO: randomly pick -r or --require
<ide> option += '-r ' + preload + ' ';
<ide> });
<ide> return option; | 1 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.