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
|
|---|---|---|---|---|---|
Text
|
Text
|
use the changelog convention [ci skip]
|
c35a7d78ec2599b597296dc6749ca3d7ac434177
|
<ide><path>activerecord/CHANGELOG.md
<ide> ## Rails 4.0.0 (unreleased) ##
<ide>
<del>* Fix creation of through association models when using collection=[]
<del> on a hm:t association from an unsaved model.
<add>* Fix creation of through association models when using `collection=[]`
<add> on a `has_many :through` association from an unsaved model.
<add> Fix #7661.
<ide>
<ide> *Ernie Miller*
<ide>
<ide> * Explain only normal CRUD sql (select / update / insert / delete).
<del> Fix problem that explains unexplainable sql. Closes #7544 #6458.
<add> Fix problem that explains unexplainable sql.
<add> Closes #7544 #6458.
<ide>
<ide> *kennyj*
<ide>
| 1
|
Text
|
Text
|
fix typo in rails autoloading guide
|
08145c251427acb5d17781159162af798163e955
|
<ide><path>guides/source/autoloading_and_reloading_constants.md
<ide> $ bin/rails runner 'p UsersHelper'
<ide> UsersHelper
<ide> ```
<ide>
<del>Autoload paths automatically pick any custom directories under `app`. For example, if your application has `app/presenters`, or `app/services`, etc., they are added to autoload paths.
<add>Autoload paths automatically pick up any custom directories under `app`. For example, if your application has `app/presenters`, or `app/services`, etc., they are added to autoload paths.
<ide>
<ide> The array of autoload paths can be extended by mutating `config.autoload_paths`, in `config/application.rb`, but nowadays this is discouraged.
<ide>
| 1
|
Javascript
|
Javascript
|
fix crash unmounting an empty portal
|
1fecba92307041e181ce425082d4d21ec8928728
|
<ide><path>packages/react-dom/src/__tests__/ReactDOMFiber-test.js
<ide> describe('ReactDOMFiber', () => {
<ide> expect(container.innerHTML).toBe('<div></div>');
<ide> });
<ide>
<add> it('should unmount empty portal component wherever it appears', () => {
<add> const portalContainer = document.createElement('div');
<add>
<add> class Wrapper extends React.Component {
<add> constructor(props) {
<add> super(props);
<add> this.state = {
<add> show: true,
<add> };
<add> }
<add> render() {
<add> return (
<add> <div>
<add> {this.state.show && (
<add> <React.Fragment>
<add> {ReactDOM.createPortal(null, portalContainer)}
<add> <div>child</div>
<add> </React.Fragment>
<add> )}
<add> <div>parent</div>
<add> </div>
<add> );
<add> }
<add> }
<add>
<add> const instance = ReactDOM.render(<Wrapper />, container);
<add> expect(container.innerHTML).toBe(
<add> '<div><div>child</div><div>parent</div></div>',
<add> );
<add> instance.setState({show: false});
<add> expect(instance.state.show).toBe(false);
<add> expect(container.innerHTML).toBe('<div><div>parent</div></div>');
<add> });
<add>
<ide> it('should keep track of namespace across portals (simple)', () => {
<ide> assertNamespacesMatch(
<ide> <svg {...expectSVG}>
<ide><path>packages/react-reconciler/src/ReactFiberCommitWork.js
<ide> function unmountHostComponents(current): void {
<ide> }
<ide> // Don't visit children because we already visited them.
<ide> } else if (node.tag === HostPortal) {
<del> // When we go into a portal, it becomes the parent to remove from.
<del> // We will reassign it back when we pop the portal on the way up.
<del> currentParent = node.stateNode.containerInfo;
<del> currentParentIsContainer = true;
<del> // Visit children because portals might contain host components.
<ide> if (node.child !== null) {
<add> // When we go into a portal, it becomes the parent to remove from.
<add> // We will reassign it back when we pop the portal on the way up.
<add> currentParent = node.stateNode.containerInfo;
<add> currentParentIsContainer = true;
<add> // Visit children because portals might contain host components.
<ide> node.child.return = node;
<ide> node = node.child;
<ide> continue;
| 2
|
Text
|
Text
|
replace html with html [ci skip]
|
ae755bc5179977b0ab105537c65e7831e47341d2
|
<ide><path>guides/source/upgrading_ruby_on_rails.md
<ide> end
<ide>
<ide> There's a new choice for sanitizing HTML fragments in your applications. The
<ide> venerable html-scanner approach is now officially being deprecated in favor of
<del>[`Rails Html Sanitizer`](https://github.com/rails/rails-html-sanitizer).
<add>[`Rails HTML Sanitizer`](https://github.com/rails/rails-html-sanitizer).
<ide>
<ide> This means the methods `sanitize`, `sanitize_css`, `strip_tags` and
<ide> `strip_links` are backed by a new implementation.
<ide> gem 'rails-deprecated_sanitizer'
<ide> ```
<ide>
<ide> ### Rails DOM Testing
<del>The [`TagAssertions` module](http://api.rubyonrails.org/classes/ActionDispatch/Assertions/TagAssertions.html) (containing methods such as `assert_tag`), [has been deprecated](https://github.com/rails/rails/blob/6061472b8c310158a2a2e8e9a6b81a1aef6b60fe/actionpack/lib/action_dispatch/testing/assertions/dom.rb) in favor of the `assert_select` methods from the `SelectorAssertions` module, which has been extracted into the [rails-dom-testing gem](https://github.com/rails/rails-dom-testing).
<add>The [`TagAssertions` module](http://api.rubyonrails.org/classes/ActionDispatch/Assertions/TagAssertions.html) (containing methods such as `assert_tag`), [has been deprecated](https://github.com/rails/rails/blob/6061472b8c310158a2a2e8e9a6b81a1aef6b60fe/actionpack/lib/action_dispatch/testing/assertions/dom.rb) in favor of the `assert_select` methods from the `SelectorAssertions` module, which has been extracted into the [rails-dom-testing gem](https://github.com/rails/rails-dom-testing).
<ide>
<ide>
<ide> ### Masked Authenticity Tokens
| 1
|
Text
|
Text
|
fix example in doc
|
e02554412f36b1eb8ea59a58c41a9d2e8ddac13a
|
<ide><path>docs/templates/applications.md
<ide> block4_pool_features = model.predict(x)
<ide> from keras.applications.inception_v3 import InceptionV3
<ide> from keras.preprocessing import image
<ide> from keras.models import Model
<del>from keras.layers import Dense
<add>from keras.layers import Dense, Lambda
<add>from keras import backend as K
<ide>
<ide> # create the base pre-trained model
<ide> base_model = InceptionV3(weights='imagenet', include_top=False)
<ide> # add some Dense layers on top
<ide> x = base_model.output
<add># add a global spatial average pooling layer
<add>x = Lambda(lambda x: K.mean(x, axis=[1, 2]))(x) # assuming 'tf' dim ordering
<ide> x = Dense(1024, activation='relu')(x)
<ide> predictions = Dense(200, activation='softmax')(x) # let's say we have 200 classes
<ide>
| 1
|
Java
|
Java
|
parse yogavalue from string. inverse of tostring()
|
e656adcaa8a4eda358f0a2b2bdf8a8f3b7eaabc7
|
<ide><path>ReactAndroid/src/main/java/com/facebook/yoga/YogaValue.java
<ide> public class YogaValue {
<ide> static final YogaValue UNDEFINED = new YogaValue(YogaConstants.UNDEFINED, YogaUnit.UNDEFINED);
<ide> static final YogaValue ZERO = new YogaValue(0, YogaUnit.POINT);
<add> static final YogaValue AUTO = new YogaValue(YogaConstants.UNDEFINED, YogaUnit.AUTO);
<ide>
<ide> public final float value;
<ide> public final YogaUnit unit;
<ide> public String toString() {
<ide> throw new IllegalStateException();
<ide> }
<ide> }
<add>
<add> public static YogaValue parse(String s) {
<add> if (s == null) {
<add> return null;
<add> }
<add>
<add> if ("undefined".equals(s)) {
<add> return UNDEFINED;
<add> }
<add>
<add> if ("auto".equals(s)) {
<add> return AUTO;
<add> }
<add>
<add> if (s.endsWith("%")) {
<add> return new YogaValue(Float.parseFloat(s.substring(0, s.length() - 1)), YogaUnit.PERCENT);
<add> }
<add>
<add> return new YogaValue(Float.parseFloat(s), YogaUnit.POINT);
<add> }
<ide> }
| 1
|
Python
|
Python
|
add robust tests for exec_command()
|
2fbdd9903fc9bf6e1fe797e92c0157abd67850ce
|
<ide><path>numpy/distutils/tests/test_exec_command.py
<add>import os
<ide> import sys
<ide> import StringIO
<ide>
<ide> def __exit__(self, exc_type, exc_value, traceback):
<ide> self._stdout.flush()
<ide> sys.stdout = self.old_stdout
<ide>
<add>class redirect_stderr(object):
<add> """Context manager to redirect stderr for exec_command test."""
<add> def __init__(self, stderr=None):
<add> self._stderr = stderr or sys.stderr
<ide>
<del>def test_exec_command():
<add> def __enter__(self):
<add> self.old_stderr = sys.stderr
<add> sys.stderr = self._stderr
<add>
<add> def __exit__(self, exc_type, exc_value, traceback):
<add> self._stderr.flush()
<add> sys.stderr = self.old_stderr
<add>
<add>class emulate_nonposix(object):
<add> """Context manager to emulate os.name != 'posix' """
<add> def __init__(self, osname='non-posix'):
<add> self._new_name = osname
<add>
<add> def __enter__(self):
<add> self._old_name = os.name
<add> os.name = self._new_name
<add>
<add> def __exit__(self, exc_type, exc_value, traceback):
<add> os.name = self._old_name
<add>
<add>
<add>def test_exec_command_stdout():
<ide> # Regression test for gh-2999 and gh-2915.
<ide> # There are several packages (nose, scipy.weave.inline, Sage inline
<ide> # Fortran) that replace stdout, in which case it doesn't have a fileno
<ide> # method. This is tested here, with a do-nothing command that fails if the
<ide> # presence of fileno() is assumed in exec_command.
<add>
<add> # Test posix version:
<ide> with redirect_stdout(StringIO.StringIO()):
<ide> exec_command.exec_command("cd '.'")
<ide>
<add> # Test non-posix version:
<add> with emulate_nonposix():
<add> with redirect_stdout(StringIO.StringIO()):
<add> exec_command.exec_command("cd '.'")
<add>
<add>def test_exec_command_stderr():
<add> # Test posix version:
<add> with redirect_stderr(StringIO.StringIO()):
<add> exec_command.exec_command("cd '.'")
<add>
<add> # Test non-posix version:
<add> # Note: this test reveals a failure
<add> #with emulate_nonposix():
<add> # with redirect_stderr(StringIO.StringIO()):
<add> # exec_command.exec_command("cd '.'")
| 1
|
Javascript
|
Javascript
|
check zlib version for createdeflateraw
|
51898575ae2cc179699cc0c56cfc97ae22b235fc
|
<ide><path>test/parallel/test-zlib-failed-init.js
<ide> const assert = require('assert');
<ide> const zlib = require('zlib');
<ide>
<ide> // For raw deflate encoding, requests for 256-byte windows are rejected as
<del>// invalid by zlib.
<del>// (http://zlib.net/manual.html#Advanced)
<del>assert.throws(() => {
<del> zlib.createDeflateRaw({ windowBits: 8 });
<del>}, /^Error: Init error$/);
<add>// invalid by zlib (http://zlib.net/manual.html#Advanced).
<add>// This check was introduced in version 1.2.9 and prior to that there was
<add>// no such rejection which is the reason for the version check below
<add>// (http://zlib.net/ChangeLog.txt).
<add>if (!/^1\.2\.[0-8]$/.test(process.versions.zlib)) {
<add> assert.throws(() => {
<add> zlib.createDeflateRaw({ windowBits: 8 });
<add> }, /^Error: Init error$/);
<add>}
<ide>
<ide> // Regression tests for bugs in the validation logic.
<ide>
| 1
|
Ruby
|
Ruby
|
remove unncessary semicolon
|
31fb99680026fb285bc69f1641e3fbdbed09ee98
|
<ide><path>Library/Homebrew/cask/lib/hbc/cli/reinstall.rb
<ide> def self.install_casks(cask_tokens, force, skip_cask_deps, require_sha)
<ide>
<ide> if cask.installed?
<ide> # use copy of cask for uninstallation to avoid 'No such file or directory' bug
<del> installed_cask = cask;
<add> installed_cask = cask
<ide> latest_installed_version = installed_cask.timestamped_versions.last
<ide>
<ide> unless latest_installed_version.nil?
| 1
|
PHP
|
PHP
|
fix issue with getting table instances
|
cd2d0a603c88e039c130cc310e6ef6ee1144be89
|
<ide><path>src/Console/Command/Task/TestTask.php
<ide> public function generateConstructor($type, $fullClassName) {
<ide> $pre = $construct = $post = '';
<ide> if ($type === 'table') {
<ide> $className = str_replace('Table', '', $className);
<del> $construct = "TableRegistry::get('{$className}', ['className' => '{$fullClassName}']);\n";
<add> $pre = "\$config = TableRegistry::exists('{$className}') ? [] : ['className' => '{$fullClassName}'];\n";
<add> $construct = "TableRegistry::get('{$className}', \$config);\n";
<ide> }
<ide> if ($type === 'behavior' || $type === 'entity') {
<ide> $construct = "new {$className}();\n";
<ide><path>tests/TestCase/Console/Command/Task/TestTaskTest.php
<ide> public function testBakeModelTest() {
<ide> $this->assertContains('class ArticlesTableTest extends TestCase', $result);
<ide>
<ide> $this->assertContains('function setUp()', $result);
<del> $this->assertContains("\$this->Articles = TableRegistry::get('Articles', [", $result);
<add> $this->assertContains("\$config = TableRegistry::exists('Articles') ?", $result);
<add> $this->assertContains("\$this->Articles = TableRegistry::get('Articles', \$config", $result);
<ide>
<ide> $this->assertContains('function tearDown()', $result);
<ide> $this->assertContains('unset($this->Articles)', $result);
<ide> public function testBakeHelperTest() {
<ide> */
<ide> public function testGenerateConstructor() {
<ide> $result = $this->Task->generateConstructor('controller', 'PostsController');
<del> $expected = array('', '', '');
<add> $expected = ['', '', ''];
<ide> $this->assertEquals($expected, $result);
<ide>
<ide> $result = $this->Task->generateConstructor('table', 'App\Model\\Table\PostsTable');
<del> $expected = array('', "TableRegistry::get('Posts', ['className' => 'App\Model\\Table\PostsTable']);\n", '');
<add> $expected = [
<add> "\$config = TableRegistry::exists('Posts') ? [] : ['className' => 'App\Model\\Table\PostsTable'];\n",
<add> "TableRegistry::get('Posts', \$config);\n",
<add> ''
<add> ];
<ide> $this->assertEquals($expected, $result);
<ide>
<ide> $result = $this->Task->generateConstructor('helper', 'FormHelper');
<del> $expected = array("\$view = new View();\n", "new FormHelper(\$view);\n", '');
<add> $expected = ["\$view = new View();\n", "new FormHelper(\$view);\n", ''];
<ide> $this->assertEquals($expected, $result);
<ide>
<del> $result = $this->Task->generateConstructor('entity', 'TestPlugin\Model\Entity\Article', null);
<del> $expected = array("", "new Article();\n", '');
<add> $result = $this->Task->generateConstructor('entity', 'TestPlugin\Model\Entity\Article');
<add> $expected = ["", "new Article();\n", ''];
<ide> $this->assertEquals($expected, $result);
<ide> }
<ide>
| 2
|
Python
|
Python
|
add tests for some util functions
|
08636c9740b3103fd05c81791f43faeb29920305
|
<ide><path>test/test_utils.py
<add># -*- coding: utf-8 -*-
<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>import warnings
<add>import os.path
<add>
<add>import libcloud.utils
<add>
<add>WARNINGS_BUFFER = []
<add>
<add>def show_warning(msg, cat, fname, lno):
<add> WARNINGS_BUFFER.append((msg, cat, fname, lno))
<add>
<add>original_func = warnings.showwarning
<add>
<add>class TestUtils(unittest.TestCase):
<add> def setUp(self):
<add> global WARNINGS_BUFFER
<add> WARNINGS_BUFFER = []
<add>
<add> def tearDown(self):
<add> global WARNINGS_BUFFER
<add> WARNINGS_BUFFER = []
<add> warnings.showwarning = original_func
<add>
<add> def test_guess_file_mime_type(self):
<add> file_path = os.path.abspath(__file__)
<add> mimetype, encoding = libcloud.utils.guess_file_mime_type(file_path=file_path)
<add>
<add> self.assertEqual(mimetype, 'text/x-python')
<add>
<add> def test_deprecated_warning(self):
<add> warnings.showwarning = show_warning
<add>
<add> libcloud.utils.SHOW_DEPRECATION_WARNING = False
<add> self.assertEqual(len(WARNINGS_BUFFER), 0)
<add> libcloud.utils.deprecated_warning('test_module')
<add> self.assertEqual(len(WARNINGS_BUFFER), 0)
<add>
<add> libcloud.utils.SHOW_DEPRECATION_WARNING = True
<add> self.assertEqual(len(WARNINGS_BUFFER), 0)
<add> libcloud.utils.deprecated_warning('test_module')
<add> self.assertEqual(len(WARNINGS_BUFFER), 1)
<add>
<add> def test_in_development_warning(self):
<add> warnings.showwarning = show_warning
<add>
<add> libcloud.utils.SHOW_IN_DEVELOPMENT_WARNING = False
<add> self.assertEqual(len(WARNINGS_BUFFER), 0)
<add> libcloud.utils.in_development_warning('test_module')
<add> self.assertEqual(len(WARNINGS_BUFFER), 0)
<add>
<add> libcloud.utils.SHOW_IN_DEVELOPMENT_WARNING = True
<add> self.assertEqual(len(WARNINGS_BUFFER), 0)
<add> libcloud.utils.in_development_warning('test_module')
<add> self.assertEqual(len(WARNINGS_BUFFER), 1)
<add>
<add>if __name__ == '__main__':
<add> sys.exit(unittest.main())
| 1
|
Go
|
Go
|
migrate some "info" tests to integration
|
ec4a34ae2f375cfadacaf95cb5ef93b7c5ca43d3
|
<ide><path>integration-cli/docker_cli_info_test.go
<ide> package main
<ide> import (
<ide> "encoding/json"
<ide> "fmt"
<del> "net"
<ide> "strings"
<ide> "testing"
<ide>
<del> "github.com/docker/docker/integration-cli/daemon"
<del> testdaemon "github.com/docker/docker/testutil/daemon"
<ide> "gotest.tools/assert"
<ide> )
<ide>
<ide> func (s *DockerSuite) TestInfoEnsureSucceeds(c *testing.T) {
<ide> }
<ide> }
<ide>
<del>// TestInfoFormat tests `docker info --format`
<del>func (s *DockerSuite) TestInfoFormat(c *testing.T) {
<del> out, status := dockerCmd(c, "info", "--format", "{{json .}}")
<del> assert.Equal(c, status, 0)
<del> var m map[string]interface{}
<del> err := json.Unmarshal([]byte(out), &m)
<del> assert.NilError(c, err)
<del> _, _, err = dockerCmdWithError("info", "--format", "{{.badString}}")
<del> assert.ErrorContains(c, err, "")
<del>}
<del>
<del>// TestInfoDiscoveryBackend verifies that a daemon run with `--cluster-advertise` and
<del>// `--cluster-store` properly show the backend's endpoint in info output.
<del>func (s *DockerSuite) TestInfoDiscoveryBackend(c *testing.T) {
<del> testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux)
<del>
<del> d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
<del> discoveryBackend := "consul://consuladdr:consulport/some/path"
<del> discoveryAdvertise := "1.1.1.1:2375"
<del> d.Start(c, fmt.Sprintf("--cluster-store=%s", discoveryBackend), fmt.Sprintf("--cluster-advertise=%s", discoveryAdvertise))
<del> defer d.Stop(c)
<del>
<del> out, err := d.Cmd("info")
<del> assert.NilError(c, err)
<del> assert.Assert(c, strings.Contains(out, fmt.Sprintf("Cluster Store: %s\n", discoveryBackend)))
<del> assert.Assert(c, strings.Contains(out, fmt.Sprintf("Cluster Advertise: %s\n", discoveryAdvertise)))
<del>}
<del>
<del>// TestInfoDiscoveryInvalidAdvertise verifies that a daemon run with
<del>// an invalid `--cluster-advertise` configuration
<del>func (s *DockerSuite) TestInfoDiscoveryInvalidAdvertise(c *testing.T) {
<del> testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux)
<del>
<del> d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
<del> discoveryBackend := "consul://consuladdr:consulport/some/path"
<del>
<del> // --cluster-advertise with an invalid string is an error
<del> err := d.StartWithError(fmt.Sprintf("--cluster-store=%s", discoveryBackend), "--cluster-advertise=invalid")
<del> assert.ErrorContains(c, err, "")
<del>
<del> // --cluster-advertise without --cluster-store is also an error
<del> err = d.StartWithError("--cluster-advertise=1.1.1.1:2375")
<del> assert.ErrorContains(c, err, "")
<del>}
<del>
<del>// TestInfoDiscoveryAdvertiseInterfaceName verifies that a daemon run with `--cluster-advertise`
<del>// configured with interface name properly show the advertise ip-address in info output.
<del>func (s *DockerSuite) TestInfoDiscoveryAdvertiseInterfaceName(c *testing.T) {
<del> testRequires(c, testEnv.IsLocalDaemon, Network, DaemonIsLinux)
<del>
<del> d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
<del> discoveryBackend := "consul://consuladdr:consulport/some/path"
<del> discoveryAdvertise := "eth0"
<del>
<del> d.Start(c, fmt.Sprintf("--cluster-store=%s", discoveryBackend), fmt.Sprintf("--cluster-advertise=%s:2375", discoveryAdvertise))
<del> defer d.Stop(c)
<del>
<del> iface, err := net.InterfaceByName(discoveryAdvertise)
<del> assert.NilError(c, err)
<del> addrs, err := iface.Addrs()
<del> assert.NilError(c, err)
<del> assert.Assert(c, len(addrs) > 0)
<del> ip, _, err := net.ParseCIDR(addrs[0].String())
<del> assert.NilError(c, err)
<del>
<del> out, err := d.Cmd("info")
<del> assert.NilError(c, err)
<del> assert.Assert(c, strings.Contains(out, fmt.Sprintf("Cluster Store: %s\n", discoveryBackend)))
<del> assert.Assert(c, strings.Contains(out, fmt.Sprintf("Cluster Advertise: %s:2375\n", ip.String())))
<del>}
<del>
<ide> func (s *DockerSuite) TestInfoDisplaysRunningContainers(c *testing.T) {
<ide> testRequires(c, DaemonIsLinux)
<ide>
<ide> func (s *DockerSuite) TestInfoDisplaysStoppedContainers(c *testing.T) {
<ide> assert.Assert(c, strings.Contains(out, fmt.Sprintf(" Stopped: %d\n", existing["ContainersStopped"]+1)))
<ide> }
<ide>
<del>func (s *DockerSuite) TestInfoDebug(c *testing.T) {
<del> testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux)
<del>
<del> d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
<del> d.Start(c, "--debug")
<del> defer d.Stop(c)
<del>
<del> out, err := d.Cmd("--debug", "info")
<del> assert.NilError(c, err)
<del> assert.Assert(c, strings.Contains(out, "Debug Mode (client): true\n"))
<del> assert.Assert(c, strings.Contains(out, "Debug Mode (server): true\n"))
<del> assert.Assert(c, strings.Contains(out, "File Descriptors"))
<del> assert.Assert(c, strings.Contains(out, "Goroutines"))
<del> assert.Assert(c, strings.Contains(out, "System Time"))
<del> assert.Assert(c, strings.Contains(out, "EventsListeners"))
<del> assert.Assert(c, strings.Contains(out, "Docker Root Dir"))
<del>}
<del>
<del>func (s *DockerSuite) TestInsecureRegistries(c *testing.T) {
<del> testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux)
<del>
<del> registryCIDR := "192.168.1.0/24"
<del> registryHost := "insecurehost.com:5000"
<del>
<del> d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
<del> d.Start(c, "--insecure-registry="+registryCIDR, "--insecure-registry="+registryHost)
<del> defer d.Stop(c)
<del>
<del> out, err := d.Cmd("info")
<del> assert.NilError(c, err)
<del> assert.Assert(c, strings.Contains(out, "Insecure Registries:\n"))
<del> assert.Assert(c, strings.Contains(out, fmt.Sprintf(" %s\n", registryHost)))
<del> assert.Assert(c, strings.Contains(out, fmt.Sprintf(" %s\n", registryCIDR)))
<del>}
<del>
<del>func (s *DockerDaemonSuite) TestRegistryMirrors(c *testing.T) {
<del>
<del> registryMirror1 := "https://192.168.1.2"
<del> registryMirror2 := "http://registry.mirror.com:5000"
<del>
<del> s.d.Start(c, "--registry-mirror="+registryMirror1, "--registry-mirror="+registryMirror2)
<del>
<del> out, err := s.d.Cmd("info")
<del> assert.NilError(c, err)
<del> assert.Assert(c, strings.Contains(out, "Registry Mirrors:\n"))
<del> assert.Assert(c, strings.Contains(out, fmt.Sprintf(" %s", registryMirror1)))
<del> assert.Assert(c, strings.Contains(out, fmt.Sprintf(" %s", registryMirror2)))
<del>}
<del>
<ide> func existingContainerStates(c *testing.T) map[string]int {
<ide> out, _ := dockerCmd(c, "info", "--format", "{{json .}}")
<ide> var m map[string]interface{}
<ide><path>integration-cli/docker_cli_info_unix_test.go
<ide> package main
<ide>
<ide> import (
<del> "strings"
<add> "context"
<ide> "testing"
<ide>
<add> "github.com/docker/docker/client"
<ide> "gotest.tools/assert"
<add> is "gotest.tools/assert/cmp"
<ide> )
<ide>
<ide> func (s *DockerSuite) TestInfoSecurityOptions(c *testing.T) {
<del> testRequires(c, testEnv.IsLocalDaemon, seccompEnabled, Apparmor, DaemonIsLinux)
<add> testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux)
<add> if !seccompEnabled() && !Apparmor() {
<add> c.Skip("test requires Seccomp and/or AppArmor")
<add> }
<ide>
<del> out, _ := dockerCmd(c, "info")
<del> assert.Assert(c, strings.Contains(out, "Security Options:\n apparmor\n seccomp\n Profile: default\n"))
<add> cli, err := client.NewClientWithOpts(client.FromEnv)
<add> assert.NilError(c, err)
<add> defer cli.Close()
<add> info, err := cli.Info(context.Background())
<add> assert.NilError(c, err)
<add>
<add> if Apparmor() {
<add> assert.Check(c, is.Contains(info.SecurityOptions, "name=apparmor"))
<add> }
<add> if seccompEnabled() {
<add> assert.Check(c, is.Contains(info.SecurityOptions, "name=seccomp,profile=default"))
<add> }
<ide> }
<ide><path>integration/system/info_linux_test.go
<ide> package system // import "github.com/docker/docker/integration/system"
<ide>
<ide> import (
<ide> "context"
<add> "fmt"
<add> "net"
<ide> "net/http"
<ide> "testing"
<ide>
<add> "github.com/docker/docker/testutil/daemon"
<ide> req "github.com/docker/docker/testutil/request"
<ide> "gotest.tools/assert"
<ide> is "gotest.tools/assert/cmp"
<add> "gotest.tools/skip"
<ide> )
<ide>
<ide> func TestInfoBinaryCommits(t *testing.T) {
<ide> func TestInfoAPIVersioned(t *testing.T) {
<ide> assert.Check(t, is.Contains(out, "ExecutionDriver"))
<ide> assert.Check(t, is.Contains(out, "not supported"))
<ide> }
<add>
<add>// TestInfoDiscoveryBackend verifies that a daemon run with `--cluster-advertise` and
<add>// `--cluster-store` properly returns the backend's endpoint in info output.
<add>func TestInfoDiscoveryBackend(t *testing.T) {
<add> skip.If(t, testEnv.IsRemoteDaemon, "cannot run daemon when remote daemon")
<add>
<add> const (
<add> discoveryBackend = "consul://consuladdr:consulport/some/path"
<add> discoveryAdvertise = "1.1.1.1:2375"
<add> )
<add>
<add> d := daemon.New(t)
<add> d.Start(t, "--cluster-store="+discoveryBackend, "--cluster-advertise="+discoveryAdvertise)
<add> defer d.Stop(t)
<add>
<add> info := d.Info(t)
<add> assert.Equal(t, info.ClusterStore, discoveryBackend)
<add> assert.Equal(t, info.ClusterAdvertise, discoveryAdvertise)
<add>}
<add>
<add>// TestInfoDiscoveryInvalidAdvertise verifies that a daemon run with
<add>// an invalid `--cluster-advertise` configuration
<add>func TestInfoDiscoveryInvalidAdvertise(t *testing.T) {
<add> skip.If(t, testEnv.IsRemoteDaemon, "cannot run daemon when remote daemon")
<add> d := daemon.New(t)
<add>
<add> // --cluster-advertise with an invalid string is an error
<add> err := d.StartWithError("--cluster-store=consul://consuladdr:consulport/some/path", "--cluster-advertise=invalid")
<add> if err == nil {
<add> d.Stop(t)
<add> }
<add> assert.ErrorContains(t, err, "", "expected error when starting daemon")
<add>
<add> // --cluster-advertise without --cluster-store is also an error
<add> err = d.StartWithError("--cluster-advertise=1.1.1.1:2375")
<add> if err == nil {
<add> d.Stop(t)
<add> }
<add> assert.ErrorContains(t, err, "", "expected error when starting daemon")
<add>}
<add>
<add>// TestInfoDiscoveryAdvertiseInterfaceName verifies that a daemon run with `--cluster-advertise`
<add>// configured with interface name properly show the advertise ip-address in info output.
<add>func TestInfoDiscoveryAdvertiseInterfaceName(t *testing.T) {
<add> skip.If(t, testEnv.IsRemoteDaemon, "cannot run daemon when remote daemon")
<add> // TODO should we check for networking availability (integration-cli suite checks for networking through `Network()`)
<add>
<add> d := daemon.New(t)
<add> const (
<add> discoveryStore = "consul://consuladdr:consulport/some/path"
<add> discoveryInterface = "eth0"
<add> )
<add>
<add> d.Start(t, "--cluster-store="+discoveryStore, fmt.Sprintf("--cluster-advertise=%s:2375", discoveryInterface))
<add> defer d.Stop(t)
<add>
<add> iface, err := net.InterfaceByName(discoveryInterface)
<add> assert.NilError(t, err)
<add> addrs, err := iface.Addrs()
<add> assert.NilError(t, err)
<add> assert.Assert(t, len(addrs) > 0)
<add> ip, _, err := net.ParseCIDR(addrs[0].String())
<add> assert.NilError(t, err)
<add>
<add> info := d.Info(t)
<add> assert.Equal(t, info.ClusterStore, discoveryStore)
<add> assert.Equal(t, info.ClusterAdvertise, ip.String()+":2375")
<add>}
<ide><path>integration/system/info_test.go
<ide> package system // import "github.com/docker/docker/integration/system"
<ide> import (
<ide> "context"
<ide> "fmt"
<add> "sort"
<ide> "testing"
<ide>
<add> "github.com/docker/docker/api/types/registry"
<ide> "github.com/docker/docker/testutil/daemon"
<ide> "gotest.tools/assert"
<ide> is "gotest.tools/assert/cmp"
<ide> func TestInfoAPIWarnings(t *testing.T) {
<ide> d := daemon.New(t)
<ide> c := d.NewClientT(t)
<ide>
<del> d.StartWithBusybox(t, "-H=0.0.0.0:23756", "-H="+d.Sock())
<add> d.Start(t, "-H=0.0.0.0:23756", "-H="+d.Sock())
<ide> defer d.Stop(t)
<ide>
<ide> info, err := c.Info(context.Background())
<ide> func TestInfoAPIWarnings(t *testing.T) {
<ide> assert.Check(t, is.Contains(out, linePrefix))
<ide> }
<ide> }
<add>
<add>func TestInfoDebug(t *testing.T) {
<add> skip.If(t, testEnv.IsRemoteDaemon, "cannot run daemon when remote daemon")
<add>
<add> d := daemon.New(t)
<add> d.Start(t, "--debug")
<add> defer d.Stop(t)
<add>
<add> info := d.Info(t)
<add> assert.Equal(t, info.Debug, true)
<add>
<add> // Note that the information below is not tied to debug-mode being enabled.
<add> assert.Check(t, info.NFd != 0)
<add>
<add> // TODO need a stable way to generate event listeners
<add> // assert.Check(t, info.NEventsListener != 0)
<add> assert.Check(t, info.NGoroutines != 0)
<add> assert.Check(t, info.SystemTime != "")
<add> assert.Equal(t, info.DockerRootDir, d.Root)
<add>}
<add>
<add>func TestInfoInsecureRegistries(t *testing.T) {
<add> skip.If(t, testEnv.IsRemoteDaemon, "cannot run daemon when remote daemon")
<add>
<add> const (
<add> registryCIDR = "192.168.1.0/24"
<add> registryHost = "insecurehost.com:5000"
<add> )
<add>
<add> d := daemon.New(t)
<add> d.Start(t, "--insecure-registry="+registryCIDR, "--insecure-registry="+registryHost)
<add> defer d.Stop(t)
<add>
<add> info := d.Info(t)
<add> assert.Assert(t, is.Len(info.RegistryConfig.InsecureRegistryCIDRs, 2))
<add> cidrs := []string{
<add> info.RegistryConfig.InsecureRegistryCIDRs[0].String(),
<add> info.RegistryConfig.InsecureRegistryCIDRs[1].String(),
<add> }
<add> assert.Assert(t, is.Contains(cidrs, registryCIDR))
<add> assert.Assert(t, is.Contains(cidrs, "127.0.0.0/8"))
<add> assert.DeepEqual(t, *info.RegistryConfig.IndexConfigs["docker.io"], registry.IndexInfo{Name: "docker.io", Mirrors: []string{}, Secure: true, Official: true})
<add> assert.DeepEqual(t, *info.RegistryConfig.IndexConfigs[registryHost], registry.IndexInfo{Name: registryHost, Mirrors: []string{}, Secure: false, Official: false})
<add>}
<add>
<add>func TestInfoRegistryMirrors(t *testing.T) {
<add> skip.If(t, testEnv.IsRemoteDaemon, "cannot run daemon when remote daemon")
<add>
<add> const (
<add> registryMirror1 = "https://192.168.1.2"
<add> registryMirror2 = "http://registry.mirror.com:5000"
<add> )
<add>
<add> d := daemon.New(t)
<add> d.Start(t, "--registry-mirror="+registryMirror1, "--registry-mirror="+registryMirror2)
<add> defer d.Stop(t)
<add>
<add> info := d.Info(t)
<add> sort.Strings(info.RegistryConfig.Mirrors)
<add> assert.DeepEqual(t, info.RegistryConfig.Mirrors, []string{registryMirror2 + "/", registryMirror1 + "/"})
<add>}
| 4
|
Python
|
Python
|
fix lint errors
|
e4bf28fc63b958406c5700f413f037b2344b7f8a
|
<ide><path>official/transformer/v2/transformer_main.py
<ide> def __init__(self, flags_obj):
<ide>
<ide> print("Running transformer with num_gpus =", num_gpus)
<ide> if self.distribution_strategy:
<del> print("For training, using distribution strategy: ", self.distribution_strategy)
<add> print("For training, using distribution strategy: ",
<add> self.distribution_strategy)
<ide> else:
<ide> print("Not using any distribution strategy.")
<del>
<add>
<ide> self.params = params = misc.get_model_params(flags_obj.param_set, num_gpus)
<ide>
<ide> params["num_gpus"] = num_gpus
<ide> def predict(self):
<ide> with tf.name_scope("model"):
<ide> model = transformer.create_model(params, is_train)
<ide> self._load_weights_if_possible(
<del> model, tf.train.latest_checkpoint(self.flags_obj.model_dir))
<add> model, tf.train.latest_checkpoint(self.flags_obj.model_dir))
<ide> model.summary()
<ide> subtokenizer = tokenizer.Subtokenizer(flags_obj.vocab_file)
<ide>
| 1
|
Ruby
|
Ruby
|
fix symlink path
|
ef7a5cfa3acd85efc55b6aff97f55ddecb238b8b
|
<ide><path>Library/Homebrew/tap.rb
<ide> def unlink_manpages
<ide> return unless (path/"man").exist?
<ide> (path/"man").find do |src|
<ide> next if src.directory?
<del> dst = HOMEBREW_PREFIX/src.relative_path_from(path)
<add> dst = HOMEBREW_PREFIX/"share"/src.relative_path_from(path)
<ide> dst.delete if dst.symlink? && src == dst.resolved_path
<ide> dst.parent.rmdir_if_possible
<ide> end
| 1
|
Text
|
Text
|
change "diga hola" for "salude"
|
33d14922dc0162c7b23cdeb6c76f714932865f4f
|
<ide><path>guide/spanish/certifications/responsive-web-design/basic-html-and-html5/say-hello-to-html-elements/index.md
<ide> title: Say Hello to HTML Elements
<ide> localeTitle: Diga hola a los elementos HTML
<ide> ---
<del>## Diga hola a los elementos HTML
<add>## Salude a los elementos HTML
<ide>
<ide> Considere el siguiente ejemplo:
<ide>
<ide> Recuerda la solicitud de desafío:
<ide>
<ide> > cambia el texto de tu elemento h1 para que diga "Hola mundo"
<ide>
<del>¡Buena suerte!
<ide>\ No newline at end of file
<add>¡Buena suerte!
| 1
|
PHP
|
PHP
|
use use statement for internal classes
|
f18488f90574ae0010f46e703f3bab4c1862b099
|
<ide><path>src/TestSuite/TestCase.php
<ide> use Cake\Core\App;
<ide> use Cake\Core\Configure;
<ide> use Cake\Datasource\ConnectionManager;
<add>use Cake\ORM\Exception\MissingTableClassException;
<ide> use Cake\ORM\TableRegistry;
<ide> use Cake\Routing\Router;
<ide> use Cake\Utility\Inflector;
<ide> public function getMockForModel($alias, array $methods = [], array $options = []
<ide> $class = Inflector::camelize($alias);
<ide> $className = App::className($class, 'Model/Table', 'Table');
<ide> if (!$className) {
<del> throw new \Cake\ORM\Exception\MissingTableClassException([$alias]);
<add> throw new MissingTableClassException([$alias]);
<ide> }
<ide> $options['className'] = $className;
<ide> }
| 1
|
Javascript
|
Javascript
|
fix linting issues
|
a419d47ef8c457f80a6ee31fc362e68dadb2a9b3
|
<ide><path>src/main-process/atom-window.js
<ide> class AtomWindow extends EventEmitter {
<ide> if (this.shouldHideTitleBar()) options.frame = false
<ide> this.browserWindow = new BrowserWindow(options)
<ide>
<del>
<ide> if (this.atomApplication.projectSettings != null) {
<ide> this.projectSettings = this.atomApplication.projectSettings
<ide> }
<ide> class AtomWindow extends EventEmitter {
<ide> return paths.every(p => this.containsPath(p))
<ide> }
<ide>
<del> loadDataOverProcessBoundary() {
<add> loadDataOverProcessBoundary () {
<ide> Object.defineProperty(this.browserWindow, 'loadSettingsJSON', {
<ide> get: () => JSON.stringify(Object.assign({
<ide> userSettings: this.atomApplication.configFile.get(),
<ide><path>src/main-process/parse-command-line.js
<ide> module.exports = function parseCommandLine (processArgs) {
<ide> pathsToOpen = pathsToOpen.concat(paths)
<ide> }
<ide> projectSettings = { originPath, paths, config }
<del>
<ide> }
<ide>
<ide> if (devMode) {
<ide> const readProjectSettingsSync = (filepath, executedFrom) => {
<ide> if (contents.paths || contents.config) {
<ide> return contents
<ide> }
<del>
<ide> } catch (e) {
<ide> throw new Error('Unable to read supplied config file.')
<ide> }
| 2
|
Text
|
Text
|
remove changelog that is included in 7.0
|
a35a380c2cdc7fe032f927095545aee21a192f54
|
<ide><path>activesupport/CHANGELOG.md
<del>* Fix `ActiveSupport::Duration.build` to support negative values.
<ide>
<del> The algorithm to collect the `parts` of the `ActiveSupport::Duration`
<del> ignored the sign of the `value` and accumulated incorrect part values. This
<del> impacted `ActiveSupport::Duration#sum` (which is dependent on `parts`) but
<del> not `ActiveSupport::Duration#eql?` (which is dependent on `value`).
<del>
<del> *Caleb Buxton*, *Braden Staudacher*
<ide>
<ide> Please check [7-0-stable](https://github.com/rails/rails/blob/7-0-stable/activesupport/CHANGELOG.md) for previous changes.
| 1
|
Ruby
|
Ruby
|
fix failing tests after merge
|
6545a68264682e8d0a0ee0e913fa98d92fef9428
|
<ide><path>actionmailer/lib/action_mailer/mail_helper.rb
<ide> def block_format(text)
<ide>
<ide> # Access the mailer instance.
<ide> def mailer #:nodoc:
<del> @controller
<add> @_controller
<ide> end
<ide> end
<ide> end
<ide><path>actionpack/lib/action_controller/metal/helpers.rb
<ide> def all_application_helpers
<ide> extract = /^#{Regexp.quote(path)}\/?(.*)_helper.rb$/
<ide> helpers += Dir["#{path}/**/*_helper.rb"].map { |file| file.sub(extract, '\1') }
<ide> end
<add> helpers.sort!
<ide> helpers.uniq!
<ide> helpers
<ide> end
<ide><path>actionpack/test/abstract/helper_test.rb
<ide> require 'abstract_unit'
<ide>
<del>ActionController::Base.helpers_dir = File.dirname(__FILE__) + '/../fixtures/helpers'
<add>ActionController::Base.helpers_path = [File.dirname(__FILE__) + '/../fixtures/helpers']
<ide>
<ide> module AbstractController
<ide> module Testing
<ide><path>actionpack/test/controller/helper_test.rb
<ide> require 'abstract_unit'
<ide> require 'active_support/core_ext/kernel/reporting'
<ide>
<del>ActionController::Base.helpers_dir = File.dirname(__FILE__) + '/../fixtures/helpers'
<add>ActionController::Base.helpers_path = [File.dirname(__FILE__) + '/../fixtures/helpers']
<ide>
<ide> module Fun
<ide> class GamesController < ActionController::Base
<ide> def test_all_helpers
<ide> end
<ide>
<ide> def test_all_helpers_with_alternate_helper_dir
<del> @controller_class.helpers_dir = File.dirname(__FILE__) + '/../fixtures/alternate_helpers'
<add> @controller_class.helpers_path = [File.dirname(__FILE__) + '/../fixtures/alternate_helpers']
<ide>
<ide> # Reload helpers
<ide> @controller_class._helpers = Module.new
<ide><path>actionpack/test/fixtures/helpers/fun/games_helper.rb
<del>module Fun::GamesHelper
<del> def stratego() "Iz guuut!" end
<add>module Fun
<add> module GamesHelper
<add> def stratego() "Iz guuut!" end
<add> end
<ide> end
<ide>\ No newline at end of file
<ide><path>actionpack/test/fixtures/helpers/fun/pdf_helper.rb
<del>module Fun::PdfHelper
<del> def foobar() 'baz' end
<add>module Fun
<add> module PdfHelper
<add> def foobar() 'baz' end
<add> end
<ide> end
| 6
|
Ruby
|
Ruby
|
add docs and guards to `while_preventing_writes`
|
28468e43b0c54c49a4167177e9f6d6233269b2de
|
<ide><path>activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
<ide> def prevent_writes=(prevent_writes) # :nodoc:
<ide> # See `READ_QUERY` for the queries that are blocked by this
<ide> # method.
<ide> def while_preventing_writes(enabled = true)
<add> unless ActiveRecord::Base.legacy_connection_handling
<add> raise NotImplementedError, "`while_preventing_writes` is only available on the connection_handler with legacy_connection_handling"
<add> end
<add>
<ide> original, self.prevent_writes = self.prevent_writes, enabled
<ide> yield
<ide> ensure
<ide><path>activerecord/lib/active_record/connection_handling.rb
<ide> def connecting_to(role: default_role, shard: default_shard, prevent_writes: fals
<ide> self.connected_to_stack << { role: role, shard: shard, prevent_writes: prevent_writes, klass: self }
<ide> end
<ide>
<add> # Prevent writing to the database regardless of role.
<add> #
<add> # In some cases you may want to prevent writes to the database
<add> # even if you are on a database that can write. `while_preventing_writes`
<add> # will prevent writes to the database for the duration of the block.
<add> #
<add> # This method does not provide the same protection as a readonly
<add> # user and is meant to be a safeguard against accidental writes.
<add> #
<add> # See `READ_QUERY` for the queries that are blocked by this
<add> # method.
<ide> def while_preventing_writes(enabled = true, &block)
<del> connected_to(role: current_role, prevent_writes: enabled, &block)
<add> if legacy_connection_handling
<add> connection_handler.while_preventing_writes(enabled)
<add> else
<add> connected_to(role: current_role, prevent_writes: enabled, &block)
<add> end
<ide> end
<ide>
<ide> # Returns true if role is the current connected role.
| 2
|
Javascript
|
Javascript
|
add assertion for {{#each foo in bar}} syntax
|
aa2cbd87758f2408ba6e4b9e4cd0d3a86f62819c
|
<ide><path>packages/ember-template-compiler/lib/index.js
<ide> import TransformEachIntoCollection from 'ember-template-compiler/plugins/transfo
<ide> import TransformUnescapedInlineLinkTo from 'ember-template-compiler/plugins/transform-unescaped-inline-link-to';
<ide> import AssertNoViewAndControllerPaths from 'ember-template-compiler/plugins/assert-no-view-and-controller-paths';
<ide> import AssertNoViewHelper from 'ember-template-compiler/plugins/assert-no-view-helper';
<add>import AssertNoEachIn from 'ember-template-compiler/plugins/assert-no-each-in';
<ide>
<ide> // used for adding Ember.Handlebars.compile for backwards compat
<ide> import 'ember-template-compiler/compat';
<ide> registerPlugin('ast', TransformAngleBracketComponents);
<ide> registerPlugin('ast', TransformInputOnToOnEvent);
<ide> registerPlugin('ast', TransformTopLevelComponents);
<ide> registerPlugin('ast', TransformUnescapedInlineLinkTo);
<add>registerPlugin('ast', AssertNoEachIn);
<ide>
<ide> if (_Ember.ENV._ENABLE_LEGACY_VIEW_SUPPORT) {
<ide> registerPlugin('ast', TransformEachIntoCollection);
<ide><path>packages/ember-template-compiler/lib/plugins/assert-no-each-in.js
<add>import Ember from 'ember-metal/core';
<add>import { assert } from 'ember-metal/debug';
<add>import calculateLocationDisplay from 'ember-template-compiler/system/calculate-location-display';
<add>
<add>function AssertNoEachIn(options = {}) {
<add> this.syntax = null;
<add> this.options = options;
<add>}
<add>
<add>AssertNoEachIn.prototype.transform = function AssertNoEachIn_transform(ast) {
<add> if (!!Ember.ENV._ENABLE_LEGACY_VIEW_SUPPORT) {
<add> return ast;
<add> }
<add> let walker = new this.syntax.Walker();
<add> let moduleName = this.options && this.options.moduleName;
<add>
<add> walker.visit(ast, function(node) {
<add> if (!validate(node)) { return; }
<add> assertHelper(moduleName, node);
<add> });
<add>
<add> return ast;
<add>};
<add>
<add>function assertHelper(moduleName, node) {
<add> let moduleInfo = calculateLocationDisplay(moduleName, node.loc);
<add> let singular = node.params[0].original;
<add> let plural = node.params[2].original;
<add>
<add> assert(`Using {{#each ${singular} in ${plural}}} ${moduleInfo}is no longer supported in Ember 2.0+, please use {{#each ${plural} as |${singular}|}}`);
<add>}
<add>
<add>function validate(node) {
<add> return (node.type === 'BlockStatement' || node.type === 'MustacheStatement') &&
<add> node.path.original === 'each' &&
<add> node.params.length === 3 &&
<add> node.params[1].type === 'PathExpression' &&
<add> node.params[1].original === 'in';
<add>}
<add>
<add>export default AssertNoEachIn;
<ide><path>packages/ember-template-compiler/lib/plugins/transform-each-in-to-hash.js
<del>/**
<del>@module ember
<del>@submodule ember-htmlbars
<del>*/
<del>
<del>
<del>/**
<del> An HTMLBars AST transformation that replaces all instances of
<del>
<del> ```handlebars
<del> {{#each item in items}}
<del> {{/each}}
<del> ```
<del>
<del> with
<del>
<del> ```handlebars
<del> {{#each items keyword="item"}}
<del> {{/each}}
<del> ```
<del>
<del> @class TransformEachInToHash
<del> @private
<del>*/
<del>function TransformEachInToHash(options = {}) {
<del> // set later within HTMLBars to the syntax package
<del> this.syntax = null;
<del> this.options = options;
<del>}
<del>
<del>/**
<del> @private
<del> @method transform
<del> @param {AST} ast The AST to be transformed.
<del>*/
<del>TransformEachInToHash.prototype.transform = function TransformEachInToHash_transform(ast) {
<del> var pluginContext = this;
<del> var walker = new pluginContext.syntax.Walker();
<del> var b = pluginContext.syntax.builders;
<del>
<del> walker.visit(ast, function(node) {
<del> if (pluginContext.validate(node)) {
<del> if (node.program && node.program.blockParams.length) {
<del> throw new Error('You cannot use keyword (`{{each foo in bar}}`) and block params (`{{each bar as |foo|}}`) at the same time.');
<del> }
<del>
<del> var removedParams = node.sexpr.params.splice(0, 2);
<del> var keyword = removedParams[0].original;
<del>
<del> // TODO: This may not be necessary.
<del> if (!node.sexpr.hash) {
<del> node.sexpr.hash = b.hash();
<del> }
<del>
<del> node.sexpr.hash.pairs.push(b.pair(
<del> 'keyword',
<del> b.string(keyword)
<del> ));
<del> }
<del> });
<del>
<del> return ast;
<del>};
<del>
<del>TransformEachInToHash.prototype.validate = function TransformEachInToHash_validate(node) {
<del> return (node.type === 'BlockStatement' || node.type === 'MustacheStatement') &&
<del> node.sexpr.path.original === 'each' &&
<del> node.sexpr.params.length === 3 &&
<del> node.sexpr.params[1].type === 'PathExpression' &&
<del> node.sexpr.params[1].original === 'in';
<del>};
<del>
<del>export default TransformEachInToHash;
<ide><path>packages/ember-template-compiler/tests/plugins/assert-no-each-in-test.js
<add>import Ember from 'ember-metal/core';
<add>import { compile } from 'ember-template-compiler';
<add>
<add>let legacyViewSupportOriginalValue;
<add>
<add>QUnit.module('ember-template-compiler: assert-no-each-in-test without legacy view support', {
<add> setup() {
<add> legacyViewSupportOriginalValue = Ember.ENV._ENABLE_LEGACY_VIEW_SUPPORT;
<add> Ember.ENV._ENABLE_LEGACY_VIEW_SUPPORT = false;
<add> },
<add>
<add> teardown() {
<add> Ember.ENV._ENABLE_LEGACY_VIEW_SUPPORT = legacyViewSupportOriginalValue;
<add> }
<add>});
<add>
<add>QUnit.test('{{#each foo in bar}} is not allowed', function() {
<add> expect(1);
<add>
<add> expectAssertion(function() {
<add> compile('{{#each person in people}}{{person.name}}{{/each}}', {
<add> moduleName: 'foo/bar/baz'
<add> });
<add> }, `Using {{#each person in people}} ('foo/bar/baz' @ L1:C0) is no longer supported in Ember 2.0+, please use {{#each people as |person|}}`);
<add>});
<add>
<add>
<add>QUnit.module('ember-template-compiler: assert-no-each-in-test with legacy view support', {
<add> setup() {
<add> legacyViewSupportOriginalValue = Ember.ENV._ENABLE_LEGACY_VIEW_SUPPORT;
<add> Ember.ENV._ENABLE_LEGACY_VIEW_SUPPORT = true;
<add> },
<add>
<add> teardown() {
<add> Ember.ENV._ENABLE_LEGACY_VIEW_SUPPORT = legacyViewSupportOriginalValue;
<add> }
<add>});
<add>
<add>QUnit.test('{{#each foo in bar}} is allowed', function() {
<add> expect(1);
<add>
<add> compile('{{#each person in people}}{{person.name}}{{/each}}', {
<add> moduleName: 'foo/bar/baz'
<add> });
<add>
<add> ok(true);
<add>});
| 4
|
Javascript
|
Javascript
|
rename triangle.uvintersection to getuv
|
c48d55fc3a11004edb2a8837373f77661cc838b8
|
<ide><path>src/math/Triangle.js
<del>import { Vector2 } from './Vector2.js';
<ide> import { Vector3 } from './Vector3.js';
<ide>
<ide> /**
<ide> Object.assign( Triangle, {
<ide>
<ide> }(),
<ide>
<del> uvIntersection: function () {
<add> getUV: function () {
<ide>
<ide> var barycoord = new Vector3();
<del> var v1 = new Vector2();
<del> var v2 = new Vector2();
<del> var v3 = new Vector2();
<ide>
<del> return function uvIntersection( point, p1, p2, p3, uv1, uv2, uv3, result ) {
<add> return function getUV( point, p1, p2, p3, uv1, uv2, uv3, target ) {
<ide>
<ide> this.getBarycoord( point, p1, p2, p3, barycoord );
<ide>
<del> v1.copy( uv1 ).multiplyScalar( barycoord.x );
<del> v2.copy( uv2 ).multiplyScalar( barycoord.y );
<del> v3.copy( uv3 ).multiplyScalar( barycoord.z );
<add> target.set( 0, 0 );
<add> target.addScaledVector( uv1, barycoord.x );
<add> target.addScaledVector( uv2, barycoord.y );
<add> target.addScaledVector( uv3, barycoord.z );
<ide>
<del> v1.add( v2 ).add( v3 );
<del>
<del> return result.copy( v1 );
<add> return target;
<ide>
<ide> };
<ide>
<ide> Object.assign( Triangle.prototype, {
<ide>
<ide> },
<ide>
<del> uvIntersection: function ( point, uv1, uv2, uv3, result ) {
<add> getUV: function ( point, uv1, uv2, uv3, result ) {
<ide>
<del> return Triangle.uvIntersection( point, this.a, this.b, this.c, uv1, uv2, uv3, result );
<add> return Triangle.getUV( point, this.a, this.b, this.c, uv1, uv2, uv3, result );
<ide>
<ide> },
<ide>
<ide><path>src/objects/Mesh.js
<ide> Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), {
<ide> uvB.fromBufferAttribute( uv, b );
<ide> uvC.fromBufferAttribute( uv, c );
<ide>
<del> intersection.uv = Triangle.uvIntersection( intersectionPoint, vA, vB, vC, uvA, uvB, uvC, new Vector2() );
<add> intersection.uv = Triangle.getUV( intersectionPoint, vA, vB, vC, uvA, uvB, uvC, new Vector2() );
<ide>
<ide> }
<ide>
<ide> Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), {
<ide> uvB.copy( uvs_f[ 1 ] );
<ide> uvC.copy( uvs_f[ 2 ] );
<ide>
<del> intersection.uv = Triangle.uvIntersection( intersectionPoint, fvA, fvB, fvC, uvA, uvB, uvC, new Vector2() );
<add> intersection.uv = Triangle.getUV( intersectionPoint, fvA, fvB, fvC, uvA, uvB, uvC, new Vector2() );
<ide>
<ide> }
<ide>
<ide><path>src/objects/Sprite.js
<ide> Sprite.prototype = Object.assign( Object.create( Object3D.prototype ), {
<ide>
<ide> distance: distance,
<ide> point: intersectPoint.clone(),
<del> uv: Triangle.uvIntersection( intersectPoint, vA, vB, vC, uvA, uvB, uvC, new Vector2() ),
<add> uv: Triangle.getUV( intersectPoint, vA, vB, vC, uvA, uvB, uvC, new Vector2() ),
<ide> face: null,
<ide> object: this
<ide>
| 3
|
Javascript
|
Javascript
|
fix listview to work with native animated.event
|
f8f70d22757ba3d2877954706d93efcc9c0fac3b
|
<ide><path>Libraries/CustomComponents/ListView/ListView.js
<ide> var ListView = React.createClass({
<ide> }
<ide> },
<ide>
<add> getScrollableNode: function() {
<add> if (this._scrollComponent && this._scrollComponent.getScrollableNode) {
<add> return this._scrollComponent.getScrollableNode();
<add> } else {
<add> return ReactNative.findNodeHandle(this._scrollComponent);
<add> }
<add> },
<add>
<ide> /**
<ide> * Scrolls to a given x, y offset, either immediately or with a smooth animation.
<ide> *
| 1
|
Go
|
Go
|
use "transfermanager" in godoc
|
587c474b57263e79f2b72bbc19fd67f86c30e495
|
<ide><path>distribution/xfer/transfer.go
<ide> type transfer struct {
<ide> // running remains open as long as the transfer is in progress.
<ide> running chan struct{}
<ide> // released stays open until all watchers release the transfer and
<del> // the transfer is no longer tracked by the transfer manager.
<add> // the transfer is no longer tracked by the transferManager.
<ide> released chan struct{}
<ide>
<ide> // broadcastDone is true if the main progress channel has closed.
<ide> func (t *transfer) Done() <-chan struct{} {
<ide> }
<ide>
<ide> // Released returns a channel which is closed once all watchers release the
<del>// transfer AND the transfer is no longer tracked by the transfer manager.
<add>// transfer AND the transfer is no longer tracked by the transferManager.
<ide> func (t *transfer) Released() <-chan struct{} {
<ide> return t.released
<ide> }
<ide> func (t *transfer) Context() context.Context {
<ide> return t.ctx
<ide> }
<ide>
<del>// Close is called by the transfer manager when the transfer is no longer
<add>// Close is called by the transferManager when the transfer is no longer
<ide> // being tracked.
<ide> func (t *transfer) Close() {
<ide> t.mu.Lock()
<ide> func (t *transfer) Close() {
<ide> t.mu.Unlock()
<ide> }
<ide>
<del>// DoFunc is a function called by the transfer manager to actually perform
<add>// DoFunc is a function called by the transferManager to actually perform
<ide> // a transfer. It should be non-blocking. It should wait until the start channel
<ide> // is closed before transferring any data. If the function closes inactive, that
<del>// signals to the transfer manager that the job is no longer actively moving
<add>// signals to the transferManager that the job is no longer actively moving
<ide> // data - for example, it may be waiting for a dependent transfer to finish.
<ide> // This prevents it from taking up a slot.
<ide> type DoFunc func(progressChan chan<- progress.Progress, start <-chan struct{}, inactive chan<- struct{}) Transfer
| 1
|
Python
|
Python
|
fix longdouble precision check
|
a5d002e2b969d59e1cea226361f7518921c289e0
|
<ide><path>numpy/core/tests/test_umath.py
<ide> def check(x, rtol):
<ide> x_series = np.logspace(-20, -3.001, 200)
<ide> x_basic = np.logspace(-2.999, 0, 10, endpoint=False)
<ide>
<del> if glibc_older_than("2.19") and dtype is np.longcomplex:
<add> if dtype is np.longcomplex:
<ide> if (platform.machine() == 'aarch64' and bad_arcsinh()):
<ide> pytest.skip("Trig functions of np.longcomplex values known "
<ide> "to be inaccurate on aarch64 for some compilation "
| 1
|
Javascript
|
Javascript
|
update the hash to have default values
|
9b9554c47d61228facd3b1f081afd7af307e81f9
|
<ide><path>models/User.js
<ide> var userSchema = new mongoose.Schema({
<ide> instagram: String,
<ide> tokens: Array,
<ide> challengesCompleted: { type: Array, default: [] },
<del> challengesHash: {},
<del>
<add> challengesHash: {
<add> 0: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 1: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 2: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 3: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 4: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 5: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 6: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 7: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 8: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 9: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 10: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 11: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 12: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 13: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 14: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 15: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 16: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 17: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 18: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 19: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 20: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 21: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 22: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 23: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 24: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 25: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 26: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 27: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 28: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 29: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 30: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 31: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 32: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 33: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 34: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 35: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 36: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 37: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 38: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 39: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 40: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 41: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 42: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 43: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 44: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 45: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 46: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 47: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 48: {
<add> type: Number,
<add> default: 0,
<add> },
<add> 49: {
<add> type: Number,
<add> default: 0,
<add> }
<add> },
<ide> profile: {
<ide> name: { type: String, default: '' },
<ide> gender: { type: String, default: '' },
| 1
|
Text
|
Text
|
improve changelogs formatting [ci skip]
|
5deec016fe97c238073ea22b7cca9c796c68a0a5
|
<ide><path>actionview/CHANGELOG.md
<ide>
<ide> *Paul Seidemann*
<ide>
<del>* Ensure ActionView::Digestor.cache is correctly cleaned up when
<del> combining recursive templates with ActionView::Resolver.caching = false
<add>* Ensure `ActionView::Digestor.cache` is correctly cleaned up when
<add> combining recursive templates with `ActionView::Resolver.caching = false`.
<ide>
<ide> *wyaeld*
<ide>
<ide>
<ide> *Angel N. Sciortino*
<ide>
<del>* Fix some edge cases for AV `select` helper with `:selected` option
<add>* Fix some edge cases for AV `select` helper with `:selected` option.
<ide>
<ide> *Bogdan Gusiev*
<ide>
<ide>
<ide> *Bogdan Gusiev*
<ide>
<del>* Handle `:namespace` form option in collection labels
<add>* Handle `:namespace` form option in collection labels.
<ide>
<ide> *Vasiliy Ermolovich*
<ide>
<del>* Fix `form_for` when both `namespace` and `as` options are present
<add>* Fix `form_for` when both `namespace` and `as` options are present.
<ide>
<ide> `as` option no longer overwrites `namespace` option when generating
<del> html id attribute of the form element
<add> html id attribute of the form element.
<ide>
<ide> *Adam Niedzielski*
<ide>
<ide><path>activerecord/CHANGELOG.md
<ide>
<ide> *Yves Senn*
<ide>
<del>* Fix uninitialized constant TransactionState error when Marshall.load is used on an Active Record result.
<add>* Fix uninitialized constant `TransactionState` error when `Marshall.load` is used on an Active Record result.
<ide> Fixes #12790
<ide>
<ide> *Jason Ayre*
<ide>
<ide> *Jon Leighton*
<ide>
<del>* Added ActiveRecord::QueryMethods#rewhere which will overwrite an existing, named where condition.
<add>* Added `ActiveRecord::QueryMethods#rewhere` which will overwrite an existing, named where condition.
<ide>
<ide> Examples:
<ide>
<ide>
<ide> *DHH*
<ide>
<del>* Extend ActiveRecord::Base#cache_key to take an optional list of timestamp attributes of which the highest will be used.
<add>* Extend `ActiveRecord::Base#cache_key` to take an optional list of timestamp attributes of which the highest will be used.
<ide>
<ide> Example:
<ide>
<ide>
<ide> *DHH*
<ide>
<del>* Added ActiveRecord::Base#enum for declaring enum attributes where the values map to integers in the database, but can be queried by name.
<add>* Added `ActiveRecord::Base#enum` for declaring enum attributes where the values map to integers in the database, but can be queried by name.
<ide>
<ide> Example:
<ide>
<ide> # conversation.update! status: 0
<ide> conversation.active!
<ide> conversation.active? # => true
<del> conversation.status # => :active
<add> conversation.status # => "active"
<ide>
<ide> # conversation.update! status: 1
<ide> conversation.archived!
<ide> conversation.archived? # => true
<del> conversation.status # => :archived
<add> conversation.status # => "archived"
<ide>
<ide> # conversation.update! status: 1
<ide> conversation.status = :archived
<ide>
<ide> *DHH*
<ide>
<del>* ActiveRecord::Base#attribute_for_inspect now truncates long arrays (more than 10 elements)
<add>* `ActiveRecord::Base#attribute_for_inspect` now truncates long arrays (more than 10 elements).
<ide>
<ide> *Jan Bernacki*
<ide>
<del>* Allow for the name of the schema_migrations table to be configured.
<add>* Allow for the name of the `schema_migrations` table to be configured.
<ide>
<ide> *Jerad Phelps*
<ide>
<ide><path>activesupport/CHANGELOG.md
<del>* Fix ActiveSupport `Time#to_json` and `DateTime#to_json` to return 3 decimal
<add>* Fix Active Support `Time#to_json` and `DateTime#to_json` to return 3 decimal
<ide> places worth of fractional seconds, similar to `TimeWithZone`.
<ide>
<ide> *Ryan Glover*
<ide>
<ide> * Removed circular reference protection in JSON encoder, deprecated
<del> ActiveSupport::JSON::Encoding::CircularReferenceError.
<add> `ActiveSupport::JSON::Encoding::CircularReferenceError`.
<ide>
<ide> *Godfrey Chan*, *Sergio Campamá*
<ide>
<del>* Add `capitalize` option to Inflector.humanize, so strings can be humanized without being capitalized:
<add>* Add `capitalize` option to `Inflector.humanize`, so strings can be humanized without being capitalized:
<ide>
<ide> 'employee_salary'.humanize # => "Employee salary"
<ide> 'employee_salary'.humanize(capitalize: false) # => "employee salary"
<ide>
<ide> *claudiob*
<ide>
<del>* Fixed Object#as_json and Struct#as_json not working properly with options. They now take
<del> the same options as Hash#as_json:
<add>* Fixed `Object#as_json` and `Struct#as_json` not working properly with options. They now take
<add> the same options as `Hash#as_json`:
<ide>
<ide> struct = Struct.new(:foo, :bar).new
<ide> struct.foo = "hello"
<ide>
<ide> *Sergio Campamá*, *Godfrey Chan*
<ide>
<del>* Added Numeric#in_milliseconds, like 1.hour.in_milliseconds, so we can feed them to JavaScript functions like getTime().
<add>* Added `Numeric#in_milliseconds`, like `1.hour.in_milliseconds`, so we can feed them to JavaScript functions like `getTime()`.
<ide>
<ide> *DHH*
<ide>
<del>* Calling ActiveSupport::JSON.decode with unsupported options now raises an error.
<add>* Calling `ActiveSupport::JSON.decode` with unsupported options now raises an error.
<ide>
<ide> *Godfrey Chan*
<ide>
<del>* Support :unless_exist in FileStore
<add>* Support `:unless_exist` in `FileStore`.
<ide>
<ide> *Michael Grosser*
<ide>
| 3
|
Javascript
|
Javascript
|
fix loading from global folders on windows
|
055482c21e2df94446d9796949d1bb810e8331bf
|
<ide><path>lib/module.js
<ide> Module._initPaths = function() {
<ide> homeDir = process.env.HOME;
<ide> }
<ide>
<del> var paths = [path.resolve(process.execPath, '..', '..', 'lib', 'node')];
<add> // $PREFIX/lib/node, where $PREFIX is the root of the Node.js installation.
<add> var prefixDir;
<add> // process.execPath is $PREFIX/bin/node except on Windows where it is
<add> // $PREFIX\node.exe.
<add> if (isWindows) {
<add> prefixDir = path.resolve(process.execPath, '..');
<add> } else {
<add> prefixDir = path.resolve(process.execPath, '..', '..');
<add> }
<add> var paths = [path.resolve(prefixDir, 'lib', 'node')];
<ide>
<ide> if (homeDir) {
<ide> paths.unshift(path.resolve(homeDir, '.node_libraries'));
| 1
|
Javascript
|
Javascript
|
fix variable name for non-rsa keys
|
ccc67765276687880000008b291f72cceb19db90
|
<ide><path>test/parallel/test-webcrypto-sign-verify-rsa.js
<ide> async function testVerify({
<ide> noVerifyPublicKey,
<ide> privateKey,
<ide> hmacKey,
<del> rsaKeys
<add> ecdsaKeys
<ide> ] = await Promise.all([
<ide> subtle.importKey(
<ide> 'spki',
<ide> async function testVerify({
<ide> });
<ide>
<ide> await assert.rejects(
<del> subtle.verify(algorithm, rsaKeys.publicKey, signature, plaintext), {
<add> subtle.verify(algorithm, ecdsaKeys.publicKey, signature, plaintext), {
<ide> message: /Unable to use this key to verify/
<ide> });
<ide>
<ide> async function testSign({
<ide> noSignPrivateKey,
<ide> privateKey,
<ide> hmacKey,
<del> rsaKeys,
<add> ecdsaKeys
<ide> ] = await Promise.all([
<ide> subtle.importKey(
<ide> 'spki',
<ide> async function testSign({
<ide> });
<ide>
<ide> await assert.rejects(
<del> subtle.sign(algorithm, rsaKeys.privateKey, plaintext), {
<add> subtle.sign(algorithm, ecdsaKeys.privateKey, plaintext), {
<ide> message: /Unable to use this key to sign/
<ide> });
<ide> }
| 1
|
Text
|
Text
|
fix new version for match_alignments
|
71c2a3ab4747e466e77a0a590c9fed4d3b791f29
|
<ide><path>website/docs/api/matcher.md
<ide> Find all token sequences matching the supplied patterns on the `Doc` or `Span`.
<ide> | _keyword-only_ | |
<ide> | `as_spans` <Tag variant="new">3</Tag> | Instead of tuples, return a list of [`Span`](/api/span) objects of the matches, with the `match_id` assigned as the span label. Defaults to `False`. ~~bool~~ |
<ide> | `allow_missing` <Tag variant="new">3</Tag> | Whether to skip checks for missing annotation for attributes included in patterns. Defaults to `False`. ~~bool~~ |
<del>| `with_alignments` <Tag variant="new">3.1</Tag> | Return match alignment information as part of the match tuple as `List[int]` with the same length as the matched span. Each entry denotes the corresponding index of the token pattern. If `as_spans` is set to `True`, this setting is ignored. Defaults to `False`. ~~bool~~ |
<add>| `with_alignments` <Tag variant="new">3.0.6</Tag> | Return match alignment information as part of the match tuple as `List[int]` with the same length as the matched span. Each entry denotes the corresponding index of the token pattern. If `as_spans` is set to `True`, this setting is ignored. Defaults to `False`. ~~bool~~ |
<ide> | **RETURNS** | A list of `(match_id, start, end)` tuples, describing the matches. A match tuple describes a span `doc[start:end`]. The `match_id` is the ID of the added match pattern. If `as_spans` is set to `True`, a list of `Span` objects is returned instead. ~~Union[List[Tuple[int, int, int]], List[Span]]~~ |
<ide>
<ide> ## Matcher.\_\_len\_\_ {#len tag="method" new="2"}
| 1
|
Javascript
|
Javascript
|
fix race condition in test-http-client-onerror
|
2413a4e99d548ac67c549fb699c6c2d209544e3a
|
<ide><path>test/gc/test-http-client-onerror.js
<ide> console.log('We should do ' + todo + ' requests');
<ide>
<ide> var http = require('http');
<ide> var server = http.createServer(serverHandler);
<del>server.listen(PORT, getall);
<add>server.listen(PORT, runTest);
<ide>
<ide> function getall() {
<ide> if (count >= todo)
<ide> function getall() {
<ide> setImmediate(getall);
<ide> }
<ide>
<del>for (var i = 0; i < 10; i++)
<del> getall();
<add>function runTest() {
<add> for (var i = 0; i < 10; i++)
<add> getall();
<add>}
<ide>
<ide> function afterGC() {
<ide> countGC ++;
| 1
|
Java
|
Java
|
move coremodulespackage to use turboreactpackage
|
aa3fc0910a2dbc7562d474982289f390225101e7
|
<ide><path>ReactAndroid/src/main/java/com/facebook/react/CoreModulesPackage.java
<ide> /**
<ide> * Copyright (c) Facebook, Inc. and its affiliates.
<ide> *
<del> * This source code is licensed under the MIT license found in the
<del> * LICENSE file in the root directory of this source tree.
<add> * <p>This source code is licensed under the MIT license found in the LICENSE file in the root
<add> * directory of this source tree.
<ide> */
<del>
<ide> package com.facebook.react;
<ide>
<ide> import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_UI_MANAGER_MODULE_END;
<ide> import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_UI_MANAGER_MODULE_START;
<ide> import static com.facebook.react.bridge.ReactMarkerConstants.PROCESS_CORE_REACT_PACKAGE_END;
<ide> import static com.facebook.react.bridge.ReactMarkerConstants.PROCESS_CORE_REACT_PACKAGE_START;
<ide>
<del>import com.facebook.react.bridge.ModuleSpec;
<ide> import com.facebook.react.bridge.NativeModule;
<ide> import com.facebook.react.bridge.ReactApplicationContext;
<ide> import com.facebook.react.bridge.ReactMarker;
<add>import com.facebook.react.module.annotations.ReactModule;
<ide> import com.facebook.react.module.annotations.ReactModuleList;
<add>import com.facebook.react.module.model.ReactModuleInfo;
<ide> import com.facebook.react.module.model.ReactModuleInfoProvider;
<del>import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
<ide> import com.facebook.react.modules.core.DeviceEventManagerModule;
<ide> import com.facebook.react.modules.core.ExceptionsManagerModule;
<del>import com.facebook.react.modules.core.HeadlessJsTaskSupportModule;
<ide> import com.facebook.react.modules.core.Timing;
<add>import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
<add>import com.facebook.react.modules.core.HeadlessJsTaskSupportModule;
<ide> import com.facebook.react.modules.debug.SourceCodeModule;
<ide> import com.facebook.react.modules.deviceinfo.DeviceInfoModule;
<ide> import com.facebook.react.modules.systeminfo.AndroidInfoModule;
<ide> import com.facebook.react.uimanager.UIImplementationProvider;
<ide> import com.facebook.react.uimanager.UIManagerModule;
<ide> import com.facebook.react.uimanager.ViewManager;
<ide> import com.facebook.systrace.Systrace;
<del>import java.util.Arrays;
<del>import java.util.List;
<add>
<add>import java.util.Collections;
<ide> import javax.annotation.Nullable;
<del>import javax.inject.Provider;
<add>import java.util.HashMap;
<add>import java.util.List;
<add>import java.util.Map;
<add>
<add>import static com.facebook.react.bridge.ReactMarkerConstants.*;
<ide>
<ide> /**
<ide> * This is the basic module to support React Native. The debug modules are now in DebugCorePackage.
<ide> */
<ide> @ReactModuleList(
<del> nativeModules = {
<del> AndroidInfoModule.class,
<del> DeviceEventManagerModule.class,
<del> DeviceInfoModule.class,
<del> ExceptionsManagerModule.class,
<del> HeadlessJsTaskSupportModule.class,
<del> SourceCodeModule.class,
<del> Timing.class,
<del> UIManagerModule.class,
<del> }
<del>)
<del>/* package */ class CoreModulesPackage extends LazyReactPackage implements ReactPackageLogger {
<add> // WARNING: If you modify this list, ensure that the list below in method
<add> // getReactModuleInfoByInitialization is also updated
<add> nativeModules = {
<add> AndroidInfoModule.class,
<add> DeviceEventManagerModule.class,
<add> DeviceInfoModule.class,
<add> ExceptionsManagerModule.class,
<add> HeadlessJsTaskSupportModule.class,
<add> SourceCodeModule.class,
<add> Timing.class,
<add> UIManagerModule.class,
<add> })
<add>/* package */ class CoreModulesPackage extends TurboReactPackage implements ReactPackageLogger {
<ide>
<ide> private final ReactInstanceManager mReactInstanceManager;
<ide> private final DefaultHardwareBackBtnHandler mHardwareBackBtnHandler;
<ide> mMinTimeLeftInFrameForNonBatchedOperationMs = minTimeLeftInFrameForNonBatchedOperationMs;
<ide> }
<ide>
<add> /**
<add> * This method is overridden, since OSS does not run the annotation processor to generate {@link
<add> * CoreModulesPackage$$ReactModuleInfoProvider} class. Here we check if it exists. If it does not
<add> * exist, we generate one manually in {@link
<add> * CoreModulesPackage#getReactModuleInfoByInitialization()} and return that instead.
<add> */
<ide> @Override
<del> public List<ModuleSpec> getNativeModules(final ReactApplicationContext reactContext) {
<del> return Arrays.asList(
<del> ModuleSpec.nativeModuleSpec(
<del> AndroidInfoModule.NAME,
<del> new Provider<NativeModule>() {
<del> @Override
<del> public NativeModule get() {
<del> return new AndroidInfoModule(reactContext);
<del> }
<del> }),
<del> ModuleSpec.nativeModuleSpec(
<del> DeviceEventManagerModule.NAME,
<del> new Provider<NativeModule>() {
<del> @Override
<del> public NativeModule get() {
<del> return new DeviceEventManagerModule(reactContext, mHardwareBackBtnHandler);
<del> }
<del> }),
<del> ModuleSpec.nativeModuleSpec(
<del> ExceptionsManagerModule.NAME,
<del> new Provider<NativeModule>() {
<del> @Override
<del> public NativeModule get() {
<del> return new ExceptionsManagerModule(mReactInstanceManager.getDevSupportManager());
<del> }
<del> }),
<del> ModuleSpec.nativeModuleSpec(
<del> HeadlessJsTaskSupportModule.NAME,
<del> new Provider<NativeModule>() {
<del> @Override
<del> public NativeModule get() {
<del> return new HeadlessJsTaskSupportModule(reactContext);
<del> }
<del> }),
<del> ModuleSpec.nativeModuleSpec(
<del> SourceCodeModule.NAME,
<del> new Provider<NativeModule>() {
<del> @Override
<del> public NativeModule get() {
<del> return new SourceCodeModule(reactContext);
<del> }
<del> }),
<del> ModuleSpec.nativeModuleSpec(
<del> Timing.NAME,
<del> new Provider<NativeModule>() {
<del> @Override
<del> public NativeModule get() {
<del> return new Timing(reactContext, mReactInstanceManager.getDevSupportManager());
<del> }
<del> }),
<del> ModuleSpec.nativeModuleSpec(
<del> UIManagerModule.NAME,
<del> new Provider<NativeModule>() {
<del> @Override
<del> public NativeModule get() {
<del> return createUIManager(reactContext);
<del> }
<del> }),
<del> ModuleSpec.nativeModuleSpec(
<del> DeviceInfoModule.NAME,
<del> new Provider<NativeModule>() {
<del> @Override
<del> public NativeModule get() {
<del> return new DeviceInfoModule(reactContext);
<del> }
<del> }));
<add> public ReactModuleInfoProvider getReactModuleInfoProvider() {
<add> try {
<add> Class<?> reactModuleInfoProviderClass =
<add> Class.forName("com.facebook.react.CoreModulesPackage$$ReactModuleInfoProvider");
<add> return (ReactModuleInfoProvider) reactModuleInfoProviderClass.newInstance();
<add> } catch (ClassNotFoundException e) {
<add> // In OSS case, the annotation processor does not run. We fall back on creating this byhand
<add> Class<? extends NativeModule>[] moduleList =
<add> new Class[] {
<add> AndroidInfoModule.class,
<add> DeviceEventManagerModule.class,
<add> DeviceInfoModule.class,
<add> ExceptionsManagerModule.class,
<add> HeadlessJsTaskSupportModule.class,
<add> SourceCodeModule.class,
<add> Timing.class,
<add> UIManagerModule.class
<add> };
<add>
<add> final Map<String, ReactModuleInfo> reactModuleInfoMap = new HashMap<>();
<add> for (Class<? extends NativeModule> moduleClass : moduleList) {
<add> ReactModule reactModule = moduleClass.getAnnotation(ReactModule.class);
<add>
<add> reactModuleInfoMap.put(
<add> reactModule.name(),
<add> new ReactModuleInfo(
<add> reactModule.name(),
<add> moduleClass.getName(),
<add> reactModule.canOverrideExistingModule(),
<add> reactModule.needsEagerInit(),
<add> reactModule.hasConstants(),
<add> reactModule.isCxxModule(),
<add> false));
<add> }
<add>
<add> return new ReactModuleInfoProvider() {
<add> @Override
<add> public Map<String, ReactModuleInfo> getReactModuleInfos() {
<add> return reactModuleInfoMap;
<add> }
<add> };
<add> } catch (InstantiationException e) {
<add> throw new RuntimeException(
<add> "No ReactModuleInfoProvider for CoreModulesPackage$$ReactModuleInfoProvider", e);
<add> } catch (IllegalAccessException e) {
<add> throw new RuntimeException(
<add> "No ReactModuleInfoProvider for CoreModulesPackage$$ReactModuleInfoProvider", e);
<add> }
<ide> }
<ide>
<ide> @Override
<del> public ReactModuleInfoProvider getReactModuleInfoProvider() {
<del> // This has to be done via reflection or we break open source.
<del> return LazyReactPackage.getReactModuleInfoProviderViaReflection(this);
<add> public NativeModule getModule(String name, ReactApplicationContext reactContext) {
<add> switch (name) {
<add> case AndroidInfoModule.NAME:
<add> return new AndroidInfoModule(reactContext);
<add> case DeviceEventManagerModule.NAME:
<add> return new DeviceEventManagerModule(reactContext, mHardwareBackBtnHandler);
<add> case ExceptionsManagerModule.NAME:
<add> return new ExceptionsManagerModule(mReactInstanceManager.getDevSupportManager());
<add> case HeadlessJsTaskSupportModule.NAME:
<add> return new HeadlessJsTaskSupportModule(reactContext);
<add> case SourceCodeModule.NAME:
<add> return new SourceCodeModule(reactContext);
<add> case Timing.NAME:
<add> return new Timing(reactContext, mReactInstanceManager.getDevSupportManager());
<add> case UIManagerModule.NAME:
<add> return createUIManager(reactContext);
<add> case DeviceInfoModule.NAME:
<add> return new DeviceInfoModule(reactContext);
<add> default:
<add> throw new IllegalArgumentException(
<add> "In CoreModulesPackage, could not find Native module for " + name);
<add> }
<ide> }
<ide>
<ide> private UIManagerModule createUIManager(final ReactApplicationContext reactContext) {
<ide> ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_START);
<ide> Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "createUIManagerModule");
<ide> try {
<ide> if (mLazyViewManagersEnabled) {
<del> UIManagerModule.ViewManagerResolver resolver = new UIManagerModule.ViewManagerResolver() {
<del> @Override
<del> public @Nullable ViewManager getViewManager(String viewManagerName) {
<del> return mReactInstanceManager.createViewManager(viewManagerName);
<del> }
<del> @Override
<del> public List<String> getViewManagerNames() {
<del> return mReactInstanceManager.getViewManagerNames();
<del> }
<del> };
<add> UIManagerModule.ViewManagerResolver resolver =
<add> new UIManagerModule.ViewManagerResolver() {
<add> @Override
<add> public @Nullable ViewManager getViewManager(String viewManagerName) {
<add> return mReactInstanceManager.createViewManager(viewManagerName);
<add> }
<add>
<add> @Override
<add> public List<String> getViewManagerNames() {
<add> return mReactInstanceManager.getViewManagerNames();
<add> }
<add> };
<ide>
<ide> return new UIManagerModule(
<del> reactContext,
<del> resolver,
<del> mMinTimeLeftInFrameForNonBatchedOperationMs);
<add> reactContext, resolver, mMinTimeLeftInFrameForNonBatchedOperationMs);
<ide> } else {
<ide> return new UIManagerModule(
<ide> reactContext,
| 1
|
Mixed
|
Javascript
|
add hasintl to failing test
|
a8979a605434b0a07395c9764caafef362f3875e
|
<ide><path>test/common/README.md
<ide> Checks `hasCrypto` and `crypto` with fips.
<ide>
<ide> Checks if [internationalization] is supported.
<ide>
<add>### hasSmallICU
<add>* return [<Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
<add>
<add>Checks `hasIntl` and `small-icu` is supported.
<add>
<ide> ### hasIPv6
<ide> * return [<Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
<ide>
<ide><path>test/common/index.js
<ide> Object.defineProperty(exports, 'hasIntl', {
<ide> }
<ide> });
<ide>
<add>Object.defineProperty(exports, 'hasSmallICU', {
<add> get: function() {
<add> return process.binding('config').hasSmallICU;
<add> }
<add>});
<add>
<ide> // Useful for testing expected internal/error objects
<ide> exports.expectsError = function expectsError({code, type, message}) {
<ide> return function(error) {
<ide><path>test/parallel/test-icu-data-dir.js
<ide> 'use strict';
<del>require('../common');
<add>const common = require('../common');
<add>if (!(common.hasIntl && common.hasSmallICU)) {
<add> common.skip('missing Intl');
<add> return;
<add>}
<ide> const assert = require('assert');
<ide> const { spawnSync } = require('child_process');
<ide>
<ide><path>test/parallel/test-url-domain-ascii-unicode.js
<ide> 'use strict';
<ide>
<del>require('../common');
<add>const common = require('../common');
<add>if (!common.hasIntl) {
<add> common.skip('missing Intl');
<add> return;
<add>}
<ide> const strictEqual = require('assert').strictEqual;
<ide> const url = require('url');
<ide>
<ide><path>test/parallel/test-url-format-whatwg.js
<ide> 'use strict';
<ide>
<ide> const common = require('../common');
<add>if (!common.hasIntl) {
<add> common.skip('missing Intl');
<add> return;
<add>}
<ide> const assert = require('assert');
<ide> const url = require('url');
<ide> const URL = url.URL;
| 5
|
Ruby
|
Ruby
|
require missing association in test
|
f987609ad6afa4ddd3208621b28de9c2d6ee898e
|
<ide><path>activerecord/test/cases/associations/has_one_through_associations_test.rb
<ide> require 'models/owner'
<ide> require 'models/post'
<ide> require 'models/comment'
<add>require 'models/categorization'
<ide>
<ide> class HasOneThroughAssociationsTest < ActiveRecord::TestCase
<ide> fixtures :member_types, :members, :clubs, :memberships, :sponsors, :organizations, :minivans,
| 1
|
Javascript
|
Javascript
|
split cross-package types from implementation
|
376d5c1b5aa17724c5fea9412f8fcde14a7b23f1
|
<ide><path>packages/legacy-events/PluginModuleType.js
<ide> * @flow
<ide> */
<ide>
<del>import type {Fiber} from 'react-reconciler/src/ReactFiber.old';
<add>import type {Fiber} from 'react-reconciler/src/ReactInternalTypes';
<ide> import type {
<ide> DispatchConfig,
<ide> ReactSyntheticEvent,
<ide><path>packages/legacy-events/ReactSyntheticEventType.js
<ide> * @flow
<ide> */
<ide>
<del>import type {Fiber} from 'react-reconciler/src/ReactFiber.old';
<add>import type {Fiber} from 'react-reconciler/src/ReactInternalTypes';
<ide> import type {EventPriority} from 'shared/ReactTypes';
<ide> import type {TopLevelType} from './TopLevelEventTypes';
<ide>
<ide><path>packages/react-debug-tools/src/ReactDebugHooks.js
<ide> import type {
<ide> ReactEventResponderListener,
<ide> ReactScopeMethods,
<ide> } from 'shared/ReactTypes';
<del>import type {Fiber} from 'react-reconciler/src/ReactFiber.old';
<del>import type {OpaqueIDType} from 'react-reconciler/src/ReactFiberHostConfig';
<del>
<ide> import type {
<del> Hook,
<del> TimeoutConfig,
<add> Fiber,
<ide> Dispatcher as DispatcherType,
<del>} from 'react-reconciler/src/ReactFiberHooks.old';
<del>import type {SuspenseConfig} from 'react-reconciler/src/ReactFiberSuspenseConfig.old';
<add>} from 'react-reconciler/src/ReactInternalTypes';
<add>import type {OpaqueIDType} from 'react-reconciler/src/ReactFiberHostConfig';
<add>
<add>import type {SuspenseConfig} from 'react-reconciler/src/ReactFiberSuspenseConfig';
<ide> import {NoMode} from 'react-reconciler/src/ReactTypeOfMode';
<ide>
<ide> import ErrorStackParser from 'error-stack-parser';
<ide> let primitiveStackCache: null | Map<string, Array<any>> = null;
<ide>
<ide> let currentFiber: Fiber | null = null;
<ide>
<add>type Hook = {
<add> memoizedState: any,
<add> next: Hook | null,
<add>};
<add>
<add>type TimeoutConfig = {|
<add> timeoutMs: number,
<add>|};
<add>
<ide> function getPrimitiveStackCache(): Map<string, Array<any>> {
<ide> // This initializes a cache of all primitive hooks so that the top
<ide> // most stack frames added by calling the primitive hook can be removed.
<ide><path>packages/react-devtools-shared/src/backend/console.js
<ide> import {getInternalReactConstants} from './renderer';
<ide> import describeComponentFrame from './describeComponentFrame';
<ide>
<del>import type {Fiber} from 'react-reconciler/src/ReactFiber.old';
<add>import type {Fiber} from 'react-reconciler/src/ReactInternalTypes';
<ide> import type {ReactRenderer} from './types';
<ide>
<ide> const APPEND_STACK_TO_METHODS = ['error', 'trace', 'warn'];
<ide><path>packages/react-devtools-shared/src/backend/renderer.js
<ide> import {
<ide> registerRenderer as registerRendererWithConsole,
<ide> } from './console';
<ide>
<del>import type {Fiber} from 'react-reconciler/src/ReactFiber.old';
<add>import type {Fiber} from 'react-reconciler/src/ReactInternalTypes';
<ide> import type {
<ide> ChangeDescription,
<ide> CommitDataBackend,
<ide><path>packages/react-devtools-shared/src/backend/types.js
<ide>
<ide> import type {ReactContext} from 'shared/ReactTypes';
<ide> import type {Source} from 'shared/ReactElementType';
<del>import type {Fiber} from 'react-reconciler/src/ReactFiber.old';
<add>import type {Fiber} from 'react-reconciler/src/ReactInternalTypes';
<ide> import type {
<ide> ComponentFilter,
<ide> ElementType,
<ide><path>packages/react-dom/src/client/ReactDOMComponentTree.js
<ide> * @flow
<ide> */
<ide>
<del>import type {Fiber} from 'react-reconciler/src/ReactFiber.old';
<add>import type {Fiber} from 'react-reconciler/src/ReactInternalTypes';
<ide> import type {
<ide> Container,
<ide> TextInstance,
<ide><path>packages/react-dom/src/client/ReactDOMRoot.js
<ide> import type {Container} from './ReactDOMHostConfig';
<ide> import type {RootTag} from 'react-reconciler/src/ReactRootTags';
<ide> import type {ReactNodeList} from 'shared/ReactTypes';
<del>// TODO: This type is shared between the reconciler and ReactDOM, but will
<del>// eventually be lifted out to the renderer.
<del>import type {FiberRoot} from 'react-reconciler/src/ReactFiberRoot.old';
<add>import type {FiberRoot} from 'react-reconciler/src/ReactInternalTypes';
<ide> import {findHostInstanceWithNoPortals} from 'react-reconciler/src/ReactFiberReconciler';
<ide>
<ide> export type RootType = {
<ide><path>packages/react-dom/src/events/DOMLegacyEventPluginSystem.js
<ide> import type {AnyNativeEvent} from 'legacy-events/PluginModuleType';
<ide> import type {DOMTopLevelEventType} from 'legacy-events/TopLevelEventTypes';
<ide> import type {ElementListenerMap} from '../events/DOMEventListenerMap';
<ide> import type {EventSystemFlags} from './EventSystemFlags';
<del>import type {Fiber} from 'react-reconciler/src/ReactFiber.old';
<add>import type {Fiber} from 'react-reconciler/src/ReactInternalTypes';
<ide> import type {PluginModule} from 'legacy-events/PluginModuleType';
<ide> import type {ReactSyntheticEvent} from 'legacy-events/ReactSyntheticEventType';
<ide> import type {TopLevelType} from 'legacy-events/TopLevelEventTypes';
<ide><path>packages/react-dom/src/events/DOMModernPluginEventSystem.js
<ide> import type {
<ide> } from '../events/DOMEventListenerMap';
<ide> import type {EventSystemFlags} from './EventSystemFlags';
<ide> import type {EventPriority, ReactScopeMethods} from 'shared/ReactTypes';
<del>import type {Fiber} from 'react-reconciler/src/ReactFiber.old';
<add>import type {Fiber} from 'react-reconciler/src/ReactInternalTypes';
<ide> import type {PluginModule} from 'legacy-events/PluginModuleType';
<ide> import type {
<ide> ReactSyntheticEvent,
<ide><path>packages/react-dom/src/events/DeprecatedDOMEventResponderSystem.js
<ide> import {
<ide> flushDiscreteUpdatesIfNeeded,
<ide> executeUserEventHandler,
<ide> } from './ReactDOMUpdateBatching';
<del>import type {Fiber} from 'react-reconciler/src/ReactFiber.old';
<add>import type {Fiber} from 'react-reconciler/src/ReactInternalTypes';
<ide> import {enableDeprecatedFlareAPI} from 'shared/ReactFeatureFlags';
<ide> import invariant from 'shared/invariant';
<ide>
<ide><path>packages/react-dom/src/events/ReactDOMEventListener.js
<ide>
<ide> import type {AnyNativeEvent} from 'legacy-events/PluginModuleType';
<ide> import type {EventPriority} from 'shared/ReactTypes';
<del>import type {FiberRoot} from 'react-reconciler/src/ReactFiberRoot.old';
<add>import type {FiberRoot} from 'react-reconciler/src/ReactInternalTypes';
<ide> import type {Container, SuspenseInstance} from '../client/ReactDOMHostConfig';
<ide> import type {DOMTopLevelEventType} from 'legacy-events/TopLevelEventTypes';
<ide>
<ide><path>packages/react-dom/src/events/ReactDOMEventReplaying.js
<ide> import type {Container, SuspenseInstance} from '../client/ReactDOMHostConfig';
<ide> import type {DOMTopLevelEventType} from 'legacy-events/TopLevelEventTypes';
<ide> import type {ElementListenerMap} from '../events/DOMEventListenerMap';
<ide> import type {EventSystemFlags} from './EventSystemFlags';
<del>import type {FiberRoot} from 'react-reconciler/src/ReactFiberRoot.old';
<add>import type {FiberRoot} from 'react-reconciler/src/ReactInternalTypes';
<ide>
<ide> import {
<ide> enableDeprecatedFlareAPI,
<ide><path>packages/react-dom/src/events/SimpleEventPlugin.js
<ide> import type {
<ide> DOMTopLevelEventType,
<ide> } from 'legacy-events/TopLevelEventTypes';
<ide> import type {ReactSyntheticEvent} from 'legacy-events/ReactSyntheticEventType';
<del>import type {Fiber} from 'react-reconciler/src/ReactFiber.old';
<add>import type {Fiber} from 'react-reconciler/src/ReactInternalTypes';
<ide> import type {PluginModule} from 'legacy-events/PluginModuleType';
<ide> import type {EventSystemFlags} from './EventSystemFlags';
<ide>
<ide><path>packages/react-dom/src/events/accumulateEnterLeaveListeners.js
<ide> * @flow
<ide> */
<ide>
<del>import type {Fiber} from 'react-reconciler/src/ReactFiber.old';
<add>import type {Fiber} from 'react-reconciler/src/ReactInternalTypes';
<ide> import type {ReactSyntheticEvent} from 'legacy-events/ReactSyntheticEventType';
<ide>
<ide> import {HostComponent} from 'react-reconciler/src/ReactWorkTags';
<ide><path>packages/react-dom/src/events/accumulateEventTargetListeners.js
<ide> * @flow
<ide> */
<ide>
<del>import type {Fiber} from 'react-reconciler/src/ReactFiber.old';
<add>import type {Fiber} from 'react-reconciler/src/ReactInternalTypes';
<ide> import type {DOMTopLevelEventType} from 'legacy-events/TopLevelEventTypes';
<ide> import type {ReactSyntheticEvent} from 'legacy-events/ReactSyntheticEventType';
<ide>
<ide><path>packages/react-dom/src/events/accumulateTwoPhaseListeners.js
<ide> * @flow
<ide> */
<ide>
<del>import type {Fiber} from 'react-reconciler/src/ReactFiber.old';
<add>import type {Fiber} from 'react-reconciler/src/ReactInternalTypes';
<ide> import type {DOMTopLevelEventType} from 'legacy-events/TopLevelEventTypes';
<ide> import type {ReactSyntheticEvent} from 'legacy-events/ReactSyntheticEventType';
<ide>
<ide><path>packages/react-dom/src/events/getListener.js
<ide> * @flow
<ide> */
<ide>
<del>import type {Fiber} from 'react-reconciler/src/ReactFiber.old';
<add>import type {Fiber} from 'react-reconciler/src/ReactInternalTypes';
<ide> import type {Props} from '../client/ReactDOMHostConfig';
<ide>
<ide> import invariant from 'shared/invariant';
<ide><path>packages/react-dom/src/server/ReactPartialRendererHooks.js
<ide> * @flow
<ide> */
<ide>
<del>import type {
<del> Dispatcher as DispatcherType,
<del> TimeoutConfig,
<del>} from 'react-reconciler/src/ReactFiberHooks.old';
<add>import type {Dispatcher as DispatcherType} from 'react-reconciler/src/ReactInternalTypes';
<ide> import type {ThreadID} from './ReactThreadIDAllocator';
<ide> import type {OpaqueIDType} from 'react-reconciler/src/ReactFiberHostConfig';
<ide>
<ide> import type {
<ide> ReactContext,
<ide> ReactEventResponderListener,
<ide> } from 'shared/ReactTypes';
<del>import type {SuspenseConfig} from 'react-reconciler/src/ReactFiberSuspenseConfig.old';
<add>import type {SuspenseConfig} from 'react-reconciler/src/ReactFiberSuspenseConfig';
<ide> import type {ReactDOMListenerMap} from '../shared/ReactDOMTypes';
<ide>
<ide> import {validateContextBounds} from './ReactPartialRendererContext';
<ide> type Hook = {|
<ide> next: Hook | null,
<ide> |};
<ide>
<add>type TimeoutConfig = {|
<add> timeoutMs: number,
<add>|};
<add>
<ide> let currentlyRenderingComponent: Object | null = null;
<ide> let firstWorkInProgressHook: Hook | null = null;
<ide> let workInProgressHook: Hook | null = null;
<ide><path>packages/react-native-renderer/src/ReactFabricEventEmitter.js
<ide> */
<ide>
<ide> import type {AnyNativeEvent} from 'legacy-events/PluginModuleType';
<del>import type {Fiber} from 'react-reconciler/src/ReactFiber.old';
<add>import type {Fiber} from 'react-reconciler/src/ReactInternalTypes';
<ide> import type {PluginModule} from 'legacy-events/PluginModuleType';
<ide> import type {ReactSyntheticEvent} from 'legacy-events/ReactSyntheticEventType';
<ide> import type {TopLevelType} from 'legacy-events/TopLevelEventTypes';
<ide><path>packages/react-native-renderer/src/ReactNativeEventEmitter.js
<ide> */
<ide>
<ide> import type {AnyNativeEvent} from 'legacy-events/PluginModuleType';
<del>import type {Fiber} from 'react-reconciler/src/ReactFiber.old';
<add>import type {Fiber} from 'react-reconciler/src/ReactInternalTypes';
<ide> import type {PluginModule} from 'legacy-events/PluginModuleType';
<ide> import type {ReactSyntheticEvent} from 'legacy-events/ReactSyntheticEventType';
<ide> import type {TopLevelType} from 'legacy-events/TopLevelEventTypes';
<ide><path>packages/react-native-renderer/src/ReactNativeFiberInspector.js
<ide> * @flow
<ide> */
<ide>
<del>import type {Fiber} from 'react-reconciler/src/ReactFiber.old';
<add>import type {Fiber} from 'react-reconciler/src/ReactInternalTypes';
<ide> import type {TouchedViewDataAtPoint, InspectorData} from './ReactNativeTypes';
<ide>
<ide> import {
<ide><path>packages/react-native-renderer/src/ReactNativeGetListener.js
<ide> * @flow
<ide> */
<ide>
<del>import type {Fiber} from 'react-reconciler/src/ReactFiber.old';
<add>import type {Fiber} from 'react-reconciler/src/ReactInternalTypes';
<ide>
<ide> import invariant from 'shared/invariant';
<ide> import {getFiberCurrentPropsFromNode} from 'legacy-events/EventPluginUtils';
<ide><path>packages/react-noop-renderer/src/createReactNoop.js
<ide> * environment.
<ide> */
<ide>
<del>import type {Fiber} from 'react-reconciler/src/ReactFiber.old';
<add>import type {Fiber} from 'react-reconciler/src/ReactInternalTypes';
<ide> import type {UpdateQueue} from 'react-reconciler/src/ReactUpdateQueue';
<ide> import type {ReactNodeList} from 'shared/ReactTypes';
<ide> import type {RootTag} from 'react-reconciler/src/ReactRootTags';
<ide><path>packages/react-reconciler/src/ReactCapturedValue.js
<ide> * @flow
<ide> */
<ide>
<del>import type {Fiber} from './ReactFiber.old';
<add>import type {Fiber} from './ReactInternalTypes';
<ide>
<ide> import {getStackByFiberInDevAndProd} from './ReactFiberComponentStack';
<ide>
<ide><path>packages/react-reconciler/src/ReactChildFiber.old.js
<ide> import type {ReactElement} from 'shared/ReactElementType';
<ide> import type {ReactPortal} from 'shared/ReactTypes';
<ide> import type {BlockComponent} from 'react/src/ReactBlock';
<ide> import type {LazyComponent} from 'react/src/ReactLazy';
<del>import type {Fiber} from './ReactFiber.old';
<del>import type {ExpirationTime} from './ReactFiberExpirationTime.old';
<add>import type {Fiber} from './ReactInternalTypes';
<add>import type {ExpirationTime} from './ReactFiberExpirationTime';
<ide>
<ide> import getComponentName from 'shared/getComponentName';
<ide> import {Placement, Deletion} from './ReactSideEffectTags';
<ide><path>packages/react-reconciler/src/ReactCurrentFiber.js
<ide> * @flow
<ide> */
<ide>
<del>import type {Fiber} from './ReactFiber.old';
<add>import type {Fiber} from './ReactInternalTypes';
<ide>
<ide> import ReactSharedInternals from 'shared/ReactSharedInternals';
<ide> import {getStackByFiberInDevAndProd} from './ReactFiberComponentStack';
<ide><path>packages/react-reconciler/src/ReactFiber.old.js
<ide> * @flow
<ide> */
<ide>
<del>import type {ReactElement, Source} from 'shared/ReactElementType';
<add>import type {ReactElement} from 'shared/ReactElementType';
<ide> import type {
<ide> ReactFragment,
<ide> ReactPortal,
<del> RefObject,
<del> ReactEventResponder,
<del> ReactEventResponderInstance,
<ide> ReactFundamentalComponent,
<ide> ReactScope,
<ide> } from 'shared/ReactTypes';
<add>import type {Fiber} from './ReactInternalTypes';
<ide> import type {RootTag} from './ReactRootTags';
<ide> import type {WorkTag} from './ReactWorkTags';
<ide> import type {TypeOfMode} from './ReactTypeOfMode';
<del>import type {SideEffectTag} from './ReactSideEffectTags';
<del>import type {ExpirationTime} from './ReactFiberExpirationTime.old';
<del>import type {UpdateQueue} from './ReactUpdateQueue.old';
<del>import type {ContextDependency} from './ReactFiberNewContext.old';
<del>import type {HookType} from './ReactFiberHooks.old';
<add>import type {ExpirationTime} from './ReactFiberExpirationTime';
<ide> import type {SuspenseInstance} from './ReactFiberHostConfig';
<ide>
<ide> import invariant from 'shared/invariant';
<ide> import {
<ide> resolveFunctionForHotReloading,
<ide> resolveForwardRefForHotReloading,
<ide> } from './ReactFiberHotReloading.old';
<del>import {NoWork} from './ReactFiberExpirationTime.old';
<add>import {NoWork} from './ReactFiberExpirationTime';
<ide> import {
<ide> NoMode,
<ide> ConcurrentMode,
<ide> import {
<ide> REACT_BLOCK_TYPE,
<ide> } from 'shared/ReactSymbols';
<ide>
<add>export type {Fiber};
<add>
<ide> let hasBadMapPolyfill;
<ide>
<ide> if (__DEV__) {
<ide> if (__DEV__) {
<ide> }
<ide> }
<ide>
<del>export type Dependencies = {
<del> expirationTime: ExpirationTime,
<del> firstContext: ContextDependency<mixed> | null,
<del> responders: Map<
<del> ReactEventResponder<any, any>,
<del> ReactEventResponderInstance<any, any>,
<del> > | null,
<del> ...
<del>};
<del>
<del>// A Fiber is work on a Component that needs to be done or was done. There can
<del>// be more than one per component.
<del>export type Fiber = {|
<del> // These first fields are conceptually members of an Instance. This used to
<del> // be split into a separate type and intersected with the other Fiber fields,
<del> // but until Flow fixes its intersection bugs, we've merged them into a
<del> // single type.
<del>
<del> // An Instance is shared between all versions of a component. We can easily
<del> // break this out into a separate object to avoid copying so much to the
<del> // alternate versions of the tree. We put this on a single object for now to
<del> // minimize the number of objects created during the initial render.
<del>
<del> // Tag identifying the type of fiber.
<del> tag: WorkTag,
<del>
<del> // Unique identifier of this child.
<del> key: null | string,
<del>
<del> // The value of element.type which is used to preserve the identity during
<del> // reconciliation of this child.
<del> elementType: any,
<del>
<del> // The resolved function/class/ associated with this fiber.
<del> type: any,
<del>
<del> // The local state associated with this fiber.
<del> stateNode: any,
<del>
<del> // Conceptual aliases
<del> // parent : Instance -> return The parent happens to be the same as the
<del> // return fiber since we've merged the fiber and instance.
<del>
<del> // Remaining fields belong to Fiber
<del>
<del> // The Fiber to return to after finishing processing this one.
<del> // This is effectively the parent, but there can be multiple parents (two)
<del> // so this is only the parent of the thing we're currently processing.
<del> // It is conceptually the same as the return address of a stack frame.
<del> return: Fiber | null,
<del>
<del> // Singly Linked List Tree Structure.
<del> child: Fiber | null,
<del> sibling: Fiber | null,
<del> index: number,
<del>
<del> // The ref last used to attach this node.
<del> // I'll avoid adding an owner field for prod and model that as functions.
<del> ref:
<del> | null
<del> | (((handle: mixed) => void) & {_stringRef: ?string, ...})
<del> | RefObject,
<del>
<del> // Input is the data coming into process this fiber. Arguments. Props.
<del> pendingProps: any, // This type will be more specific once we overload the tag.
<del> memoizedProps: any, // The props used to create the output.
<del>
<del> // A queue of state updates and callbacks.
<del> updateQueue: UpdateQueue<any> | null,
<del>
<del> // The state used to create the output
<del> memoizedState: any,
<del>
<del> // Dependencies (contexts, events) for this fiber, if it has any
<del> dependencies: Dependencies | null,
<del>
<del> // Bitfield that describes properties about the fiber and its subtree. E.g.
<del> // the ConcurrentMode flag indicates whether the subtree should be async-by-
<del> // default. When a fiber is created, it inherits the mode of its
<del> // parent. Additional flags can be set at creation time, but after that the
<del> // value should remain unchanged throughout the fiber's lifetime, particularly
<del> // before its child fibers are created.
<del> mode: TypeOfMode,
<del>
<del> // Effect
<del> effectTag: SideEffectTag,
<del>
<del> // Singly linked list fast path to the next fiber with side-effects.
<del> nextEffect: Fiber | null,
<del>
<del> // The first and last fiber with side-effect within this subtree. This allows
<del> // us to reuse a slice of the linked list when we reuse the work done within
<del> // this fiber.
<del> firstEffect: Fiber | null,
<del> lastEffect: Fiber | null,
<del>
<del> // Represents a time in the future by which this work should be completed.
<del> // Does not include work found in its subtree.
<del> expirationTime: ExpirationTime,
<del>
<del> // This is used to quickly determine if a subtree has no pending changes.
<del> childExpirationTime: ExpirationTime,
<del>
<del> // This is a pooled version of a Fiber. Every fiber that gets updated will
<del> // eventually have a pair. There are cases when we can clean up pairs to save
<del> // memory if we need to.
<del> alternate: Fiber | null,
<del>
<del> // Time spent rendering this Fiber and its descendants for the current update.
<del> // This tells us how well the tree makes use of sCU for memoization.
<del> // It is reset to 0 each time we render and only updated when we don't bailout.
<del> // This field is only set when the enableProfilerTimer flag is enabled.
<del> actualDuration?: number,
<del>
<del> // If the Fiber is currently active in the "render" phase,
<del> // This marks the time at which the work began.
<del> // This field is only set when the enableProfilerTimer flag is enabled.
<del> actualStartTime?: number,
<del>
<del> // Duration of the most recent render time for this Fiber.
<del> // This value is not updated when we bailout for memoization purposes.
<del> // This field is only set when the enableProfilerTimer flag is enabled.
<del> selfBaseDuration?: number,
<del>
<del> // Sum of base times for all descendants of this Fiber.
<del> // This value bubbles up during the "complete" phase.
<del> // This field is only set when the enableProfilerTimer flag is enabled.
<del> treeBaseDuration?: number,
<del>
<del> // Conceptual aliases
<del> // workInProgress : Fiber -> alternate The alternate used for reuse happens
<del> // to be the same as work in progress.
<del> // __DEV__ only
<del> _debugID?: number,
<del> _debugSource?: Source | null,
<del> _debugOwner?: Fiber | null,
<del> _debugIsCurrentlyTiming?: boolean,
<del> _debugNeedsRemount?: boolean,
<del>
<del> // Used to verify that the order of hooks does not change between renders.
<del> _debugHookTypes?: Array<HookType> | null,
<del>|};
<del>
<ide> let debugCounter = 1;
<ide>
<ide> function FiberNode(
<ide><path>packages/react-reconciler/src/ReactFiberBeginWork.old.js
<ide> import type {ReactProviderType, ReactContext} from 'shared/ReactTypes';
<ide> import type {BlockComponent} from 'react/src/ReactBlock';
<ide> import type {LazyComponent as LazyComponentType} from 'react/src/ReactLazy';
<del>import type {Fiber} from './ReactFiber.old';
<del>import type {FiberRoot} from './ReactFiberRoot.old';
<del>import type {ExpirationTime} from './ReactFiberExpirationTime.old';
<add>import type {Fiber} from './ReactInternalTypes';
<add>import type {FiberRoot} from './ReactInternalTypes';
<add>import type {ExpirationTime} from './ReactFiberExpirationTime';
<ide> import type {
<ide> SuspenseState,
<ide> SuspenseListRenderState,
<ide> import {
<ide> Never,
<ide> Sync,
<ide> computeAsyncExpiration,
<del>} from './ReactFiberExpirationTime.old';
<add>} from './ReactFiberExpirationTime';
<ide> import {
<ide> ConcurrentMode,
<ide> NoMode,
<ide><path>packages/react-reconciler/src/ReactFiberClassComponent.old.js
<ide> * @flow
<ide> */
<ide>
<del>import type {Fiber} from './ReactFiber.old';
<del>import type {ExpirationTime} from './ReactFiberExpirationTime.old';
<add>import type {Fiber} from './ReactInternalTypes';
<add>import type {ExpirationTime} from './ReactFiberExpirationTime';
<ide> import type {UpdateQueue} from './ReactUpdateQueue.old';
<ide>
<ide> import * as React from 'react';
<ide> import {
<ide> initializeUpdateQueue,
<ide> cloneUpdateQueue,
<ide> } from './ReactUpdateQueue.old';
<del>import {NoWork} from './ReactFiberExpirationTime.old';
<add>import {NoWork} from './ReactFiberExpirationTime';
<ide> import {
<ide> cacheContext,
<ide> getMaskedContext,
<ide> import {
<ide> computeExpirationForFiber,
<ide> scheduleUpdateOnFiber,
<ide> } from './ReactFiberWorkLoop.old';
<del>import {requestCurrentSuspenseConfig} from './ReactFiberSuspenseConfig.old';
<add>import {requestCurrentSuspenseConfig} from './ReactFiberSuspenseConfig';
<ide>
<ide> import {disableLogs, reenableLogs} from 'shared/ConsolePatchingDev';
<ide>
<ide><path>packages/react-reconciler/src/ReactFiberCommitWork.old.js
<ide> import type {
<ide> ChildSet,
<ide> UpdatePayload,
<ide> } from './ReactFiberHostConfig';
<del>import type {Fiber} from './ReactFiber.old';
<del>import type {FiberRoot} from './ReactFiberRoot.old';
<del>import type {ExpirationTime} from './ReactFiberExpirationTime.old';
<add>import type {Fiber} from './ReactInternalTypes';
<add>import type {FiberRoot} from './ReactInternalTypes';
<add>import type {ExpirationTime} from './ReactFiberExpirationTime';
<ide> import type {SuspenseState} from './ReactFiberSuspenseComponent.old';
<add>import type {UpdateQueue} from './ReactUpdateQueue.old';
<ide> import type {FunctionComponentUpdateQueue} from './ReactFiberHooks.old';
<ide> import type {Wakeable} from 'shared/ReactTypes';
<del>import type {ReactPriorityLevel} from './SchedulerWithReactIntegration.old';
<add>import type {ReactPriorityLevel} from './ReactInternalTypes';
<ide>
<ide> import {unstable_wrap as Schedule_tracing_wrap} from 'scheduler/tracing';
<ide> import {
<ide> function commitLifeCycles(
<ide> }
<ide> }
<ide> }
<del> const updateQueue = finishedWork.updateQueue;
<add>
<add> // TODO: I think this is now always non-null by the time it reaches the
<add> // commit phase. Consider removing the type check.
<add> const updateQueue: UpdateQueue<
<add> *,
<add> > | null = (finishedWork.updateQueue: any);
<ide> if (updateQueue !== null) {
<ide> if (__DEV__) {
<ide> if (
<ide> function commitLifeCycles(
<ide> return;
<ide> }
<ide> case HostRoot: {
<del> const updateQueue = finishedWork.updateQueue;
<add> // TODO: I think this is now always non-null by the time it reaches the
<add> // commit phase. Consider removing the type check.
<add> const updateQueue: UpdateQueue<
<add> *,
<add> > | null = (finishedWork.updateQueue: any);
<ide> if (updateQueue !== null) {
<ide> let instance = null;
<ide> if (finishedWork.child !== null) {
<ide><path>packages/react-reconciler/src/ReactFiberCompleteWork.old.js
<ide> * @flow
<ide> */
<ide>
<del>import type {Fiber} from './ReactFiber.old';
<del>import type {ExpirationTime} from './ReactFiberExpirationTime.old';
<add>import type {Fiber} from './ReactInternalTypes';
<add>import type {ExpirationTime} from './ReactFiberExpirationTime';
<ide> import type {
<ide> ReactFundamentalComponentInstance,
<ide> ReactScopeInstance,
<ide> } from 'shared/ReactTypes';
<del>import type {FiberRoot} from './ReactFiberRoot.old';
<add>import type {FiberRoot} from './ReactInternalTypes';
<ide> import type {
<ide> Instance,
<ide> Type,
<ide> import {
<ide> renderHasNotSuspendedYet,
<ide> } from './ReactFiberWorkLoop.old';
<ide> import {createFundamentalStateInstance} from './ReactFiberFundamental.old';
<del>import {Never} from './ReactFiberExpirationTime.old';
<add>import {Never} from './ReactFiberExpirationTime';
<ide> import {resetChildFibers} from './ReactChildFiber.old';
<ide> import {updateDeprecatedEventListeners} from './ReactFiberDeprecatedEvents.old';
<ide> import {createScopeMethods} from './ReactFiberScope.old';
<ide><path>packages/react-reconciler/src/ReactFiberComponentStack.js
<ide> * @flow
<ide> */
<ide>
<del>import type {Fiber} from './ReactFiber.old';
<add>import type {Fiber} from './ReactInternalTypes';
<ide>
<ide> import {
<ide> HostComponent,
<ide><path>packages/react-reconciler/src/ReactFiberContext.old.js
<ide> * @flow
<ide> */
<ide>
<del>import type {Fiber} from './ReactFiber.old';
<add>import type {Fiber} from './ReactInternalTypes';
<ide> import type {StackCursor} from './ReactFiberStack.old';
<ide>
<ide> import {isFiberMounted} from './ReactFiberTreeReflection';
<ide><path>packages/react-reconciler/src/ReactFiberDeprecatedEvents.old.js
<ide> * @flow
<ide> */
<ide>
<del>import type {Fiber} from './ReactFiber.old';
<add>import type {Fiber} from './ReactInternalTypes';
<ide> import type {Container, Instance} from './ReactFiberHostConfig';
<ide> import type {
<ide> ReactEventResponder,
<ide> import {
<ide> DEPRECATED_mountResponderInstance,
<ide> DEPRECATED_unmountResponderInstance,
<ide> } from './ReactFiberHostConfig';
<del>import {NoWork} from './ReactFiberExpirationTime.old';
<add>import {NoWork} from './ReactFiberExpirationTime';
<ide>
<ide> import {REACT_RESPONDER_TYPE} from 'shared/ReactSymbols';
<ide>
<ide><path>packages/react-reconciler/src/ReactFiberDevToolsHook.old.js
<ide>
<ide> import {enableProfilerTimer} from 'shared/ReactFeatureFlags';
<ide> import {getCurrentTime} from './ReactFiberWorkLoop.old';
<del>import {inferPriorityFromExpirationTime} from './ReactFiberExpirationTime.old';
<add>import {inferPriorityFromExpirationTime} from './ReactFiberExpirationTime';
<ide>
<del>import type {Fiber} from './ReactFiber.old';
<del>import type {FiberRoot} from './ReactFiberRoot.old';
<del>import type {ExpirationTime} from './ReactFiberExpirationTime.old';
<add>import type {Fiber} from './ReactInternalTypes';
<add>import type {FiberRoot} from './ReactInternalTypes';
<add>import type {ExpirationTime} from './ReactFiberExpirationTime';
<ide> import type {ReactNodeList} from 'shared/ReactTypes';
<ide>
<ide> import {DidCapture} from './ReactSideEffectTags';
<ide><path>packages/react-reconciler/src/ReactFiberErrorDialog.js
<ide> * @flow
<ide> */
<ide>
<del>import type {Fiber} from './ReactFiber.old';
<add>import type {Fiber} from './ReactInternalTypes';
<ide> import type {CapturedValue} from './ReactCapturedValue';
<ide>
<ide> // This module is forked in different environments.
<ide><path>packages/react-reconciler/src/ReactFiberErrorLogger.js
<ide> * @flow
<ide> */
<ide>
<del>import type {Fiber} from './ReactFiber.old';
<add>import type {Fiber} from './ReactInternalTypes';
<ide> import type {CapturedValue} from './ReactCapturedValue';
<ide>
<ide> import {showErrorDialog} from './ReactFiberErrorDialog';
<add><path>packages/react-reconciler/src/ReactFiberExpirationTime.js
<del><path>packages/react-reconciler/src/ReactFiberExpirationTime.old.js
<ide> * @flow
<ide> */
<ide>
<del>import type {ReactPriorityLevel} from './SchedulerWithReactIntegration.old';
<add>import type {ReactPriorityLevel} from './ReactInternalTypes';
<ide>
<ide> import {MAX_SIGNED_31_BIT_INT} from './MaxInts';
<ide>
<ide><path>packages/react-reconciler/src/ReactFiberFundamental.old.js
<ide> * @flow
<ide> */
<ide>
<del>import type {Fiber} from './ReactFiber.old';
<add>import type {Fiber} from './ReactInternalTypes';
<ide> import type {
<ide> ReactFundamentalImpl,
<ide> ReactFundamentalComponentInstance,
<ide><path>packages/react-reconciler/src/ReactFiberHooks.old.js
<ide> import type {
<ide> ReactEventResponderListener,
<ide> ReactScopeMethods,
<ide> } from 'shared/ReactTypes';
<del>import type {Fiber} from './ReactFiber.old';
<del>import type {ExpirationTime} from './ReactFiberExpirationTime.old';
<add>import type {Fiber, Dispatcher} from './ReactInternalTypes';
<add>import type {ExpirationTime} from './ReactFiberExpirationTime';
<ide> import type {HookEffectTag} from './ReactHookEffectTags';
<del>import type {SuspenseConfig} from './ReactFiberSuspenseConfig.old';
<del>import type {ReactPriorityLevel} from './SchedulerWithReactIntegration.old';
<del>import type {FiberRoot} from './ReactFiberRoot.old';
<add>import type {SuspenseConfig} from './ReactFiberSuspenseConfig';
<add>import type {ReactPriorityLevel} from './ReactInternalTypes';
<add>import type {FiberRoot} from './ReactInternalTypes';
<ide> import type {
<ide> OpaqueIDType,
<ide> ReactListenerEvent,
<ide> import ReactSharedInternals from 'shared/ReactSharedInternals';
<ide> import {enableUseEventAPI} from 'shared/ReactFeatureFlags';
<ide>
<ide> import {markRootExpiredAtTime} from './ReactFiberRoot.old';
<del>import {NoWork, Sync} from './ReactFiberExpirationTime.old';
<add>import {NoWork, Sync} from './ReactFiberExpirationTime';
<ide> import {NoMode, BlockingMode} from './ReactTypeOfMode';
<ide> import {readContext} from './ReactFiberNewContext.old';
<ide> import {createDeprecatedResponderListener} from './ReactFiberDeprecatedEvents.old';
<ide> import invariant from 'shared/invariant';
<ide> import getComponentName from 'shared/getComponentName';
<ide> import is from 'shared/objectIs';
<ide> import {markWorkInProgressReceivedUpdate} from './ReactFiberBeginWork.old';
<del>import {requestCurrentSuspenseConfig} from './ReactFiberSuspenseConfig.old';
<add>import {requestCurrentSuspenseConfig} from './ReactFiberSuspenseConfig';
<ide> import {
<ide> UserBlockingPriority,
<ide> NormalPriority,
<ide> import {getIsRendering} from './ReactCurrentFiber';
<ide>
<ide> const {ReactCurrentDispatcher, ReactCurrentBatchConfig} = ReactSharedInternals;
<ide>
<del>export type Dispatcher = {|
<del> readContext<T>(
<del> context: ReactContext<T>,
<del> observedBits: void | number | boolean,
<del> ): T,
<del> useState<S>(initialState: (() => S) | S): [S, Dispatch<BasicStateAction<S>>],
<del> useReducer<S, I, A>(
<del> reducer: (S, A) => S,
<del> initialArg: I,
<del> init?: (I) => S,
<del> ): [S, Dispatch<A>],
<del> useContext<T>(
<del> context: ReactContext<T>,
<del> observedBits: void | number | boolean,
<del> ): T,
<del> useRef<T>(initialValue: T): {|current: T|},
<del> useEffect(
<del> create: () => (() => void) | void,
<del> deps: Array<mixed> | void | null,
<del> ): void,
<del> useLayoutEffect(
<del> create: () => (() => void) | void,
<del> deps: Array<mixed> | void | null,
<del> ): void,
<del> useCallback<T>(callback: T, deps: Array<mixed> | void | null): T,
<del> useMemo<T>(nextCreate: () => T, deps: Array<mixed> | void | null): T,
<del> useImperativeHandle<T>(
<del> ref: {|current: T | null|} | ((inst: T | null) => mixed) | null | void,
<del> create: () => T,
<del> deps: Array<mixed> | void | null,
<del> ): void,
<del> useDebugValue<T>(value: T, formatterFn: ?(value: T) => mixed): void,
<del> useResponder<E, C>(
<del> responder: ReactEventResponder<E, C>,
<del> props: Object,
<del> ): ReactEventResponderListener<E, C>,
<del> useDeferredValue<T>(value: T, config: TimeoutConfig | void | null): T,
<del> useTransition(
<del> config: SuspenseConfig | void | null,
<del> ): [(() => void) => void, boolean],
<del> useMutableSource<Source, Snapshot>(
<del> source: MutableSource<Source>,
<del> getSnapshot: MutableSourceGetSnapshotFn<Source, Snapshot>,
<del> subscribe: MutableSourceSubscribeFn<Source, Snapshot>,
<del> ): Snapshot,
<del> useEvent(event: ReactListenerEvent): ReactListenerMap,
<del> useOpaqueIdentifier(): OpaqueIDType | void,
<del>|};
<del>
<ide> type Update<S, A> = {|
<ide> expirationTime: ExpirationTime,
<ide> suspenseConfig: null | SuspenseConfig,
<ide> export type Effect = {|
<ide>
<ide> export type FunctionComponentUpdateQueue = {|lastEffect: Effect | null|};
<ide>
<del>export type TimeoutConfig = {|
<add>type TimeoutConfig = {|
<ide> timeoutMs: number,
<ide> |};
<ide>
<ide><path>packages/react-reconciler/src/ReactFiberHostContext.old.js
<ide> * @flow
<ide> */
<ide>
<del>import type {Fiber} from './ReactFiber.old';
<add>import type {Fiber} from './ReactInternalTypes';
<ide> import type {StackCursor} from './ReactFiberStack.old';
<ide> import type {Container, HostContext} from './ReactFiberHostConfig';
<ide>
<ide><path>packages/react-reconciler/src/ReactFiberHotReloading.old.js
<ide> */
<ide>
<ide> import type {ReactElement} from 'shared/ReactElementType';
<del>import type {Fiber} from './ReactFiber.old';
<del>import type {FiberRoot} from './ReactFiberRoot.old';
<add>import type {Fiber} from './ReactInternalTypes';
<add>import type {FiberRoot} from './ReactInternalTypes';
<ide> import type {Instance} from './ReactFiberHostConfig';
<ide> import type {ReactNodeList} from 'shared/ReactTypes';
<ide>
<ide> import {
<ide> } from './ReactFiberWorkLoop.old';
<ide> import {updateContainer, syncUpdates} from './ReactFiberReconciler.old';
<ide> import {emptyContextObject} from './ReactFiberContext.old';
<del>import {Sync} from './ReactFiberExpirationTime.old';
<add>import {Sync} from './ReactFiberExpirationTime';
<ide> import {
<ide> ClassComponent,
<ide> FunctionComponent,
<ide><path>packages/react-reconciler/src/ReactFiberHydrationContext.old.js
<ide> * @flow
<ide> */
<ide>
<del>import type {Fiber} from './ReactFiber.old';
<add>import type {Fiber} from './ReactInternalTypes';
<ide> import type {
<ide> Instance,
<ide> TextInstance,
<ide> import {
<ide> didNotFindHydratableSuspenseInstance,
<ide> } from './ReactFiberHostConfig';
<ide> import {enableSuspenseServerRenderer} from 'shared/ReactFeatureFlags';
<del>import {Never, NoWork} from './ReactFiberExpirationTime.old';
<add>import {Never, NoWork} from './ReactFiberExpirationTime';
<ide>
<ide> // The deepest Fiber on the stack involved in a hydration context.
<ide> // This may have been an insertion or a hydration.
<ide><path>packages/react-reconciler/src/ReactFiberNewContext.old.js
<ide> */
<ide>
<ide> import type {ReactContext} from 'shared/ReactTypes';
<del>import type {Fiber} from './ReactFiber.old';
<add>import type {Fiber, ContextDependency} from './ReactInternalTypes';
<ide> import type {StackCursor} from './ReactFiberStack.old';
<del>import type {ExpirationTime} from './ReactFiberExpirationTime.old';
<del>
<del>export type ContextDependency<T> = {
<del> context: ReactContext<T>,
<del> observedBits: number,
<del> next: ContextDependency<mixed> | null,
<del> ...
<del>};
<add>import type {ExpirationTime} from './ReactFiberExpirationTime';
<ide>
<ide> import {isPrimaryRenderer} from './ReactFiberHostConfig';
<ide> import {createCursor, push, pop} from './ReactFiberStack.old';
<ide> import {
<ide> import invariant from 'shared/invariant';
<ide> import is from 'shared/objectIs';
<ide> import {createUpdate, enqueueUpdate, ForceUpdate} from './ReactUpdateQueue.old';
<del>import {NoWork} from './ReactFiberExpirationTime.old';
<add>import {NoWork} from './ReactFiberExpirationTime';
<ide> import {markWorkInProgressReceivedUpdate} from './ReactFiberBeginWork.old';
<ide> import {enableSuspenseServerRenderer} from 'shared/ReactFeatureFlags';
<ide>
<ide><path>packages/react-reconciler/src/ReactFiberReconciler.old.js
<ide> * @flow
<ide> */
<ide>
<del>import type {Fiber} from './ReactFiber.old';
<del>import type {FiberRoot} from './ReactFiberRoot.old';
<add>import type {Fiber, SuspenseHydrationCallbacks} from './ReactInternalTypes';
<add>import type {FiberRoot} from './ReactInternalTypes';
<ide> import type {RootTag} from './ReactRootTags';
<ide> import type {
<ide> Instance,
<ide> import type {
<ide> import type {RendererInspectionConfig} from './ReactFiberHostConfig';
<ide> import {FundamentalComponent} from './ReactWorkTags';
<ide> import type {ReactNodeList, Thenable} from 'shared/ReactTypes';
<del>import type {ExpirationTime} from './ReactFiberExpirationTime.old';
<del>import type {
<del> SuspenseHydrationCallbacks,
<del> SuspenseState,
<del>} from './ReactFiberSuspenseComponent.old';
<add>import type {ExpirationTime} from './ReactFiberExpirationTime';
<add>import type {SuspenseState} from './ReactFiberSuspenseComponent.old';
<ide>
<ide> import {
<ide> findCurrentHostFiber,
<ide> import {
<ide> Sync,
<ide> ContinuousHydration,
<ide> computeInteractiveExpiration,
<del>} from './ReactFiberExpirationTime.old';
<del>import {requestCurrentSuspenseConfig} from './ReactFiberSuspenseConfig.old';
<add>} from './ReactFiberExpirationTime';
<add>import {requestCurrentSuspenseConfig} from './ReactFiberSuspenseConfig';
<ide> import {
<ide> scheduleRefresh,
<ide> scheduleRoot,
<ide><path>packages/react-reconciler/src/ReactFiberRoot.old.js
<ide> * @flow
<ide> */
<ide>
<del>import type {Fiber} from './ReactFiber.old';
<del>import type {ExpirationTime} from './ReactFiberExpirationTime.old';
<add>import type {FiberRoot, SuspenseHydrationCallbacks} from './ReactInternalTypes';
<add>import type {ExpirationTime} from './ReactFiberExpirationTime';
<ide> import type {RootTag} from './ReactRootTags';
<del>import type {TimeoutHandle, NoTimeout} from './ReactFiberHostConfig';
<del>import type {Wakeable} from 'shared/ReactTypes';
<del>import type {Interaction} from 'scheduler/src/Tracing';
<del>import type {SuspenseHydrationCallbacks} from './ReactFiberSuspenseComponent.old';
<del>import type {ReactPriorityLevel} from './SchedulerWithReactIntegration.old';
<ide>
<ide> import {noTimeout} from './ReactFiberHostConfig';
<ide> import {createHostRootFiber} from './ReactFiber.old';
<del>import {NoWork} from './ReactFiberExpirationTime.old';
<add>import {NoWork} from './ReactFiberExpirationTime';
<ide> import {
<ide> enableSchedulerTracing,
<ide> enableSuspenseCallback,
<ide> import {NoPriority} from './SchedulerWithReactIntegration.old';
<ide> import {initializeUpdateQueue} from './ReactUpdateQueue.old';
<ide> import {clearPendingUpdates as clearPendingMutableSourceUpdates} from './ReactMutableSource.old';
<ide>
<del>export type PendingInteractionMap = Map<ExpirationTime, Set<Interaction>>;
<del>
<del>type BaseFiberRootProperties = {|
<del> // The type of root (legacy, batched, concurrent, etc.)
<del> tag: RootTag,
<del>
<del> // Any additional information from the host associated with this root.
<del> containerInfo: any,
<del> // Used only by persistent updates.
<del> pendingChildren: any,
<del> // The currently active root fiber. This is the mutable root of the tree.
<del> current: Fiber,
<del>
<del> pingCache:
<del> | WeakMap<Wakeable, Set<ExpirationTime>>
<del> | Map<Wakeable, Set<ExpirationTime>>
<del> | null,
<del>
<del> finishedExpirationTime: ExpirationTime,
<del> // A finished work-in-progress HostRoot that's ready to be committed.
<del> finishedWork: Fiber | null,
<del> // Timeout handle returned by setTimeout. Used to cancel a pending timeout, if
<del> // it's superseded by a new one.
<del> timeoutHandle: TimeoutHandle | NoTimeout,
<del> // Top context object, used by renderSubtreeIntoContainer
<del> context: Object | null,
<del> pendingContext: Object | null,
<del> // Determines if we should attempt to hydrate on the initial mount
<del> +hydrate: boolean,
<del> // Node returned by Scheduler.scheduleCallback
<del> callbackNode: *,
<del> // Expiration of the callback associated with this root
<del> callbackExpirationTime: ExpirationTime,
<del> // Priority of the callback associated with this root
<del> callbackPriority: ReactPriorityLevel,
<del> // The earliest pending expiration time that exists in the tree
<del> firstPendingTime: ExpirationTime,
<del> // The latest pending expiration time that exists in the tree
<del> lastPendingTime: ExpirationTime,
<del> // The earliest suspended expiration time that exists in the tree
<del> firstSuspendedTime: ExpirationTime,
<del> // The latest suspended expiration time that exists in the tree
<del> lastSuspendedTime: ExpirationTime,
<del> // The next known expiration time after the suspended range
<del> nextKnownPendingLevel: ExpirationTime,
<del> // The latest time at which a suspended component pinged the root to
<del> // render again
<del> lastPingedTime: ExpirationTime,
<del> lastExpiredTime: ExpirationTime,
<del> // Used by useMutableSource hook to avoid tearing within this root
<del> // when external, mutable sources are read from during render.
<del> mutableSourceLastPendingUpdateTime: ExpirationTime,
<del>|};
<del>
<del>// The following attributes are only used by interaction tracing builds.
<del>// They enable interactions to be associated with their async work,
<del>// And expose interaction metadata to the React DevTools Profiler plugin.
<del>// Note that these attributes are only defined when the enableSchedulerTracing flag is enabled.
<del>type ProfilingOnlyFiberRootProperties = {|
<del> interactionThreadID: number,
<del> memoizedInteractions: Set<Interaction>,
<del> pendingInteractionMap: PendingInteractionMap,
<del>|};
<del>
<del>// The follow fields are only used by enableSuspenseCallback for hydration.
<del>type SuspenseCallbackOnlyFiberRootProperties = {|
<del> hydrationCallbacks: null | SuspenseHydrationCallbacks,
<del>|};
<del>
<del>// Exported FiberRoot type includes all properties,
<del>// To avoid requiring potentially error-prone :any casts throughout the project.
<del>// Profiling properties are only safe to access in profiling builds (when enableSchedulerTracing is true).
<del>// The types are defined separately within this file to ensure they stay in sync.
<del>// (We don't have to use an inline :any cast when enableSchedulerTracing is disabled.)
<del>export type FiberRoot = {
<del> ...BaseFiberRootProperties,
<del> ...ProfilingOnlyFiberRootProperties,
<del> ...SuspenseCallbackOnlyFiberRootProperties,
<del> ...
<del>};
<del>
<ide> function FiberRootNode(containerInfo, tag, hydrate) {
<ide> this.tag = tag;
<ide> this.current = null;
<ide><path>packages/react-reconciler/src/ReactFiberScope.old.js
<ide> * @flow
<ide> */
<ide>
<del>import type {Fiber} from './ReactFiber.old';
<add>import type {Fiber} from './ReactInternalTypes';
<ide> import type {
<ide> ReactScope,
<ide> ReactScopeInstance,
<ide><path>packages/react-reconciler/src/ReactFiberStack.old.js
<ide> * @flow
<ide> */
<ide>
<del>import type {Fiber} from './ReactFiber.old';
<add>import type {Fiber} from './ReactInternalTypes';
<ide>
<ide> export type StackCursor<T> = {|current: T|};
<ide>
<ide><path>packages/react-reconciler/src/ReactFiberSuspenseComponent.old.js
<ide> * @flow
<ide> */
<ide>
<del>import type {Fiber} from './ReactFiber.old';
<add>import type {Fiber} from './ReactInternalTypes';
<ide> import type {SuspenseInstance} from './ReactFiberHostConfig';
<del>import type {ExpirationTime} from './ReactFiberExpirationTime.old';
<add>import type {ExpirationTime} from './ReactFiberExpirationTime';
<ide> import {SuspenseComponent, SuspenseListComponent} from './ReactWorkTags';
<ide> import {NoEffect, DidCapture} from './ReactSideEffectTags';
<ide> import {
<ide> isSuspenseInstancePending,
<ide> isSuspenseInstanceFallback,
<ide> } from './ReactFiberHostConfig';
<ide>
<del>export type SuspenseHydrationCallbacks = {
<del> onHydrated?: (suspenseInstance: SuspenseInstance) => void,
<del> onDeleted?: (suspenseInstance: SuspenseInstance) => void,
<del> ...
<del>};
<del>
<ide> // A null SuspenseState represents an unsuspended normal Suspense boundary.
<ide> // A non-null SuspenseState means that it is blocked for one reason or another.
<ide> // - A non-null dehydrated field means it's blocked pending hydration.
<add><path>packages/react-reconciler/src/ReactFiberSuspenseConfig.js
<del><path>packages/react-reconciler/src/ReactFiberSuspenseConfig.old.js
<ide> export type SuspenseConfig = {|
<ide> busyMinDurationMs?: number,
<ide> |};
<ide>
<add>export type TimeoutConfig = {|
<add> timeoutMs: number,
<add>|};
<add>
<ide> export function requestCurrentSuspenseConfig(): null | SuspenseConfig {
<ide> return ReactCurrentBatchConfig.suspense;
<ide> }
<ide><path>packages/react-reconciler/src/ReactFiberSuspenseContext.old.js
<ide> * @flow
<ide> */
<ide>
<del>import type {Fiber} from './ReactFiber.old';
<add>import type {Fiber} from './ReactInternalTypes';
<ide> import type {StackCursor} from './ReactFiberStack.old';
<ide>
<ide> import {createCursor, push, pop} from './ReactFiberStack.old';
<ide><path>packages/react-reconciler/src/ReactFiberThrow.old.js
<ide> * @flow
<ide> */
<ide>
<del>import type {Fiber} from './ReactFiber.old';
<del>import type {FiberRoot} from './ReactFiberRoot.old';
<del>import type {ExpirationTime} from './ReactFiberExpirationTime.old';
<add>import type {Fiber} from './ReactInternalTypes';
<add>import type {FiberRoot} from './ReactInternalTypes';
<add>import type {ExpirationTime} from './ReactFiberExpirationTime';
<ide> import type {CapturedValue} from './ReactCapturedValue';
<ide> import type {Update} from './ReactUpdateQueue.old';
<ide> import type {Wakeable} from 'shared/ReactTypes';
<ide> import {
<ide> } from './ReactFiberWorkLoop.old';
<ide> import {logCapturedError} from './ReactFiberErrorLogger';
<ide>
<del>import {Sync} from './ReactFiberExpirationTime.old';
<add>import {Sync} from './ReactFiberExpirationTime';
<ide>
<ide> const PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;
<ide>
<ide><path>packages/react-reconciler/src/ReactFiberTreeReflection.js
<ide> * @flow
<ide> */
<ide>
<del>import type {Fiber} from './ReactFiber.old';
<add>import type {Fiber} from './ReactInternalTypes';
<ide> import type {Container, SuspenseInstance} from './ReactFiberHostConfig';
<ide> import type {SuspenseState} from './ReactFiberSuspenseComponent.old';
<ide>
<ide><path>packages/react-reconciler/src/ReactFiberUnwindWork.old.js
<ide> * @flow
<ide> */
<ide>
<del>import type {Fiber} from './ReactFiber.old';
<del>import type {ExpirationTime} from './ReactFiberExpirationTime.old';
<add>import type {Fiber} from './ReactInternalTypes';
<add>import type {ExpirationTime} from './ReactFiberExpirationTime';
<ide> import type {SuspenseState} from './ReactFiberSuspenseComponent.old';
<ide>
<ide> import {resetWorkInProgressVersions as resetMutableSourceWorkInProgressVersions} from './ReactMutableSource.old';
<ide><path>packages/react-reconciler/src/ReactFiberWorkLoop.old.js
<ide> */
<ide>
<ide> import type {Wakeable} from 'shared/ReactTypes';
<del>import type {Fiber} from './ReactFiber.old';
<del>import type {FiberRoot} from './ReactFiberRoot.old';
<del>import type {ExpirationTime} from './ReactFiberExpirationTime.old';
<del>import type {ReactPriorityLevel} from './SchedulerWithReactIntegration.old';
<add>import type {Fiber, FiberRoot} from './ReactInternalTypes';
<add>import type {ExpirationTime} from './ReactFiberExpirationTime';
<add>import type {ReactPriorityLevel} from './ReactInternalTypes';
<ide> import type {Interaction} from 'scheduler/src/Tracing';
<del>import type {SuspenseConfig} from './ReactFiberSuspenseConfig.old';
<add>import type {SuspenseConfig} from './ReactFiberSuspenseConfig';
<ide> import type {SuspenseState} from './ReactFiberSuspenseComponent.old';
<ide> import type {Effect as HookEffect} from './ReactFiberHooks.old';
<ide>
<ide> import {
<ide> LOW_PRIORITY_EXPIRATION,
<ide> Batched,
<ide> Idle,
<del>} from './ReactFiberExpirationTime.old';
<add>} from './ReactFiberExpirationTime';
<ide> import {beginWork as originalBeginWork} from './ReactFiberBeginWork.old';
<ide> import {completeWork} from './ReactFiberCompleteWork.old';
<ide> import {unwindWork, unwindInterruptedWork} from './ReactFiberUnwindWork.old';
<ide><path>packages/react-reconciler/src/ReactInternalTypes.js
<add>/**
<add> * Copyright (c) Facebook, Inc. and its affiliates.
<add> *
<add> * This source code is licensed under the MIT license found in the
<add> * LICENSE file in the root directory of this source tree.
<add> *
<add> * @flow
<add> */
<add>
<add>import type {Source} from 'shared/ReactElementType';
<add>import type {
<add> RefObject,
<add> ReactEventResponder,
<add> ReactEventResponderListener,
<add> ReactEventResponderInstance,
<add> ReactContext,
<add> MutableSourceSubscribeFn,
<add> MutableSourceGetSnapshotFn,
<add> MutableSource,
<add>} from 'shared/ReactTypes';
<add>import type {
<add> SuspenseInstance,
<add> ReactListenerEvent,
<add>} from './ReactFiberHostConfig';
<add>import type {WorkTag} from './ReactWorkTags';
<add>import type {TypeOfMode} from './ReactTypeOfMode';
<add>import type {SideEffectTag} from './ReactSideEffectTags';
<add>import type {ExpirationTime} from './ReactFiberExpirationTime';
<add>// import type {UpdateQueue} from './ReactUpdateQueue.old';
<add>import type {HookType} from './ReactFiberHooks.old';
<add>import type {RootTag} from './ReactRootTags';
<add>import type {TimeoutHandle, NoTimeout} from './ReactFiberHostConfig';
<add>import type {Wakeable} from 'shared/ReactTypes';
<add>import type {Interaction} from 'scheduler/src/Tracing';
<add>import type {
<add> OpaqueIDType,
<add> ReactListenerMap,
<add>} from 'react-reconciler/src/ReactFiberHostConfig';
<add>import type {SuspenseConfig, TimeoutConfig} from './ReactFiberSuspenseConfig';
<add>
<add>export type ReactPriorityLevel = 99 | 98 | 97 | 96 | 95 | 90;
<add>
<add>export type ContextDependency<T> = {
<add> context: ReactContext<T>,
<add> observedBits: number,
<add> next: ContextDependency<mixed> | null,
<add> ...
<add>};
<add>
<add>export type Dependencies = {
<add> expirationTime: ExpirationTime,
<add> firstContext: ContextDependency<mixed> | null,
<add> responders: Map<
<add> ReactEventResponder<any, any>,
<add> ReactEventResponderInstance<any, any>,
<add> > | null,
<add> ...
<add>};
<add>
<add>// A Fiber is work on a Component that needs to be done or was done. There can
<add>// be more than one per component.
<add>export type Fiber = {|
<add> // These first fields are conceptually members of an Instance. This used to
<add> // be split into a separate type and intersected with the other Fiber fields,
<add> // but until Flow fixes its intersection bugs, we've merged them into a
<add> // single type.
<add>
<add> // An Instance is shared between all versions of a component. We can easily
<add> // break this out into a separate object to avoid copying so much to the
<add> // alternate versions of the tree. We put this on a single object for now to
<add> // minimize the number of objects created during the initial render.
<add>
<add> // Tag identifying the type of fiber.
<add> tag: WorkTag,
<add>
<add> // Unique identifier of this child.
<add> key: null | string,
<add>
<add> // The value of element.type which is used to preserve the identity during
<add> // reconciliation of this child.
<add> elementType: any,
<add>
<add> // The resolved function/class/ associated with this fiber.
<add> type: any,
<add>
<add> // The local state associated with this fiber.
<add> stateNode: any,
<add>
<add> // Conceptual aliases
<add> // parent : Instance -> return The parent happens to be the same as the
<add> // return fiber since we've merged the fiber and instance.
<add>
<add> // Remaining fields belong to Fiber
<add>
<add> // The Fiber to return to after finishing processing this one.
<add> // This is effectively the parent, but there can be multiple parents (two)
<add> // so this is only the parent of the thing we're currently processing.
<add> // It is conceptually the same as the return address of a stack frame.
<add> return: Fiber | null,
<add>
<add> // Singly Linked List Tree Structure.
<add> child: Fiber | null,
<add> sibling: Fiber | null,
<add> index: number,
<add>
<add> // The ref last used to attach this node.
<add> // I'll avoid adding an owner field for prod and model that as functions.
<add> ref:
<add> | null
<add> | (((handle: mixed) => void) & {_stringRef: ?string, ...})
<add> | RefObject,
<add>
<add> // Input is the data coming into process this fiber. Arguments. Props.
<add> pendingProps: any, // This type will be more specific once we overload the tag.
<add> memoizedProps: any, // The props used to create the output.
<add>
<add> // A queue of state updates and callbacks.
<add> updateQueue: mixed,
<add>
<add> // The state used to create the output
<add> memoizedState: any,
<add>
<add> // Dependencies (contexts, events) for this fiber, if it has any
<add> dependencies: Dependencies | null,
<add>
<add> // Bitfield that describes properties about the fiber and its subtree. E.g.
<add> // the ConcurrentMode flag indicates whether the subtree should be async-by-
<add> // default. When a fiber is created, it inherits the mode of its
<add> // parent. Additional flags can be set at creation time, but after that the
<add> // value should remain unchanged throughout the fiber's lifetime, particularly
<add> // before its child fibers are created.
<add> mode: TypeOfMode,
<add>
<add> // Effect
<add> effectTag: SideEffectTag,
<add>
<add> // Singly linked list fast path to the next fiber with side-effects.
<add> nextEffect: Fiber | null,
<add>
<add> // The first and last fiber with side-effect within this subtree. This allows
<add> // us to reuse a slice of the linked list when we reuse the work done within
<add> // this fiber.
<add> firstEffect: Fiber | null,
<add> lastEffect: Fiber | null,
<add>
<add> // Represents a time in the future by which this work should be completed.
<add> // Does not include work found in its subtree.
<add> expirationTime: ExpirationTime,
<add>
<add> // This is used to quickly determine if a subtree has no pending changes.
<add> childExpirationTime: ExpirationTime,
<add>
<add> // This is a pooled version of a Fiber. Every fiber that gets updated will
<add> // eventually have a pair. There are cases when we can clean up pairs to save
<add> // memory if we need to.
<add> alternate: Fiber | null,
<add>
<add> // Time spent rendering this Fiber and its descendants for the current update.
<add> // This tells us how well the tree makes use of sCU for memoization.
<add> // It is reset to 0 each time we render and only updated when we don't bailout.
<add> // This field is only set when the enableProfilerTimer flag is enabled.
<add> actualDuration?: number,
<add>
<add> // If the Fiber is currently active in the "render" phase,
<add> // This marks the time at which the work began.
<add> // This field is only set when the enableProfilerTimer flag is enabled.
<add> actualStartTime?: number,
<add>
<add> // Duration of the most recent render time for this Fiber.
<add> // This value is not updated when we bailout for memoization purposes.
<add> // This field is only set when the enableProfilerTimer flag is enabled.
<add> selfBaseDuration?: number,
<add>
<add> // Sum of base times for all descendants of this Fiber.
<add> // This value bubbles up during the "complete" phase.
<add> // This field is only set when the enableProfilerTimer flag is enabled.
<add> treeBaseDuration?: number,
<add>
<add> // Conceptual aliases
<add> // workInProgress : Fiber -> alternate The alternate used for reuse happens
<add> // to be the same as work in progress.
<add> // __DEV__ only
<add> _debugID?: number,
<add> _debugSource?: Source | null,
<add> _debugOwner?: Fiber | null,
<add> _debugIsCurrentlyTiming?: boolean,
<add> _debugNeedsRemount?: boolean,
<add>
<add> // Used to verify that the order of hooks does not change between renders.
<add> _debugHookTypes?: Array<HookType> | null,
<add>|};
<add>
<add>export type PendingInteractionMap = Map<ExpirationTime, Set<Interaction>>;
<add>
<add>type BaseFiberRootProperties = {|
<add> // The type of root (legacy, batched, concurrent, etc.)
<add> tag: RootTag,
<add>
<add> // Any additional information from the host associated with this root.
<add> containerInfo: any,
<add> // Used only by persistent updates.
<add> pendingChildren: any,
<add> // The currently active root fiber. This is the mutable root of the tree.
<add> current: Fiber,
<add>
<add> pingCache:
<add> | WeakMap<Wakeable, Set<ExpirationTime>>
<add> | Map<Wakeable, Set<ExpirationTime>>
<add> | null,
<add>
<add> finishedExpirationTime: ExpirationTime,
<add> // A finished work-in-progress HostRoot that's ready to be committed.
<add> finishedWork: Fiber | null,
<add> // Timeout handle returned by setTimeout. Used to cancel a pending timeout, if
<add> // it's superseded by a new one.
<add> timeoutHandle: TimeoutHandle | NoTimeout,
<add> // Top context object, used by renderSubtreeIntoContainer
<add> context: Object | null,
<add> pendingContext: Object | null,
<add> // Determines if we should attempt to hydrate on the initial mount
<add> +hydrate: boolean,
<add> // Node returned by Scheduler.scheduleCallback
<add> callbackNode: *,
<add> // Expiration of the callback associated with this root
<add> callbackExpirationTime: ExpirationTime,
<add> // Priority of the callback associated with this root
<add> callbackPriority: ReactPriorityLevel,
<add> // The earliest pending expiration time that exists in the tree
<add> firstPendingTime: ExpirationTime,
<add> // The latest pending expiration time that exists in the tree
<add> lastPendingTime: ExpirationTime,
<add> // The earliest suspended expiration time that exists in the tree
<add> firstSuspendedTime: ExpirationTime,
<add> // The latest suspended expiration time that exists in the tree
<add> lastSuspendedTime: ExpirationTime,
<add> // The next known expiration time after the suspended range
<add> nextKnownPendingLevel: ExpirationTime,
<add> // The latest time at which a suspended component pinged the root to
<add> // render again
<add> lastPingedTime: ExpirationTime,
<add> lastExpiredTime: ExpirationTime,
<add> // Used by useMutableSource hook to avoid tearing within this root
<add> // when external, mutable sources are read from during render.
<add> mutableSourceLastPendingUpdateTime: ExpirationTime,
<add>|};
<add>
<add>// The following attributes are only used by interaction tracing builds.
<add>// They enable interactions to be associated with their async work,
<add>// And expose interaction metadata to the React DevTools Profiler plugin.
<add>// Note that these attributes are only defined when the enableSchedulerTracing flag is enabled.
<add>type ProfilingOnlyFiberRootProperties = {|
<add> interactionThreadID: number,
<add> memoizedInteractions: Set<Interaction>,
<add> pendingInteractionMap: PendingInteractionMap,
<add>|};
<add>
<add>export type SuspenseHydrationCallbacks = {
<add> onHydrated?: (suspenseInstance: SuspenseInstance) => void,
<add> onDeleted?: (suspenseInstance: SuspenseInstance) => void,
<add> ...
<add>};
<add>
<add>// The follow fields are only used by enableSuspenseCallback for hydration.
<add>type SuspenseCallbackOnlyFiberRootProperties = {|
<add> hydrationCallbacks: null | SuspenseHydrationCallbacks,
<add>|};
<add>
<add>// Exported FiberRoot type includes all properties,
<add>// To avoid requiring potentially error-prone :any casts throughout the project.
<add>// Profiling properties are only safe to access in profiling builds (when enableSchedulerTracing is true).
<add>// The types are defined separately within this file to ensure they stay in sync.
<add>// (We don't have to use an inline :any cast when enableSchedulerTracing is disabled.)
<add>export type FiberRoot = {
<add> ...BaseFiberRootProperties,
<add> ...ProfilingOnlyFiberRootProperties,
<add> ...SuspenseCallbackOnlyFiberRootProperties,
<add> ...
<add>};
<add>
<add>type BasicStateAction<S> = (S => S) | S;
<add>type Dispatch<A> = A => void;
<add>
<add>export type Dispatcher = {|
<add> readContext<T>(
<add> context: ReactContext<T>,
<add> observedBits: void | number | boolean,
<add> ): T,
<add> useState<S>(initialState: (() => S) | S): [S, Dispatch<BasicStateAction<S>>],
<add> useReducer<S, I, A>(
<add> reducer: (S, A) => S,
<add> initialArg: I,
<add> init?: (I) => S,
<add> ): [S, Dispatch<A>],
<add> useContext<T>(
<add> context: ReactContext<T>,
<add> observedBits: void | number | boolean,
<add> ): T,
<add> useRef<T>(initialValue: T): {|current: T|},
<add> useEffect(
<add> create: () => (() => void) | void,
<add> deps: Array<mixed> | void | null,
<add> ): void,
<add> useLayoutEffect(
<add> create: () => (() => void) | void,
<add> deps: Array<mixed> | void | null,
<add> ): void,
<add> useCallback<T>(callback: T, deps: Array<mixed> | void | null): T,
<add> useMemo<T>(nextCreate: () => T, deps: Array<mixed> | void | null): T,
<add> useImperativeHandle<T>(
<add> ref: {|current: T | null|} | ((inst: T | null) => mixed) | null | void,
<add> create: () => T,
<add> deps: Array<mixed> | void | null,
<add> ): void,
<add> useDebugValue<T>(value: T, formatterFn: ?(value: T) => mixed): void,
<add> useResponder<E, C>(
<add> responder: ReactEventResponder<E, C>,
<add> props: Object,
<add> ): ReactEventResponderListener<E, C>,
<add> useDeferredValue<T>(value: T, config: TimeoutConfig | void | null): T,
<add> useTransition(
<add> config: SuspenseConfig | void | null,
<add> ): [(() => void) => void, boolean],
<add> useMutableSource<Source, Snapshot>(
<add> source: MutableSource<Source>,
<add> getSnapshot: MutableSourceGetSnapshotFn<Source, Snapshot>,
<add> subscribe: MutableSourceSubscribeFn<Source, Snapshot>,
<add> ): Snapshot,
<add> useEvent(event: ReactListenerEvent): ReactListenerMap,
<add> useOpaqueIdentifier(): OpaqueIDType | void,
<add>|};
<ide><path>packages/react-reconciler/src/ReactMutableSource.old.js
<ide> * @flow
<ide> */
<ide>
<del>import type {ExpirationTime} from './ReactFiberExpirationTime.old';
<del>import type {FiberRoot} from './ReactFiberRoot.old';
<add>import type {ExpirationTime} from './ReactFiberExpirationTime';
<add>import type {FiberRoot} from './ReactInternalTypes';
<ide> import type {MutableSource, MutableSourceVersion} from 'shared/ReactTypes';
<ide>
<ide> import {isPrimaryRenderer} from './ReactFiberHostConfig';
<del>import {NoWork} from './ReactFiberExpirationTime.old';
<add>import {NoWork} from './ReactFiberExpirationTime';
<ide>
<ide> // Work in progress version numbers only apply to a single render,
<ide> // and should be reset before starting a new render.
<ide><path>packages/react-reconciler/src/ReactProfilerTimer.old.js
<ide> * @flow
<ide> */
<ide>
<del>import type {Fiber} from './ReactFiber.old';
<add>import type {Fiber} from './ReactInternalTypes';
<ide>
<ide> import {
<ide> enableProfilerTimer,
<ide><path>packages/react-reconciler/src/ReactStrictModeWarnings.old.js
<ide> * @flow
<ide> */
<ide>
<del>import type {Fiber} from './ReactFiber.old';
<add>import type {Fiber} from './ReactInternalTypes';
<ide>
<ide> import {getStackByFiberInDevAndProd} from './ReactFiberComponentStack';
<ide>
<ide><path>packages/react-reconciler/src/ReactUpdateQueue.old.js
<ide> // regardless of priority. Intermediate state may vary according to system
<ide> // resources, but the final state is always the same.
<ide>
<del>import type {Fiber} from './ReactFiber.old';
<del>import type {ExpirationTime} from './ReactFiberExpirationTime.old';
<del>import type {SuspenseConfig} from './ReactFiberSuspenseConfig.old';
<del>import type {ReactPriorityLevel} from './SchedulerWithReactIntegration.old';
<add>import type {Fiber} from './ReactInternalTypes';
<add>import type {ExpirationTime} from './ReactFiberExpirationTime';
<add>import type {SuspenseConfig} from './ReactFiberSuspenseConfig';
<add>import type {ReactPriorityLevel} from './ReactInternalTypes';
<ide>
<del>import {NoWork, Sync} from './ReactFiberExpirationTime.old';
<add>import {NoWork, Sync} from './ReactFiberExpirationTime';
<ide> import {
<ide> enterDisallowedContextReadInDEV,
<ide> exitDisallowedContextReadInDEV,
<ide> export function enqueueUpdate<State>(fiber: Fiber, update: Update<State>) {
<ide> return;
<ide> }
<ide>
<del> const sharedQueue = updateQueue.shared;
<add> const sharedQueue: SharedQueue<State> = (updateQueue: any).shared;
<ide> const pending = sharedQueue.pending;
<ide> if (pending === null) {
<ide> // This is the first update. Create a circular list.
<ide><path>packages/react-reconciler/src/SchedulerWithReactIntegration.old.js
<ide> * @flow
<ide> */
<ide>
<add>import type {ReactPriorityLevel} from './ReactInternalTypes';
<add>
<ide> // Intentionally not named imports because Rollup would use dynamic dispatch for
<ide> // CommonJS interop named imports.
<ide> import * as Scheduler from 'scheduler';
<ide> if (enableSchedulerTracing) {
<ide> );
<ide> }
<ide>
<del>export type ReactPriorityLevel = 99 | 98 | 97 | 96 | 95 | 90;
<ide> export type SchedulerCallback = (isSync: boolean) => SchedulerCallback | null;
<ide>
<ide> type SchedulerCallbackOptions = {timeout?: number, ...};
<ide><path>packages/react-refresh/src/ReactFreshRuntime.js
<ide> */
<ide>
<ide> import type {Instance} from 'react-reconciler/src/ReactFiberHostConfig';
<del>import type {FiberRoot} from 'react-reconciler/src/ReactFiberRoot.old';
<add>import type {FiberRoot} from 'react-reconciler/src/ReactInternalTypes';
<ide> import type {
<ide> Family,
<ide> RefreshUpdate,
<ide><path>packages/react-test-renderer/src/ReactTestRenderer.js
<ide> * @flow
<ide> */
<ide>
<del>import type {Fiber} from 'react-reconciler/src/ReactFiber.old';
<del>import type {FiberRoot} from 'react-reconciler/src/ReactFiberRoot.old';
<add>import type {Fiber} from 'react-reconciler/src/ReactInternalTypes';
<add>import type {FiberRoot} from 'react-reconciler/src/ReactInternalTypes';
<ide> import type {Instance, TextInstance} from './ReactTestHostConfig';
<ide>
<ide> import * as Scheduler from 'scheduler/unstable_mock';
<ide><path>packages/react/src/ReactBatchConfig.js
<ide> * @flow
<ide> */
<ide>
<del>import type {SuspenseConfig} from 'react-reconciler/src/ReactFiberSuspenseConfig.old';
<add>import type {SuspenseConfig} from 'react-reconciler/src/ReactFiberSuspenseConfig';
<ide>
<ide> import ReactCurrentBatchConfig from './ReactCurrentBatchConfig';
<ide>
<ide><path>packages/react/src/ReactCurrentBatchConfig.js
<ide> * @flow
<ide> */
<ide>
<del>import type {SuspenseConfig} from 'react-reconciler/src/ReactFiberSuspenseConfig.old';
<add>import type {SuspenseConfig} from 'react-reconciler/src/ReactFiberSuspenseConfig';
<ide>
<ide> /**
<ide> * Keeps track of the current batch's configuration such as how long an update
<ide><path>packages/react/src/ReactCurrentDispatcher.js
<ide> * @flow
<ide> */
<ide>
<del>import type {Dispatcher} from 'react-reconciler/src/ReactFiberHooks.old';
<add>import type {Dispatcher} from 'react-reconciler/src/ReactInternalTypes';
<ide>
<ide> /**
<ide> * Keeps track of the current dispatcher.
<ide><path>packages/react/src/ReactCurrentOwner.js
<ide> * @flow
<ide> */
<ide>
<del>import type {Fiber} from 'react-reconciler/src/ReactFiber.old';
<add>import type {Fiber} from 'react-reconciler/src/ReactInternalTypes';
<ide>
<ide> /**
<ide> * Keeps track of the current owner.
<ide><path>scripts/flow/react-native-host-hooks.js
<ide> import type {
<ide> } from 'react-native-renderer/src/ReactNativeTypes';
<ide> import type {RNTopLevelEventType} from 'legacy-events/TopLevelEventTypes';
<ide> import type {CapturedError} from 'react-reconciler/src/ReactCapturedValue';
<del>import type {Fiber} from 'react-reconciler/src/ReactFiber.old';
<add>import type {Fiber} from 'react-reconciler/src/ReactInternalTypes';
<ide>
<ide> type DeepDifferOptions = {|+unsafelyIgnoreFunctions?: boolean|};
<ide>
| 69
|
PHP
|
PHP
|
use array_keys instead of array_flip
|
9be789d3714b5c48fac940729268c4eeae72cf40
|
<ide><path>lib/Cake/Routing/Route/CakeRoute.php
<ide> protected function _writeUrl($params) {
<ide> $lengths = array_map('strlen', $this->keys);
<ide> $flipped = array_combine($this->keys, $lengths);
<ide> arsort($flipped);
<del> $keys = array_flip($flipped);
<add> $keys = array_keys($flipped);
<ide>
<ide> foreach ($keys as $key) {
<ide> $string = null;
| 1
|
Go
|
Go
|
fix race in list
|
3536c09ceaa2d94a43a3a3228b096ba7a61f558d
|
<ide><path>volume/local/local.go
<ide> type Root struct {
<ide> // List lists all the volumes
<ide> func (r *Root) List() ([]volume.Volume, error) {
<ide> var ls []volume.Volume
<add> r.m.Lock()
<ide> for _, v := range r.volumes {
<ide> ls = append(ls, v)
<ide> }
<add> r.m.Unlock()
<ide> return ls, nil
<ide> }
<ide>
| 1
|
Text
|
Text
|
use pbkdf2 in text
|
a65b0b90c96546a33b0c9d52c9c7024df201d6b1
|
<ide><path>doc/api/crypto.md
<ide> password always creates the same key. The low iteration count and
<ide> non-cryptographically secure hash algorithm allow passwords to be tested very
<ide> rapidly.
<ide>
<del>In line with OpenSSL's recommendation to use pbkdf2 instead of
<add>In line with OpenSSL's recommendation to use PBKDF2 instead of
<ide> [`EVP_BytesToKey`][] it is recommended that developers derive a key and IV on
<ide> their own using [`crypto.pbkdf2()`][] and to use [`crypto.createCipheriv()`][]
<ide> to create the `Cipher` object. Users should not use ciphers with counter mode
<ide> password always creates the same key. The low iteration count and
<ide> non-cryptographically secure hash algorithm allow passwords to be tested very
<ide> rapidly.
<ide>
<del>In line with OpenSSL's recommendation to use pbkdf2 instead of
<add>In line with OpenSSL's recommendation to use PBKDF2 instead of
<ide> [`EVP_BytesToKey`][] it is recommended that developers derive a key and IV on
<ide> their own using [`crypto.pbkdf2()`][] and to use [`crypto.createDecipheriv()`][]
<ide> to create the `Decipher` object.
| 1
|
Text
|
Text
|
fix a small typo in volume_inspect.md
|
a96be2930a64be88a5e8bf0e3b0283c657f73844
|
<ide><path>docs/reference/commandline/volume_inspect.md
<ide> parent = "smn_cli"
<ide> --help=false Print usage
<ide>
<ide> Returns information about a volume. By default, this command renders all results
<del>in a JSON array. You can specify an alternate format to execute a given template
<del>is executed for each result. Go's
<add>in a JSON array. You can specify an alternate format to execute a
<add>given template for each result. Go's
<ide> [text/template](http://golang.org/pkg/text/template/) package describes all the
<ide> details of the format.
<ide>
| 1
|
PHP
|
PHP
|
remove debug code included in previous commit
|
3f1a49d1cf7e303857b76aa543ac96c7bc662818
|
<ide><path>cake/tests/cases/libs/model/behaviors/tree.test.php
<ide> function testMoveToEnd() {
<ide> $this->NumberTree->id = $data['NumberTree']['id'];
<ide> $this->NumberTree->saveField('parent_id', null);
<ide> //$this->NumberTree->setparent(null);
<del> // Find the last parent node in the tree
<add> // Find the last parent node in the tree
<ide> $result = $this->NumberTree->find(null, array('name','parent_id'), 'NumberTree.rght desc');
<ide> $expected = array('NumberTree' => array('name' => '1.1', 'parent_id' => null));
<ide> $this->assertEqual($result, $expected);
<ide> function testDelete() {
<ide> $initialCount = $this->NumberTree->findCount();
<ide> $result = $this->NumberTree->findByName('1.1.1');
<ide>
<del> //pr ($this->NumberTree->findAll());
<del> //$db =& ConnectionManager::getDataSource($this->NumberTree->useDbConfig);
<del> //$db->fullDebug = true;
<ide> $return = $this->NumberTree->delete($result['NumberTree']['id']);
<del> //pr ($this->NumberTree->findAll());
<ide> $this->assertEqual($return, true);
<del> //die;
<ide>
<ide> $laterCount = $this->NumberTree->findCount();
<ide> $this->assertEqual($initialCount - 1, $laterCount);
| 1
|
PHP
|
PHP
|
add support for localization in authenticatesusers
|
e14199a3386f86af84efbad2d83ef62f851ebb5b
|
<ide><path>src/Illuminate/Foundation/Auth/AuthenticatesUsers.php
<ide> protected function getCredentials(Request $request)
<ide> */
<ide> protected function getFailedLoginMessage()
<ide> {
<del> return 'These credentials do not match our records.';
<add> return trans()->has('passwords.failed') ? trans('passwords.failed') : 'These credentials do not match our records.';
<ide> }
<ide>
<ide> /**
| 1
|
Mixed
|
Ruby
|
drop support for the `server_addr` header
|
093a4cde26225f315bb3d7ccda3b7a8e329ae339
|
<ide><path>actionpack/CHANGELOG.md
<add>* Drop support for the `SERVER_ADDR` header
<add>
<add> Following up https://github.com/rack/rack/pull/1573 and https://github.com/rails/rails/pull/42349
<add>
<add> *Ricardo Díaz*
<add>
<ide> * Set session options when initializing a basic session.
<ide>
<ide> *Gannon McGibbon*
<ide><path>actionpack/lib/action_dispatch/http/request.rb
<ide> class Request
<ide> HTTP_NEGOTIATE HTTP_PRAGMA HTTP_CLIENT_IP
<ide> HTTP_X_FORWARDED_FOR HTTP_ORIGIN HTTP_VERSION
<ide> HTTP_X_CSRF_TOKEN HTTP_X_REQUEST_ID HTTP_X_FORWARDED_HOST
<del> SERVER_ADDR
<ide> ].freeze
<ide>
<del> # TODO: Remove SERVER_ADDR when we remove support to Rack 2.1.
<del> # See https://github.com/rack/rack/commit/c173b188d81ee437b588c1e046a1c9f031dea550
<ide> ENV_METHODS.each do |env|
<ide> class_eval <<-METHOD, __FILE__, __LINE__ + 1
<ide> # frozen_string_literal: true
<ide><path>actionpack/lib/action_dispatch/http/url.rb
<ide> def raw_host_with_port
<ide> if forwarded = x_forwarded_host.presence
<ide> forwarded.split(/,\s?/).last
<ide> else
<del> get_header("HTTP_HOST") || "#{server_name || server_addr}:#{get_header('SERVER_PORT')}"
<add> get_header("HTTP_HOST") || "#{server_name}:#{get_header('SERVER_PORT')}"
<ide> end
<ide> end
<ide>
| 3
|
Ruby
|
Ruby
|
fix app generator
|
ad9bacb189e82816bf333cdbae329f199a171c9f
|
<ide><path>railties/environments/environment.rb
<ide> # If you change this key, all old sessions will become invalid!
<ide> config.action_controller.session = {
<ide> :session_key => '_<%= app_name %>_session',
<del> :secret => '<%= CGI::Session.generate_unique_id(app_name) %>'
<add> :secret => '<%= app_secret %>'
<ide> }
<ide>
<ide> # Use the database for sessions instead of the file system
<ide><path>railties/lib/rails_generator/generators/applications/app/app_generator.rb
<ide> require 'rbconfig'
<add>require 'digest/md5'
<ide>
<ide> class AppGenerator < Rails::Generator::Base
<ide> DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
<ide> def manifest
<ide> script_options = { :chmod => 0755, :shebang => options[:shebang] == DEFAULT_SHEBANG ? nil : options[:shebang] }
<ide> dispatcher_options = { :chmod => 0755, :shebang => options[:shebang] }
<ide>
<add> # duplicate CGI::Session#generate_unique_id
<add> md5 = Digest::MD5.new
<add> now = Time.now
<add> md5 << now.to_s
<add> md5 << String(now.usec)
<add> md5 << String(rand(0))
<add> md5 << String($$)
<add> md5 << @app_name
<add>
<ide> record do |m|
<ide> # Root directory and all subdirectories.
<ide> m.directory ''
<ide> def manifest
<ide>
<ide> # Initializers
<ide> m.template "configs/initializers/inflections.rb", "config/initializers/inflections.rb"
<del> m.template "configs/initializers/mime_types.rb", "configs/initializers/mime_types.rb"
<add> m.template "configs/initializers/mime_types.rb", "config/initializers/mime_types.rb"
<ide>
<ide> # Environments
<ide> m.file "environments/boot.rb", "config/boot.rb"
<del> m.template "environments/environment.rb", "config/environment.rb", :assigns => { :freeze => options[:freeze] }
<add> m.template "environments/environment.rb", "config/environment.rb", :assigns => { :freeze => options[:freeze], :app_name => @app_name, :app_secret => md5.hexdigest }
<ide> m.file "environments/production.rb", "config/environments/production.rb"
<ide> m.file "environments/development.rb", "config/environments/development.rb"
<ide> m.file "environments/test.rb", "config/environments/test.rb"
| 2
|
Go
|
Go
|
use a regex to match labels
|
bc709991b37270e87b84d0102366deff7e402531
|
<ide><path>daemon/logger/fluentd/fluentd.go
<ide> func ValidateLogOpt(cfg map[string]string) error {
<ide> case "env":
<ide> case "env-regex":
<ide> case "labels":
<add> case "labels-regex":
<ide> case "tag":
<ide> case addressKey:
<ide> case bufferLimitKey:
<ide><path>daemon/logger/gcplogs/gcplogging.go
<ide> import (
<ide> const (
<ide> name = "gcplogs"
<ide>
<del> projectOptKey = "gcp-project"
<del> logLabelsKey = "labels"
<del> logEnvKey = "env"
<del> logEnvRegexKey = "env-regex"
<del> logCmdKey = "gcp-log-cmd"
<del> logZoneKey = "gcp-meta-zone"
<del> logNameKey = "gcp-meta-name"
<del> logIDKey = "gcp-meta-id"
<add> projectOptKey = "gcp-project"
<add> logLabelsKey = "labels"
<add> logLabelsRegexKey = "labels-regex"
<add> logEnvKey = "env"
<add> logEnvRegexKey = "env-regex"
<add> logCmdKey = "gcp-log-cmd"
<add> logZoneKey = "gcp-meta-zone"
<add> logNameKey = "gcp-meta-name"
<add> logIDKey = "gcp-meta-id"
<ide> )
<ide>
<ide> var (
<ide> func New(info logger.Info) (logger.Logger, error) {
<ide> func ValidateLogOpts(cfg map[string]string) error {
<ide> for k := range cfg {
<ide> switch k {
<del> case projectOptKey, logLabelsKey, logEnvKey, logEnvRegexKey, logCmdKey, logZoneKey, logNameKey, logIDKey:
<add> case projectOptKey, logLabelsKey, logLabelsRegexKey, logEnvKey, logEnvRegexKey, logCmdKey, logZoneKey, logNameKey, logIDKey:
<ide> default:
<ide> return fmt.Errorf("%q is not a valid option for the gcplogs driver", k)
<ide> }
<ide><path>daemon/logger/gelf/gelf.go
<ide> func ValidateLogOpt(cfg map[string]string) error {
<ide> case "gelf-address":
<ide> case "tag":
<ide> case "labels":
<add> case "labels-regex":
<ide> case "env":
<ide> case "env-regex":
<ide> case "gelf-compression-level":
<ide><path>daemon/logger/gelf/gelf_test.go
<ide> func TestUDPValidateLogOpt(t *testing.T) {
<ide> "gelf-address": "udp://127.0.0.1:12201",
<ide> "tag": "testtag",
<ide> "labels": "testlabel",
<add> "labels-regex": "testlabel-regex",
<ide> "env": "testenv",
<ide> "env-regex": "testenv-regex",
<ide> "gelf-compression-level": "9",
<ide><path>daemon/logger/journald/journald.go
<ide> func validateLogOpt(cfg map[string]string) error {
<ide> for key := range cfg {
<ide> switch key {
<ide> case "labels":
<add> case "labels-regex":
<ide> case "env":
<ide> case "env-regex":
<ide> case "tag":
<ide><path>daemon/logger/jsonfilelog/jsonfilelog.go
<ide> func ValidateLogOpt(cfg map[string]string) error {
<ide> case "max-size":
<ide> case "compress":
<ide> case "labels":
<add> case "labels-regex":
<ide> case "env":
<ide> case "env-regex":
<ide> case "tag":
<ide><path>daemon/logger/jsonfilelog/jsonfilelog_test.go
<ide> func TestJSONFileLoggerWithLabelsEnv(t *testing.T) {
<ide> }
<ide> defer os.RemoveAll(tmp)
<ide> filename := filepath.Join(tmp, "container.log")
<del> config := map[string]string{"labels": "rack,dc", "env": "environ,debug,ssl", "env-regex": "^dc"}
<add> config := map[string]string{"labels": "rack,dc", "labels-regex": "^loc", "env": "environ,debug,ssl", "env-regex": "^dc"}
<ide> l, err := New(logger.Info{
<ide> ContainerID: cid,
<ide> LogPath: filename,
<ide> Config: config,
<del> ContainerLabels: map[string]string{"rack": "101", "dc": "lhr"},
<add> ContainerLabels: map[string]string{"rack": "101", "dc": "lhr", "location": "here"},
<ide> ContainerEnv: []string{"environ=production", "debug=false", "port=10001", "ssl=true", "dc_region=west"},
<ide> })
<ide> if err != nil {
<ide> func TestJSONFileLoggerWithLabelsEnv(t *testing.T) {
<ide> expected := map[string]string{
<ide> "rack": "101",
<ide> "dc": "lhr",
<add> "location": "here",
<ide> "environ": "production",
<ide> "debug": "false",
<ide> "ssl": "true",
<ide><path>daemon/logger/logentries/logentries.go
<ide> func ValidateLogOpt(cfg map[string]string) error {
<ide> case "env":
<ide> case "env-regex":
<ide> case "labels":
<add> case "labels-regex":
<ide> case "tag":
<ide> case key:
<ide> default:
<ide><path>daemon/logger/loginfo.go
<ide> func (info *Info) ExtraAttributes(keyMod func(string) string) (map[string]string
<ide> }
<ide> }
<ide>
<add> labelsRegex, ok := info.Config["labels-regex"]
<add> if ok && len(labels) > 0 {
<add> re, err := regexp.Compile(labelsRegex)
<add> if err != nil {
<add> return nil, err
<add> }
<add> for k, v := range info.ContainerLabels {
<add> if re.MatchString(k) {
<add> if keyMod != nil {
<add> k = keyMod(k)
<add> }
<add> extra[k] = v
<add> }
<add> }
<add> }
<add>
<ide> envMapping := make(map[string]string)
<ide> for _, e := range info.ContainerEnv {
<ide> if kv := strings.SplitN(e, "=", 2); len(kv) == 2 {
<ide><path>daemon/logger/splunk/splunk.go
<ide> const (
<ide> envKey = "env"
<ide> envRegexKey = "env-regex"
<ide> labelsKey = "labels"
<add> labelsRegexKey = "labels-regex"
<ide> tagKey = "tag"
<ide> )
<ide>
<ide> func ValidateLogOpt(cfg map[string]string) error {
<ide> case envKey:
<ide> case envRegexKey:
<ide> case labelsKey:
<add> case labelsRegexKey:
<ide> case tagKey:
<ide> default:
<ide> return fmt.Errorf("unknown log opt '%s' for %s log driver", key, driverName)
<ide><path>daemon/logger/syslog/syslog.go
<ide> func ValidateLogOpt(cfg map[string]string) error {
<ide> case "env":
<ide> case "env-regex":
<ide> case "labels":
<add> case "labels-regex":
<ide> case "syslog-address":
<ide> case "syslog-facility":
<ide> case "syslog-tls-ca-cert":
<ide><path>daemon/logger/syslog/syslog_test.go
<ide> func TestValidateLogOpt(t *testing.T) {
<ide> "env": "http://127.0.0.1",
<ide> "env-regex": "abc",
<ide> "labels": "labelA",
<add> "labels-regex": "def",
<ide> "syslog-address": "udp://1.2.3.4:1111",
<ide> "syslog-facility": "daemon",
<ide> "syslog-tls-ca-cert": "/etc/ca-certificates/custom/ca.pem",
| 12
|
Python
|
Python
|
fix typo in documentation. toto -> to
|
041a901f324eea7e7ee04b0f7a563c7ed5c8a03a
|
<ide><path>transformers/tokenization_gpt2.py
<ide> def _tokenize(self, text, add_prefix_space=False):
<ide> """ Tokenize a string.
<ide> Args:
<ide> - add_prefix_space (boolean, default False):
<del> Begin the sentence with at least one space toto get invariance to word order in GPT-2 (and RoBERTa) tokenizers.
<add> Begin the sentence with at least one space to get invariance to word order in GPT-2 (and RoBERTa) tokenizers.
<ide> """
<ide> if add_prefix_space:
<ide> text = ' ' + text
| 1
|
Ruby
|
Ruby
|
update ruby codegen to cleanup build folder.
|
0e316ec671617f5e7c1985b4b05cd0d45bcea403
|
<ide><path>scripts/cocoapods/__tests__/codegen_utils-test.rb
<ide> require_relative "./test_utils/FinderMock.rb"
<ide> require_relative "./test_utils/CodegenUtilsMock.rb"
<ide> require_relative "./test_utils/CodegenScriptPhaseExtractorMock.rb"
<add>require_relative "./test_utils/FileUtilsMock.rb"
<ide>
<ide> class CodegenUtilsTests < Test::Unit::TestCase
<ide> :base_path
<ide> def setup
<ide> end
<ide>
<ide> def teardown
<add> FileUtils::FileUtilsStorage.reset()
<ide> Finder.reset()
<ide> Pathname.reset()
<ide> Pod::UI.reset()
<ide> def testUseReactCodegenDiscovery_whenParametersAreGood_executeCodegen
<ide> ])
<ide> end
<ide>
<add> # ============================= #
<add> # Test - CleanUpCodegenFolder #
<add> # ============================= #
<add>
<add> def testCleanUpCodegenFolder_whenCleanupDone_doNothing
<add> # Arrange
<add> CodegenUtils.set_cleanup_done(true)
<add> codegen_dir = "build/generated/ios"
<add>
<add> # Act
<add> CodegenUtils.clean_up_build_folder(@base_path, codegen_dir)
<add>
<add> # Assert
<add> assert_equal(FileUtils::FileUtilsStorage.rmrf_invocation_count, 0)
<add> assert_equal(FileUtils::FileUtilsStorage.rmrf_paths, [])
<add> assert_equal(CodegenUtils.cleanup_done(), true)
<add> end
<add>
<add> def testCleanUpCodegenFolder_whenFolderDoesNotExists_markAsCleanupDone
<add> # Arrange
<add> CodegenUtils.set_cleanup_done(false)
<add> codegen_dir = "build/generated/ios"
<add>
<add> # Act
<add> CodegenUtils.clean_up_build_folder(@base_path, codegen_dir)
<add>
<add> # Assert
<add> assert_equal(FileUtils::FileUtilsStorage.rmrf_invocation_count, 0)
<add> assert_equal(FileUtils::FileUtilsStorage.rmrf_paths, [])
<add> assert_equal(Dir.glob_invocation, [])
<add> assert_equal(CodegenUtils.cleanup_done(), true)
<add> end
<add>
<add> def testCleanUpCodegenFolder_whenFolderExists_deleteItAndSetCleanupDone
<add> # Arrange
<add> CodegenUtils.set_cleanup_done(false)
<add> codegen_dir = "build/generated/ios"
<add> codegen_path = "#{@base_path}/#{codegen_dir}"
<add> globs = [
<add> "/MyModuleSpecs/MyModule.h",
<add> "#{codegen_path}/MyModuleSpecs/MyModule.mm",
<add> "#{codegen_path}/react/components/MyComponent/ShadowNode.h",
<add> "#{codegen_path}/react/components/MyComponent/ShadowNode.mm",
<add> ]
<add> Dir.mocked_existing_dirs(codegen_path)
<add> Dir.mocked_existing_globs(globs, "#{codegen_path}/*")
<add>
<add> # Act
<add> CodegenUtils.clean_up_build_folder(@base_path, codegen_dir)
<add>
<add> # Assert
<add> assert_equal(Dir.exist_invocation_params, [codegen_path])
<add> assert_equal(Dir.glob_invocation, ["#{codegen_path}/*"])
<add> assert_equal(FileUtils::FileUtilsStorage.rmrf_invocation_count, 1)
<add> assert_equal(FileUtils::FileUtilsStorage.rmrf_paths, [globs])
<add> assert_equal(CodegenUtils.cleanup_done(), true)
<add>
<add> end
<add>
<ide> private
<ide>
<ide> def get_podspec_no_fabric_no_script
<ide><path>scripts/cocoapods/__tests__/test_utils/FileUtilsMock.rb
<add># Copyright (c) Meta Platforms, Inc. and affiliates.
<add>#
<add># This source code is licensed under the MIT license found in the
<add># LICENSE file in the root directory of this source tree.
<add>
<add>module FileUtils
<add>
<add>
<add> class FileUtilsStorage
<add> @@RMRF_INVOCATION_COUNT = 0
<add> @@RMRF_PATHS = []
<add>
<add> def self.rmrf_invocation_count
<add> return @@RMRF_INVOCATION_COUNT
<add> end
<add>
<add> def self.increase_rmrfi_invocation_count
<add> @@RMRF_INVOCATION_COUNT += 1
<add> end
<add>
<add> def self.rmrf_paths
<add> return @@RMRF_PATHS
<add> end
<add>
<add> def self.push_rmrf_path(path)
<add> @@RMRF_PATHS.push(path)
<add> end
<add>
<add> def self.reset
<add> @@RMRF_INVOCATION_COUNT = 0
<add> @@RMRF_PATHS = []
<add> end
<add> end
<add>
<add> def self.rm_rf(path)
<add> FileUtilsStorage.push_rmrf_path(path)
<add> FileUtilsStorage.increase_rmrfi_invocation_count
<add> end
<add>end
<ide><path>scripts/cocoapods/codegen.rb
<ide> def run_codegen!(
<ide> folly_version: '2021.07.22.00',
<ide> codegen_utils: CodegenUtils.new()
<ide> )
<add>
<ide> if new_arch_enabled
<ide> codegen_utils.use_react_native_codegen_discovery!(
<ide> disable_codegen,
<ide><path>scripts/cocoapods/codegen_utils.rb
<ide> def use_react_native_codegen_discovery!(
<ide>
<ide> CodegenUtils.set_react_codegen_discovery_done(true)
<ide> end
<add>
<add> @@CLEANUP_DONE = false
<add>
<add> def self.set_cleanup_done(newValue)
<add> @@CLEANUP_DONE = newValue
<add> end
<add>
<add> def self.cleanup_done
<add> return @@CLEANUP_DONE
<add> end
<add>
<add> def self.clean_up_build_folder(app_path, codegen_dir)
<add> return if CodegenUtils.cleanup_done()
<add> CodegenUtils.set_cleanup_done(true)
<add>
<add> codegen_path = File.join(app_path, codegen_dir)
<add> return if !Dir.exist?(codegen_path)
<add>
<add> FileUtils.rm_rf(Dir.glob("#{codegen_path}/*"))
<add> CodegenUtils.set_cleanup_done(true)
<add> end
<ide> end
<ide><path>scripts/react_native_pods.rb
<ide> def use_react_native! (
<ide> app_path: '..',
<ide> config_file_dir: '')
<ide>
<add> CodegenUtils.clean_up_build_folder(app_path, $CODEGEN_OUTPUT_DIR)
<add>
<ide> prefix = path
<ide>
<ide> # The version of folly that must be used
| 5
|
Ruby
|
Ruby
|
solve some warnings and a failing test
|
653acac069e66f53b791caa4838a1e25de905f31
|
<ide><path>actionpack/lib/action_controller/test_case.rb
<ide> class TestSession < Rack::Session::Abstract::SessionHash #:nodoc:
<ide> DEFAULT_OPTIONS = Rack::Session::Abstract::ID::DEFAULT_OPTIONS
<ide>
<ide> def initialize(session = {})
<add> @env, @by = nil, nil
<ide> replace(session.stringify_keys)
<ide> @loaded = true
<ide> end
<ide><path>actionpack/lib/action_dispatch/http/request.rb
<ide> def body_stream #:nodoc:
<ide> # TODO This should be broken apart into AD::Request::Session and probably
<ide> # be included by the session middleware.
<ide> def reset_session
<del> session.destroy if session
<add> session.destroy if session && session.respond_to?(:destroy)
<ide> self.session = {}
<ide> @env['action_dispatch.request.flash_hash'] = nil
<ide> end
| 2
|
Python
|
Python
|
fix typo discard_count -> discarded_count
|
2c28350d949c1964940546bcbdaacec049adeaed
|
<ide><path>celery/bin/celeryd.py
<ide> def say(msg):
<ide>
<ide> if discard:
<ide> discarded_count = discard_all()
<del> what = discard_count > 1 and "messages" or "message"
<add> what = discarded_count > 1 and "messages" or "message"
<ide> say("discard: Erased %d %s from the queue.\n" % (
<ide> discarded_count, what))
<ide>
| 1
|
Javascript
|
Javascript
|
complete the request on timeout
|
fdf8e0f9889c4ee55c055f09aab57030314c6fde
|
<ide><path>src/ng/httpBackend.js
<ide> function createHttpBackend($browser, createXhr, $browserDefer, callbacks, rawDoc
<ide>
<ide> xhr.onerror = requestError;
<ide> xhr.onabort = requestError;
<add> xhr.ontimeout = requestError;
<ide>
<ide> forEach(eventHandlers, function(value, key) {
<ide> xhr.addEventListener(key, value);
<ide><path>test/ng/httpBackendSpec.js
<ide> describe('$httpBackend', function() {
<ide> });
<ide>
<ide> it('should not try to read response data when request is aborted', function() {
<del> callback.and.callFake(function(status, response, headers) {
<add> callback.and.callFake(function(status, response, headers, statusText) {
<ide> expect(status).toBe(-1);
<ide> expect(response).toBe(null);
<ide> expect(headers).toBe(null);
<add> expect(statusText).toBe('');
<ide> });
<ide> $backend('GET', '/url', null, callback, {}, 2000);
<ide> xhr = MockXhr.$$lastInstance;
<ide> describe('$httpBackend', function() {
<ide> expect(callback).toHaveBeenCalledOnce();
<ide> });
<ide>
<add> it('should complete the request on timeout', function() {
<add> callback.and.callFake(function(status, response, headers, statusText) {
<add> expect(status).toBe(-1);
<add> expect(response).toBe(null);
<add> expect(headers).toBe(null);
<add> expect(statusText).toBe('');
<add> });
<add> $backend('GET', '/url', null, callback, {});
<add> xhr = MockXhr.$$lastInstance;
<add>
<add> expect(callback).not.toHaveBeenCalled();
<add>
<add> xhr.ontimeout();
<add> expect(callback).toHaveBeenCalledOnce();
<add> });
<add>
<ide> it('should abort request on timeout', function() {
<ide> callback.and.callFake(function(status, response) {
<ide> expect(status).toBe(-1);
<ide> describe('$httpBackend', function() {
<ide> expect(MockXhr.$$lastInstance.withCredentials).toBe(true);
<ide> });
<ide>
<add>
<ide> it('should call $xhrFactory with method and url', function() {
<ide> var mockXhrFactory = jasmine.createSpy('mockXhrFactory').and.callFake(createMockXhr);
<ide> $backend = createHttpBackend($browser, mockXhrFactory, $browser.defer, $jsonpCallbacks, fakeDocument);
<ide> describe('$httpBackend', function() {
<ide> // TODO(vojta): test whether it fires "async-end" on both success and error
<ide> });
<ide>
<add>
<ide> describe('protocols that return 0 status code', function() {
<ide>
<ide> function respond(status, content) {
<ide> describe('$httpBackend', function() {
<ide> xhr.onload();
<ide> }
<ide>
<del>
<del> it('should convert 0 to 200 if content and file protocol', function() {
<add> beforeEach(function() {
<ide> $backend = createHttpBackend($browser, createMockXhr);
<add> });
<add>
<ide>
<add> it('should convert 0 to 200 if content and file protocol', function() {
<ide> $backend('GET', 'file:///whatever/index.html', null, callback);
<ide> respond(0, 'SOME CONTENT');
<ide>
<ide> describe('$httpBackend', function() {
<ide> });
<ide>
<ide> it('should convert 0 to 200 if content for protocols other than file', function() {
<del> $backend = createHttpBackend($browser, createMockXhr);
<del>
<ide> $backend('GET', 'someProtocol:///whatever/index.html', null, callback);
<ide> respond(0, 'SOME CONTENT');
<ide>
<ide> describe('$httpBackend', function() {
<ide> });
<ide>
<ide> it('should convert 0 to 404 if no content and file protocol', function() {
<del> $backend = createHttpBackend($browser, createMockXhr);
<del>
<ide> $backend('GET', 'file:///whatever/index.html', null, callback);
<ide> respond(0, '');
<ide>
<ide> describe('$httpBackend', function() {
<ide> });
<ide>
<ide> it('should not convert 0 to 404 if no content for protocols other than file', function() {
<del> $backend = createHttpBackend($browser, createMockXhr);
<del>
<ide> $backend('GET', 'someProtocol:///whatever/index.html', null, callback);
<ide> respond(0, '');
<ide>
<ide> describe('$httpBackend', function() {
<ide>
<ide> try {
<ide>
<del> $backend = createHttpBackend($browser, createMockXhr);
<del>
<ide> $backend('GET', '/whatever/index.html', null, callback);
<ide> respond(0, '');
<ide>
<ide> describe('$httpBackend', function() {
<ide> }
<ide> });
<ide>
<del>
<ide> it('should return original backend status code if different from 0', function() {
<del> $backend = createHttpBackend($browser, createMockXhr);
<del>
<ide> // request to http://
<ide> $backend('POST', 'http://rest_api/create_whatever', null, callback);
<ide> respond(201, '');
| 2
|
Python
|
Python
|
use optionparser for win32 build script
|
bd8c4ce81340901cd7322f84cd1911581ce910dd
|
<ide><path>tools/win32build/build.py
<ide> import subprocess
<ide> import os
<ide> import shutil
<add>from os.path import join as pjoin, split as psplit, dirname
<ide>
<ide> PYEXECS = {"2.5" : "C:\python25\python.exe",
<ide> "2.4" : "C:\python24\python2.4.exe"}
<ide> def get_windist_exec(pyver):
<ide> name = "numpy-%s.win32-py%s.exe" % (get_numpy_version(), pyver)
<ide> return name
<ide>
<del>USAGE = """build.py ARCH PYTHON_VERSION
<del>
<del>Example: build.py sse2 2.4."""
<del>
<ide> if __name__ == '__main__':
<del> if len(sys.argv) < 3:
<del> raise ValueError(USAGE)
<del> sys.exit(-1)
<del>
<del> arch = sys.argv[1]
<del> pyver = sys.argv[2]
<del> #build(arch, pyver)
<del> for arch in SITECFG.keys():
<del> build(arch, pyver)
<add> from optparse import OptionParser
<add> parser = OptionParser()
<add> parser.add_option("-a", "--arch", dest="arch",
<add> help = "Architecture to build (sse2, sse3, nosse, etc...)")
<add> parser.add_option("-p", "--pyver", dest="pyver",
<add> help = "Python version (2.4, 2.5, etc...)")
<add>
<add> opts, args = parser.parse_args()
<add> arch = opts.arch
<add> pyver = opts.pyver
<add>
<add> if not arch:
<add> arch = "nosse"
<add> if not pyver:
<add> pyver = "2.5"
<add> build(arch, pyver)
<add> #for arch in SITECFG.keys():
<add> # build(arch, pyver)
| 1
|
Text
|
Text
|
add fix to change log
|
cfe5fa109a1b0073b2859154168c90658c859c24
|
<ide><path>laravel/documentation/changes.md
<ide> ## Laravel 3.2.7
<ide>
<ide> - Fix bug in Eloquent `to_array` method.
<add>- Fix bug in displaying of generic error page.
<ide>
<ide> <a name="upgrade-3.2.7"></a>
<ide> ### Upgrading From 3.2.6
| 1
|
Javascript
|
Javascript
|
fix crash with empty section headers
|
28b43aa05c7f98f3a2a0938f203ae4745040c9ca
|
<ide><path>Libraries/CustomComponents/ListView/ListView.js
<ide> var ListView = React.createClass({
<ide> }
<ide>
<ide> if (renderSectionHeader) {
<del> bodyComponents.push(React.cloneElement(
<del> renderSectionHeader(
<del> dataSource.getSectionHeaderData(sectionIdx),
<del> sectionID
<del> ),
<del> {key: 's_' + sectionID},
<del> ));
<del> if (this.props.stickySectionHeadersEnabled) {
<del> stickySectionHeaderIndices.push(totalIndex++);
<add> const element = renderSectionHeader(
<add> dataSource.getSectionHeaderData(sectionIdx),
<add> sectionID
<add> );
<add> if (element) {
<add> bodyComponents.push(React.cloneElement(element, {key: 's_' + sectionID}));
<add> if (this.props.stickySectionHeadersEnabled) {
<add> stickySectionHeaderIndices.push(totalIndex);
<add> }
<add> totalIndex++;
<ide> }
<ide> }
<ide>
| 1
|
PHP
|
PHP
|
keyby() typehint
|
52cea7fb5f7f5e4704518b6a82b21a1e8ecb1cc9
|
<ide><path>src/Illuminate/Collections/Arr.php
<ide> public static function join($array, $glue, $finalGlue = '')
<ide> * Key an associative array by a field or using a callback.
<ide> *
<ide> * @param array $array
<del> * @param callable|array|string
<add> * @param callable|array|string $keyBy
<ide> * @return array
<ide> */
<ide> public static function keyBy($array, $keyBy)
| 1
|
Javascript
|
Javascript
|
add test for prop interceptors on sandbox
|
a37a0ad5f6880a133a2091bd8ac0092e3d1b7688
|
<ide><path>test/parallel/test-vm-global-property-interceptors.js
<add>'use strict';
<add>require('../common');
<add>const assert = require('assert');
<add>const vm = require('vm');
<add>
<add>const dSymbol = Symbol('d');
<add>const sandbox = {
<add> a: 'a',
<add> dSymbol
<add>};
<add>
<add>Object.defineProperties(sandbox, {
<add> b: {
<add> value: 'b'
<add> },
<add> c: {
<add> value: 'c',
<add> writable: true,
<add> enumerable: true
<add> },
<add> [dSymbol]: {
<add> value: 'd'
<add> },
<add> e: {
<add> value: 'e',
<add> configurable: true
<add> },
<add> f: {}
<add>});
<add>
<add>const ctx = vm.createContext(sandbox);
<add>
<add>const result = vm.runInContext(`
<add>const getDesc = (prop) => Object.getOwnPropertyDescriptor(this, prop);
<add>const result = {
<add> a: getDesc('a'),
<add> b: getDesc('b'),
<add> c: getDesc('c'),
<add> d: getDesc(dSymbol),
<add> e: getDesc('e'),
<add> f: getDesc('f'),
<add> g: getDesc('g')
<add>};
<add>result;
<add>`, ctx);
<add>
<add>//eslint-disable-next-line no-restricted-properties
<add>assert.deepEqual(result, {
<add> a: { value: 'a', writable: true, enumerable: true, configurable: true },
<add> b: { value: 'b', writable: false, enumerable: false, configurable: false },
<add> c: { value: 'c', writable: true, enumerable: true, configurable: false },
<add> d: { value: 'd', writable: false, enumerable: false, configurable: false },
<add> e: { value: 'e', writable: false, enumerable: false, configurable: true },
<add> f: {
<add> value: undefined,
<add> writable: false,
<add> enumerable: false,
<add> configurable: false
<add> },
<add> g: undefined
<add>});
<add>
<add>// define new properties
<add>vm.runInContext(`
<add>Object.defineProperty(this, 'h', {value: 'h'});
<add>Object.defineProperty(this, 'i', {});
<add>Object.defineProperty(this, 'j', {
<add> get() { return 'j'; }
<add>});
<add>let kValue = 0;
<add>Object.defineProperty(this, 'k', {
<add> get() { return kValue; },
<add> set(value) { kValue = value }
<add>});
<add>`, ctx);
<add>
<add>assert.deepStrictEqual(Object.getOwnPropertyDescriptor(ctx, 'h'), {
<add> value: 'h',
<add> writable: false,
<add> enumerable: false,
<add> configurable: false
<add>});
<add>
<add>assert.deepStrictEqual(Object.getOwnPropertyDescriptor(ctx, 'i'), {
<add> value: undefined,
<add> writable: false,
<add> enumerable: false,
<add> configurable: false
<add>});
<add>
<add>const jDesc = Object.getOwnPropertyDescriptor(ctx, 'j');
<add>assert.strictEqual(typeof jDesc.get, 'function');
<add>assert.strictEqual(typeof jDesc.set, 'undefined');
<add>assert.strictEqual(jDesc.enumerable, false);
<add>assert.strictEqual(jDesc.configurable, false);
<add>
<add>const kDesc = Object.getOwnPropertyDescriptor(ctx, 'k');
<add>assert.strictEqual(typeof kDesc.get, 'function');
<add>assert.strictEqual(typeof kDesc.set, 'function');
<add>assert.strictEqual(kDesc.enumerable, false);
<add>assert.strictEqual(kDesc.configurable, false);
<add>
<add>assert.strictEqual(ctx.k, 0);
<add>ctx.k = 1;
<add>assert.strictEqual(ctx.k, 1);
<add>assert.strictEqual(vm.runInContext('k;', ctx), 1);
<add>vm.runInContext('k = 2;', ctx);
<add>assert.strictEqual(ctx.k, 2);
<add>assert.strictEqual(vm.runInContext('k;', ctx), 2);
<add>
<add>// redefine properties on the global object
<add>assert.strictEqual(typeof vm.runInContext('encodeURI;', ctx), 'function');
<add>assert.strictEqual(ctx.encodeURI, undefined);
<add>vm.runInContext(`
<add>Object.defineProperty(this, 'encodeURI', { value: 42 });
<add>`, ctx);
<add>assert.strictEqual(vm.runInContext('encodeURI;', ctx), 42);
<add>assert.strictEqual(ctx.encodeURI, 42);
<add>
<add>// redefine properties on the sandbox
<add>vm.runInContext(`
<add>Object.defineProperty(this, 'e', { value: 'newE' });
<add>`, ctx);
<add>assert.strictEqual(ctx.e, 'newE');
<add>
<add>assert.throws(() => vm.runInContext(`
<add>'use strict';
<add>Object.defineProperty(this, 'f', { value: 'newF' });
<add>`, ctx), /TypeError: Cannot redefine property: f/);
| 1
|
Javascript
|
Javascript
|
use require for nativemodules
|
bd2c57569b916750b3d61a4f122ee305974352fe
|
<ide><path>Libraries/TurboModule/TurboModuleRegistry.js
<ide>
<ide> 'use strict';
<ide>
<del>import NativeModules from '../BatchedBridge/NativeModules';
<add>const NativeModules = require('../BatchedBridge/NativeModules');
<ide> import type {TurboModule} from './RCTExport';
<ide> import invariant from 'invariant';
<ide>
| 1
|
PHP
|
PHP
|
fix cookie reading
|
5f5218f3b20cdb43a0680825ffc760e2965b4854
|
<ide><path>lib/Cake/Controller/Component/CookieComponent.php
<ide> public function read($key = null) {
<ide> return null;
<ide> }
<ide>
<del> if (!empty($names[1])) {
<add> if (!empty($names[1]) && is_array($this->_values[$this->name][$key])) {
<ide> return Hash::get($this->_values[$this->name][$key], $names[1]);
<ide> }
<ide> return $this->_values[$this->name][$key];
| 1
|
Text
|
Text
|
fix my fix😅
|
99deae9b7046a44cf3752bd320d1acc54ec7e89c
|
<ide><path>docs/tutorials/essentials/part-5-async-logic.md
<ide> We only need to fetch the list of users once, and we want to do it right when th
<ide> ```js title="index.js"
<ide> // omit other imports
<ide>
<del>// highlight-next-line
<add>// highlight-start
<ide> import store from './app/store'
<del>// highlight-next-line
<ide> import { fetchUsers } from './features/users/usersSlice'
<add>// highlight-end
<ide>
<ide> import { worker } from './api/server'
<ide>
| 1
|
Ruby
|
Ruby
|
add form_with to unify form_tag/form_for.
|
67f81cc72db625799465332b87343cc625f346ae
|
<ide><path>actionview/lib/action_view/helpers/form_helper.rb
<ide> def apply_form_for_options!(record, object, options) #:nodoc:
<ide> end
<ide> private :apply_form_for_options!
<ide>
<add> # Creates a form tag based on mixing URLs, scopes, or models.
<add> #
<add> # # Using just a URL:
<add> # <%= form_with url: posts_path do |form| %>
<add> # <%= form.text_field :title %>
<add> # <% end %>
<add> # # =>
<add> # <form action="/posts" method="post" data-remote="true">
<add> # <input type="text" name="title">
<add> # </form>
<add> #
<add> # # Adding a scope prefixes the input field names:
<add> # <%= form_with scope: :post, url: posts_path do |form| %>
<add> # <%= form.text_field :title %>
<add> # <% end %>
<add> # # =>
<add> # <form action="/posts" method="post" data-remote="true">
<add> # <input type="text" name="post[title]">
<add> # </form>
<add> #
<add> # # Using a model infers both the URL and scope:
<add> # <%= form_with model: Post.new do |form| %>
<add> # <%= form.text_field :title %>
<add> # <% end %>
<add> # # =>
<add> # <form action="/posts" method="post" data-remote="true">
<add> # <input type="text" name="post[title]">
<add> # </form>
<add> #
<add> # # An existing model makes an update form and fills out field values:
<add> # <%= form_with model: Post.first do |form| %>
<add> # <%= form.text_field :title %>
<add> # <% end %>
<add> # # =>
<add> # <form action="/posts/1" method="post" data-remote="true">
<add> # <input type="hidden" name="_method" value="patch">
<add> # <input type="text" name="post[title]" value="<the title of the post>">
<add> # </form>
<add> #
<add> # The parameters in the forms are accessible in controllers according to
<add> # their name nesting. So inputs named +title+ and <tt>post[title]</tt> are
<add> # accessible as <tt>params[:title]</tt> and <tt>params[:post][:title]</tt>
<add> # respectively.
<add> #
<add> # By default +form_with+ attaches the <tt>data-remote</tt> attribute
<add> # submitting the form via an XMLHTTPRequest in the background if an
<add> # an Unobtrusive JavaScript driver, like rails-ujs, is used. See the
<add> # <tt>:remote</tt> option for more.
<add> #
<add> # For ease of comparison the examples above left out the submit button,
<add> # as well as the auto generated hidden fields that enable UTF-8 support
<add> # and adds an authenticity token needed for cross site request forgery
<add> # protection.
<add> #
<add> # ==== +form_with+ options
<add> #
<add> # * <tt>:url</tt> - The URL the form submits to. Akin to values passed to
<add> # +url_for+ or +link_to+. For example, you may use a named route
<add> # directly. When a <tt>:scope</tt> is passed without a <tt>:url</tt> the
<add> # form just submits to the current URL.
<add> # * <tt>:method</tt> - The method to use when submitting the form, usually
<add> # either "get" or "post". If "patch", "put", "delete", or another verb
<add> # is used, a hidden input named <tt>_method</tt> is added to
<add> # simulate the verb over post.
<add> # * <tt>:format</tt> - The format of the route the form submits to.
<add> # Useful when submitting to another resource type, like <tt>:json</tt>.
<add> # Skipped if a <tt>:url</tt> is passed.
<add> # * <tt>:scope</tt> - The scope to prefix input field names with and
<add> # thereby how the submitted parameters are grouped in controllers.
<add> # * <tt>:model</tt> - A model object to infer the <tt>:url</tt> and
<add> # <tt>:scope</tt> by, plus fill out input field values.
<add> # So if a +title+ attribute is set to "Ahoy!" then a +title+ input
<add> # field's value would be "Ahoy!".
<add> # If the model is a new record a create form is generated, if an
<add> # existing record, however, an update form is generated.
<add> # Pass <tt>:scope</tt> or <tt>:url</tt> to override the defaults.
<add> # E.g. turn <tt>params[:post]</tt> into <tt>params[:article]</tt>.
<add> # * <tt>:authenticity_token</tt> - Authenticity token to use in the form.
<add> # Override with a custom authenticity token or pass <tt>false</tt> to
<add> # skip the authenticity token field altogether.
<add> # Useful when submitting to an external resource like a payment gateway
<add> # that might limit the valid fields.
<add> # Remote forms may omit the embedded authenticity token by setting
<add> # <tt>config.action_view.embed_authenticity_token_in_remote_forms = false</tt>.
<add> # This is helpful when fragment-caching the form. Remote forms
<add> # get the authenticity token from the <tt>meta</tt> tag, so embedding is
<add> # unnecessary unless you support browsers without JavaScript.
<add> # * <tt>:local</tt> - By default form submits are remote and unobstrusive XHRs.
<add> # Disable remote submits with <tt>local: true</tt>.
<add> # * <tt>:skip_enforcing_utf8</tt> - By default a hidden field named +utf8+
<add> # is output to enforce UTF-8 submits. Set to true to skip the field.
<add> # * <tt>:builder</tt> - Override the object used to build the form.
<add> # * <tt>:id</tt> - Optional HTML id attribute.
<add> # * <tt>:class</tt> - Optional HTML class attribute.
<add> # * <tt>:data</tt> - Optional HTML data attributes.
<add> # * <tt>:html</tt> - Other optional HTML attributes for the form tag.
<add> #
<add> # === Examples
<add> #
<add> # When not passing a block, +form_with+ just generates an opening form tag.
<add> #
<add> # <%= form_with(model: @post, url: super_posts_path) %>
<add> # <%= form_with(model: @post, scope: :article) %>
<add> # <%= form_with(model: @post, format: :json) %>
<add> # <%= form_with(model: @post, authenticity_token: false) %> # Disables the token.
<add> #
<add> # For namespaced routes, like +admin_post_url+:
<add> #
<add> # <%= form_with(model: [ :admin, @post ]) do |form| %>
<add> # ...
<add> # <% end %>
<add> #
<add> # If your resource has associations defined, for example, you want to add comments
<add> # to the document given that the routes are set correctly:
<add> #
<add> # <%= form_with(model: [ @document, Comment.new ]) do |form| %>
<add> # ...
<add> # <% end %>
<add> #
<add> # Where <tt>@document = Document.find(params[:id])</tt>.
<add> #
<add> # === Mixing with other form helpers
<add> #
<add> # While +form_with+ uses a FormBuilder object it's possible to mix and
<add> # match the stand-alone FormHelper methods and methods
<add> # from FormTagHelper:
<add> #
<add> # <%= form_with scope: :person do |form| %>
<add> # <%= form.text_field :first_name %>
<add> # <%= form.text_field :last_name %>
<add> #
<add> # <%= text_area :person, :biography %>
<add> # <%= check_box_tag "person[admin]", "1", @person.company.admin? %>
<add> #
<add> # <%= form.submit %>
<add> # <% end %>
<add> #
<add> # Same goes for the methods in FormOptionHelper and DateHelper designed
<add> # to work with an object as a base, like
<add> # FormOptionHelper#collection_select and DateHelper#datetime_select.
<add> #
<add> # === Setting the method
<add> #
<add> # You can force the form to use the full array of HTTP verbs by setting
<add> #
<add> # method: (:get|:post|:patch|:put|:delete)
<add> #
<add> # in the options hash. If the verb is not GET or POST, which are natively
<add> # supported by HTML forms, the form will be set to POST and a hidden input
<add> # called _method will carry the intended verb for the server to interpret.
<add> #
<add> # === Setting HTML options
<add> #
<add> # You can set data attributes directly in a data hash, but HTML options
<add> # besides id and class must be wrapped in an HTML key:
<add> #
<add> # <%= form_with(model: @post, data: { behavior: "autosave" }, html: { name: "go" }) do |form| %>
<add> # ...
<add> # <% end %>
<add> #
<add> # generates
<add> #
<add> # <form action="/posts/123" method="post" data-behavior="autosave" name="go">
<add> # <input name="_method" type="hidden" value="patch" />
<add> # ...
<add> # </form>
<add> #
<add> # === Removing hidden model id's
<add> #
<add> # The +form_with+ method automatically includes the model id as a hidden field in the form.
<add> # This is used to maintain the correlation between the form data and its associated model.
<add> # Some ORM systems do not use IDs on nested models so in this case you want to be able
<add> # to disable the hidden id.
<add> #
<add> # In the following example the Post model has many Comments stored within it in a NoSQL database,
<add> # thus there is no primary key for comments.
<add> #
<add> # <%= form_with(model: @post) do |form| %>
<add> # <%= form.fields(:comments, skip_id: true) do |fields| %>
<add> # ...
<add> # <% end %>
<add> # <% end %>
<add> #
<add> # === Customized form builders
<add> #
<add> # You can also build forms using a customized FormBuilder class. Subclass
<add> # FormBuilder and override or define some more helpers, then use your
<add> # custom builder. For example, let's say you made a helper to
<add> # automatically add labels to form inputs.
<add> #
<add> # <%= form_with model: @person, url: { action: "create" }, builder: LabellingFormBuilder do |form| %>
<add> # <%= form.text_field :first_name %>
<add> # <%= form.text_field :last_name %>
<add> # <%= form.text_area :biography %>
<add> # <%= form.check_box :admin %>
<add> # <%= form.submit %>
<add> # <% end %>
<add> #
<add> # In this case, if you use:
<add> #
<add> # <%= render form %>
<add> #
<add> # The rendered template is <tt>people/_labelling_form</tt> and the local
<add> # variable referencing the form builder is called
<add> # <tt>labelling_form</tt>.
<add> #
<add> # The custom FormBuilder class is automatically merged with the options
<add> # of a nested +fields+ call, unless it's explicitly set.
<add> #
<add> # In many cases you will want to wrap the above in another helper, so you
<add> # could do something like the following:
<add> #
<add> # def labelled_form_with(**options, &block)
<add> # form_with(**options.merge(builder: LabellingFormBuilder), &block)
<add> # end
<add> def form_with(model: nil, scope: nil, url: nil, format: nil, **options)
<add> if model
<add> url ||= polymorphic_path(model, format: format)
<add>
<add> model = model.last if model.is_a?(Array)
<add> scope ||= model_name_from_record_or_class(model).param_key
<add> end
<add>
<add> if block_given?
<add> builder = instantiate_builder(scope, model, options)
<add> output = capture(builder, &Proc.new)
<add> options[:multipart] ||= builder.multipart?
<add>
<add> html_options = html_options_for_form_with(url, model, options)
<add> form_tag_with_body(html_options, output)
<add> else
<add> html_options = html_options_for_form_with(url, model, options)
<add> form_tag_html(html_options)
<add> end
<add> end
<add>
<ide> # Creates a scope around a specific model object like form_for, but
<ide> # doesn't create the form tags themselves. This makes fields_for suitable
<ide> # for specifying additional model objects in the same form.
<ide> def fields_for(record_name, record_object = nil, options = {}, &block)
<ide> capture(builder, &block)
<ide> end
<ide>
<add> # Scopes input fields with either an explicit scope or model.
<add> # Like +form_with+ does with <tt>:scope</tt> or <tt>:model</tt>,
<add> # except it doesn't output the form tags.
<add> #
<add> # # Using a scope prefixes the input field names:
<add> # <%= fields :comment do |fields| %>
<add> # <%= fields.text_field :body %>
<add> # <% end %>
<add> # # => <input type="text" name="comment[body] id="comment_body">
<add> #
<add> # # Using a model infers the scope and assigns field values:
<add> # <%= fields model: Comment.new(body: "full bodied") do |fields| %<
<add> # <%= fields.text_field :body %>
<add> # <% end %>
<add> # # =>
<add> # <input type="text" name="comment[body] id="comment_body" value="full bodied">
<add> #
<add> # # Using +fields+ with +form_with+:
<add> # <%= form_with model: @post do |form| %>
<add> # <%= form.text_field :title %>
<add> #
<add> # <%= form.fields :comment do |fields| %>
<add> # <%= fields.text_field :body %>
<add> # <% end %>
<add> # <% end %>
<add> #
<add> # Much like +form_with+ a FormBuilder instance associated with the scope
<add> # or model is yielded, so any generated field names are prefixed with
<add> # either the passed scope or the scope inferred from the <tt>:model</tt>.
<add> #
<add> # === Mixing with other form helpers
<add> #
<add> # While +form_with+ uses a FormBuilder object it's possible to mix and
<add> # match the stand-alone FormHelper methods and methods
<add> # from FormTagHelper:
<add> #
<add> # <%= fields model: @comment do |fields| %>
<add> # <%= fields.text_field :body %>
<add> #
<add> # <%= text_area :commenter, :biography %>
<add> # <%= check_box_tag "comment[all_caps]", "1", @comment.commenter.hulk_mode? %>
<add> # <% end %>
<add> #
<add> # Same goes for the methods in FormOptionHelper and DateHelper designed
<add> # to work with an object as a base, like
<add> # FormOptionHelper#collection_select and DateHelper#datetime_select.
<add> def fields(scope = nil, model: nil, **options, &block)
<add> # TODO: Remove when ids and classes are no longer output by default.
<add> if model
<add> scope ||= model_name_from_record_or_class(model).param_key
<add> end
<add>
<add> builder = instantiate_builder(scope, model, options)
<add> capture(builder, &block)
<add> end
<add>
<ide> # Returns a label tag tailored for labelling an input field for a specified attribute (identified by +method+) on an object
<ide> # assigned to the template (identified by +object+). The text of label will default to the attribute name unless a translation
<ide> # is found in the current I18n locale (through helpers.label.<modelname>.<attribute>) or you specify it explicitly.
<ide> def range_field(object_name, method, options = {})
<ide> end
<ide>
<ide> private
<add> def html_options_for_form_with(url_for_options = nil, model = nil, html: {}, local: false,
<add> skip_enforcing_utf8: false, **options)
<add> html_options = options.except(:index, :include_id, :builder).merge(html)
<add> html_options[:method] ||= :patch if model.respond_to?(:persisted?) && model.persisted?
<add> html_options[:enforce_utf8] = !skip_enforcing_utf8
<add>
<add> html_options[:enctype] = "multipart/form-data" if html_options.delete(:multipart)
<add>
<add> # The following URL is unescaped, this is just a hash of options, and it is the
<add> # responsibility of the caller to escape all the values.
<add> html_options[:action] = url_for(url_for_options || {})
<add> html_options[:"accept-charset"] = "UTF-8"
<add> html_options[:"data-remote"] = true unless local
<add>
<add> if !local && !embed_authenticity_token_in_remote_forms &&
<add> html_options[:authenticity_token].blank?
<add> # The authenticity token is taken from the meta tag in this case
<add> html_options[:authenticity_token] = false
<add> elsif html_options[:authenticity_token] == true
<add> # Include the default authenticity_token, which is only generated when its set to nil,
<add> # but we needed the true value to override the default of no authenticity_token on data-remote.
<add> html_options[:authenticity_token] = nil
<add> end
<add>
<add> html_options.stringify_keys!
<add> end
<ide>
<ide> def instantiate_builder(record_name, record_object, options)
<ide> case record_name
<ide> def instantiate_builder(record_name, record_object, options)
<ide> object_name = record_name
<ide> else
<ide> object = record_name
<del> object_name = model_name_from_record_or_class(object).param_key
<add> object_name = model_name_from_record_or_class(object).param_key if object
<ide> end
<ide>
<ide> builder = options[:builder] || default_form_builder_class
<ide> class FormBuilder
<ide>
<ide> # The methods which wrap a form helper call.
<ide> class_attribute :field_helpers
<del> self.field_helpers = [:fields_for, :label, :text_field, :password_field,
<add> self.field_helpers = [:fields_for, :fields, :label, :text_field, :password_field,
<ide> :hidden_field, :file_field, :text_area, :check_box,
<ide> :radio_button, :color_field, :search_field,
<ide> :telephone_field, :phone_field, :date_field,
<ide> def initialize(object_name, object, template, options)
<ide> @nested_child_index = {}
<ide> @object_name, @object, @template, @options = object_name, object, template, options
<ide> @default_options = @options ? @options.slice(:index, :namespace) : {}
<add>
<add> convert_to_legacy_options(@options)
<add>
<ide> if @object_name.to_s.match(/\[\]$/)
<ide> if (object ||= @template.instance_variable_get("@#{Regexp.last_match.pre_match}")) && object.respond_to?(:to_param)
<ide> @auto_index = object.to_param
<ide> else
<ide> raise ArgumentError, "object[] naming but object param and @object var don't exist or don't respond to to_param: #{object.inspect}"
<ide> end
<ide> end
<add>
<ide> @multipart = nil
<ide> @index = options[:index] || options[:child_index]
<ide> end
<ide> def fields_for(record_name, record_object = nil, fields_options = {}, &block)
<ide> @template.fields_for(record_name, record_object, fields_options, &block)
<ide> end
<ide>
<add> # See the docs for the <tt>ActionView::FormHelper.fields</tt> helper method.
<add> def fields(scope = nil, model: nil, **options, &block)
<add> convert_to_legacy_options(options)
<add>
<add> fields_for(scope || model, model, **options, &block)
<add> end
<add>
<ide> # Returns a label tag tailored for labelling an input field for a specified attribute (identified by +method+) on an object
<ide> # assigned to the template (identified by +object+). The text of label will default to the attribute name unless a translation
<ide> # is found in the current I18n locale (through helpers.label.<modelname>.<attribute>) or you specify it explicitly.
<ide> def nested_child_index(name)
<ide> @nested_child_index[name] ||= -1
<ide> @nested_child_index[name] += 1
<ide> end
<add>
<add> def convert_to_legacy_options(options)
<add> if options.key?(:skip_id)
<add> options[:include_id] = !options.delete(:skip_id)
<add> end
<add>
<add> if options.key?(:local)
<add> options[:remote] = !options.delete(:local)
<add> end
<add> end
<ide> end
<ide> end
<ide>
<ide><path>actionview/test/template/form_helper/form_with_test.rb
<add>require "abstract_unit"
<add>require "controller/fake_models"
<add>
<add>class FormWithTest < ActionView::TestCase
<add> include RenderERBUtils
<add>end
<add>
<add>class FormWithActsLikeFormTagTest < FormWithTest
<add> tests ActionView::Helpers::FormTagHelper
<add>
<add> setup do
<add> @controller = BasicController.new
<add> end
<add>
<add> def hidden_fields(options = {})
<add> method = options[:method]
<add> skip_enforcing_utf8 = options.fetch(:skip_enforcing_utf8, false)
<add>
<add> "".tap do |txt|
<add> unless skip_enforcing_utf8
<add> txt << %{<input name="utf8" type="hidden" value="✓" />}
<add> end
<add>
<add> if method && !%w(get post).include?(method.to_s)
<add> txt << %{<input name="_method" type="hidden" value="#{method}" />}
<add> end
<add> end
<add> end
<add>
<add> def form_text(action = "http://www.example.com", local: false, **options)
<add> enctype, html_class, id, method = options.values_at(:enctype, :html_class, :id, :method)
<add>
<add> method = method.to_s == "get" ? "get" : "post"
<add>
<add> txt = %{<form accept-charset="UTF-8" action="#{action}"}
<add> txt << %{ enctype="multipart/form-data"} if enctype
<add> txt << %{ data-remote="true"} unless local
<add> txt << %{ class="#{html_class}"} if html_class
<add> txt << %{ id="#{id}"} if id
<add> txt << %{ method="#{method}">}
<add> end
<add>
<add> def whole_form(action = "http://www.example.com", options = {})
<add> out = form_text(action, options) + hidden_fields(options)
<add>
<add> if block_given?
<add> out << yield << "</form>"
<add> end
<add>
<add> out
<add> end
<add>
<add> def url_for(options)
<add> if options.is_a?(Hash)
<add> "http://www.example.com"
<add> else
<add> super
<add> end
<add> end
<add>
<add> def test_form_with_multipart
<add> actual = form_with(multipart: true)
<add>
<add> expected = whole_form("http://www.example.com", enctype: true)
<add> assert_dom_equal expected, actual
<add> end
<add>
<add> def test_form_with_with_method_patch
<add> actual = form_with(method: :patch)
<add>
<add> expected = whole_form("http://www.example.com", method: :patch)
<add> assert_dom_equal expected, actual
<add> end
<add>
<add> def test_form_with_with_method_put
<add> actual = form_with(method: :put)
<add>
<add> expected = whole_form("http://www.example.com", method: :put)
<add> assert_dom_equal expected, actual
<add> end
<add>
<add> def test_form_with_with_method_delete
<add> actual = form_with(method: :delete)
<add>
<add> expected = whole_form("http://www.example.com", method: :delete)
<add> assert_dom_equal expected, actual
<add> end
<add>
<add> def test_form_with_with_local_true
<add> actual = form_with(local: true)
<add>
<add> expected = whole_form("http://www.example.com", local: true)
<add> assert_dom_equal expected, actual
<add> end
<add>
<add> def test_form_with_skip_enforcing_utf8_true
<add> actual = form_with(skip_enforcing_utf8: true)
<add> expected = whole_form("http://www.example.com", skip_enforcing_utf8: true)
<add> assert_dom_equal expected, actual
<add> assert actual.html_safe?
<add> end
<add>
<add> def test_form_with_with_block_in_erb
<add> output_buffer = render_erb("<%= form_with(url: 'http://www.example.com') do %>Hello world!<% end %>")
<add>
<add> expected = whole_form { "Hello world!" }
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_form_with_with_block_and_method_in_erb
<add> output_buffer = render_erb("<%= form_with(url: 'http://www.example.com', method: :put) do %>Hello world!<% end %>")
<add>
<add> expected = whole_form("http://www.example.com", method: "put") do
<add> "Hello world!"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>end
<add>
<add>class FormWithActsLikeFormForTest < FormWithTest
<add> def form_with(*)
<add> @output_buffer = super
<add> end
<add>
<add> teardown do
<add> I18n.backend.reload!
<add> end
<add>
<add> setup do
<add> # Create "label" locale for testing I18n label helpers
<add> I18n.backend.store_translations "label",
<add> activemodel: {
<add> attributes: {
<add> post: {
<add> cost: "Total cost"
<add> },
<add> "post/language": {
<add> spanish: "Espanol"
<add> }
<add> }
<add> },
<add> helpers: {
<add> label: {
<add> post: {
<add> body: "Write entire text here",
<add> color: {
<add> red: "Rojo"
<add> },
<add> comments: {
<add> body: "Write body here"
<add> }
<add> },
<add> tag: {
<add> value: "Tag"
<add> },
<add> post_delegate: {
<add> title: "Delegate model_name title"
<add> }
<add> }
<add> }
<add>
<add> # Create "submit" locale for testing I18n submit helpers
<add> I18n.backend.store_translations "submit",
<add> helpers: {
<add> submit: {
<add> create: "Create %{model}",
<add> update: "Confirm %{model} changes",
<add> submit: "Save changes",
<add> another_post: {
<add> update: "Update your %{model}"
<add> }
<add> }
<add> }
<add>
<add> I18n.backend.store_translations "placeholder",
<add> activemodel: {
<add> attributes: {
<add> post: {
<add> cost: "Total cost"
<add> },
<add> "post/cost": {
<add> uk: "Pounds"
<add> }
<add> }
<add> },
<add> helpers: {
<add> placeholder: {
<add> post: {
<add> title: "What is this about?",
<add> written_on: {
<add> spanish: "Escrito en"
<add> },
<add> comments: {
<add> body: "Write body here"
<add> }
<add> },
<add> post_delegate: {
<add> title: "Delegate model_name title"
<add> },
<add> tag: {
<add> value: "Tag"
<add> }
<add> }
<add> }
<add>
<add> @post = Post.new
<add> @comment = Comment.new
<add> def @post.errors()
<add> Class.new {
<add> def [](field); field == "author_name" ? ["can't be empty"] : [] end
<add> def empty?() false end
<add> def count() 1 end
<add> def full_messages() ["Author name can't be empty"] end
<add> }.new
<add> end
<add> def @post.to_key; [123]; end
<add> def @post.id; 0; end
<add> def @post.id_before_type_cast; "omg"; end
<add> def @post.id_came_from_user?; true; end
<add> def @post.to_param; "123"; end
<add>
<add> @post.persisted = true
<add> @post.title = "Hello World"
<add> @post.author_name = ""
<add> @post.body = "Back to the hill and over it again!"
<add> @post.secret = 1
<add> @post.written_on = Date.new(2004, 6, 15)
<add>
<add> @post.comments = []
<add> @post.comments << @comment
<add>
<add> @post.tags = []
<add> @post.tags << Tag.new
<add>
<add> @post_delegator = PostDelegator.new
<add>
<add> @post_delegator.title = "Hello World"
<add>
<add> @car = Car.new("#000FFF")
<add> end
<add>
<add> Routes = ActionDispatch::Routing::RouteSet.new
<add> Routes.draw do
<add> resources :posts do
<add> resources :comments
<add> end
<add>
<add> namespace :admin do
<add> resources :posts do
<add> resources :comments
<add> end
<add> end
<add>
<add> get "/foo", to: "controller#action"
<add> root to: "main#index"
<add> end
<add>
<add> def _routes
<add> Routes
<add> end
<add>
<add> include Routes.url_helpers
<add>
<add> def url_for(object)
<add> @url_for_options = object
<add>
<add> if object.is_a?(Hash) && object[:use_route].blank? && object[:controller].blank?
<add> object.merge!(controller: "main", action: "index")
<add> end
<add>
<add> super
<add> end
<add>
<add> def test_form_with_requires_arguments
<add> error = assert_raises(ArgumentError) do
<add> form_for(nil, html: { id: "create-post" }) do
<add> end
<add> end
<add> assert_equal "First argument in form cannot contain nil or be empty", error.message
<add>
<add> error = assert_raises(ArgumentError) do
<add> form_for([nil, nil], html: { id: "create-post" }) do
<add> end
<add> end
<add> assert_equal "First argument in form cannot contain nil or be empty", error.message
<add> end
<add>
<add> def test_form_with
<add> form_with(model: @post, id: "create-post") do |f|
<add> concat f.label(:title) { "The Title" }
<add> concat f.text_field(:title)
<add> concat f.text_area(:body)
<add> concat f.check_box(:secret)
<add> concat f.submit("Create post")
<add> concat f.button("Create post")
<add> concat f.button {
<add> concat content_tag(:span, "Create post")
<add> }
<add> end
<add>
<add> expected = whole_form("/posts/123", "create-post", method: "patch") do
<add> "<label for='post_title'>The Title</label>" +
<add> "<input name='post[title]' type='text' id='post_title' value='Hello World' />" +
<add> "<textarea name='post[body]' id='post_body'>\nBack to the hill and over it again!</textarea>" +
<add> "<input name='post[secret]' type='hidden' value='0' />" +
<add> "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" +
<add> "<input name='commit' data-disable-with='Create post' type='submit' value='Create post' />" +
<add> "<button name='button' type='submit'>Create post</button>" +
<add> "<button name='button' type='submit'><span>Create post</span></button>"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_form_with_with_collection_radio_buttons
<add> post = Post.new
<add> def post.active; false; end
<add> form_with(model: post) do |f|
<add> concat f.collection_radio_buttons(:active, [true, false], :to_s, :to_s)
<add> end
<add>
<add> expected = whole_form("/posts") do
<add> "<input type='hidden' name='post[active]' value='' />" +
<add> "<input id='post_active_true' name='post[active]' type='radio' value='true' />" +
<add> "<label for='post_active_true'>true</label>" +
<add> "<input checked='checked' id='post_active_false' name='post[active]' type='radio' value='false' />" +
<add> "<label for='post_active_false'>false</label>"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_form_with_with_collection_radio_buttons_with_custom_builder_block
<add> post = Post.new
<add> def post.active; false; end
<add>
<add> form_with(model: post) do |f|
<add> rendered_radio_buttons = f.collection_radio_buttons(:active, [true, false], :to_s, :to_s) do |b|
<add> b.label { b.radio_button + b.text }
<add> end
<add> concat rendered_radio_buttons
<add> end
<add>
<add> expected = whole_form("/posts") do
<add> "<input type='hidden' name='post[active]' value='' />" +
<add> "<label for='post_active_true'>" +
<add> "<input id='post_active_true' name='post[active]' type='radio' value='true' />" +
<add> "true</label>" +
<add> "<label for='post_active_false'>" +
<add> "<input checked='checked' id='post_active_false' name='post[active]' type='radio' value='false' />" +
<add> "false</label>"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_form_with_with_collection_radio_buttons_with_custom_builder_block_does_not_leak_the_template
<add> post = Post.new
<add> def post.active; false; end
<add> def post.id; 1; end
<add>
<add> form_with(model: post) do |f|
<add> rendered_radio_buttons = f.collection_radio_buttons(:active, [true, false], :to_s, :to_s) do |b|
<add> b.label { b.radio_button + b.text }
<add> end
<add> concat rendered_radio_buttons
<add> concat f.hidden_field :id
<add> end
<add>
<add> expected = whole_form("/posts") do
<add> "<input type='hidden' name='post[active]' value='' />" +
<add> "<label for='post_active_true'>" +
<add> "<input id='post_active_true' name='post[active]' type='radio' value='true' />" +
<add> "true</label>" +
<add> "<label for='post_active_false'>" +
<add> "<input checked='checked' id='post_active_false' name='post[active]' type='radio' value='false' />" +
<add> "false</label>" +
<add> "<input id='post_id' name='post[id]' type='hidden' value='1' />"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_form_with_with_index_and_with_collection_radio_buttons
<add> post = Post.new
<add> def post.active; false; end
<add>
<add> form_with(model: post, index: "1") do |f|
<add> concat f.collection_radio_buttons(:active, [true, false], :to_s, :to_s)
<add> end
<add>
<add> expected = whole_form("/posts") do
<add> "<input type='hidden' name='post[1][active]' value='' />" +
<add> "<input id='post_1_active_true' name='post[1][active]' type='radio' value='true' />" +
<add> "<label for='post_1_active_true'>true</label>" +
<add> "<input checked='checked' id='post_1_active_false' name='post[1][active]' type='radio' value='false' />" +
<add> "<label for='post_1_active_false'>false</label>"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_form_with_with_collection_check_boxes
<add> post = Post.new
<add> def post.tag_ids; [1, 3]; end
<add> collection = (1..3).map { |i| [i, "Tag #{i}"] }
<add> form_with(model: post) do |f|
<add> concat f.collection_check_boxes(:tag_ids, collection, :first, :last)
<add> end
<add>
<add> expected = whole_form("/posts") do
<add> "<input name='post[tag_ids][]' type='hidden' value='' />" +
<add> "<input checked='checked' id='post_tag_ids_1' name='post[tag_ids][]' type='checkbox' value='1' />" +
<add> "<label for='post_tag_ids_1'>Tag 1</label>" +
<add> "<input id='post_tag_ids_2' name='post[tag_ids][]' type='checkbox' value='2' />" +
<add> "<label for='post_tag_ids_2'>Tag 2</label>" +
<add> "<input checked='checked' id='post_tag_ids_3' name='post[tag_ids][]' type='checkbox' value='3' />" +
<add> "<label for='post_tag_ids_3'>Tag 3</label>"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_form_with_with_collection_check_boxes_with_custom_builder_block
<add> post = Post.new
<add> def post.tag_ids; [1, 3]; end
<add> collection = (1..3).map { |i| [i, "Tag #{i}"] }
<add> form_with(model: post) do |f|
<add> rendered_check_boxes = f.collection_check_boxes(:tag_ids, collection, :first, :last) do |b|
<add> b.label { b.check_box + b.text }
<add> end
<add> concat rendered_check_boxes
<add> end
<add>
<add> expected = whole_form("/posts") do
<add> "<input name='post[tag_ids][]' type='hidden' value='' />" +
<add> "<label for='post_tag_ids_1'>" +
<add> "<input checked='checked' id='post_tag_ids_1' name='post[tag_ids][]' type='checkbox' value='1' />" +
<add> "Tag 1</label>" +
<add> "<label for='post_tag_ids_2'>" +
<add> "<input id='post_tag_ids_2' name='post[tag_ids][]' type='checkbox' value='2' />" +
<add> "Tag 2</label>" +
<add> "<label for='post_tag_ids_3'>" +
<add> "<input checked='checked' id='post_tag_ids_3' name='post[tag_ids][]' type='checkbox' value='3' />" +
<add> "Tag 3</label>"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_form_with_with_collection_check_boxes_with_custom_builder_block_does_not_leak_the_template
<add> post = Post.new
<add> def post.tag_ids; [1, 3]; end
<add> def post.id; 1; end
<add> collection = (1..3).map { |i| [i, "Tag #{i}"] }
<add>
<add> form_with(model: post) do |f|
<add> rendered_check_boxes = f.collection_check_boxes(:tag_ids, collection, :first, :last) do |b|
<add> b.label { b.check_box + b.text }
<add> end
<add> concat rendered_check_boxes
<add> concat f.hidden_field :id
<add> end
<add>
<add> expected = whole_form("/posts") do
<add> "<input name='post[tag_ids][]' type='hidden' value='' />" +
<add> "<label for='post_tag_ids_1'>" +
<add> "<input checked='checked' id='post_tag_ids_1' name='post[tag_ids][]' type='checkbox' value='1' />" +
<add> "Tag 1</label>" +
<add> "<label for='post_tag_ids_2'>" +
<add> "<input id='post_tag_ids_2' name='post[tag_ids][]' type='checkbox' value='2' />" +
<add> "Tag 2</label>" +
<add> "<label for='post_tag_ids_3'>" +
<add> "<input checked='checked' id='post_tag_ids_3' name='post[tag_ids][]' type='checkbox' value='3' />" +
<add> "Tag 3</label>" +
<add> "<input id='post_id' name='post[id]' type='hidden' value='1' />"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_form_with_index_and_with_collection_check_boxes
<add> post = Post.new
<add> def post.tag_ids; [1]; end
<add> collection = [[1, "Tag 1"]]
<add>
<add> form_with(model: post, index: "1") do |f|
<add> concat f.collection_check_boxes(:tag_ids, collection, :first, :last)
<add> end
<add>
<add> expected = whole_form("/posts") do
<add> "<input name='post[1][tag_ids][]' type='hidden' value='' />" +
<add> "<input checked='checked' id='post_1_tag_ids_1' name='post[1][tag_ids][]' type='checkbox' value='1' />" +
<add> "<label for='post_1_tag_ids_1'>Tag 1</label>"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_form_with_with_file_field_generate_multipart
<add> Post.send :attr_accessor, :file
<add>
<add> form_with(model: @post, id: "create-post") do |f|
<add> concat f.file_field(:file)
<add> end
<add>
<add> expected = whole_form("/posts/123", "create-post", method: "patch", multipart: true) do
<add> "<input name='post[file]' type='file' id='post_file' />"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_fields_with_file_field_generate_multipart
<add> Comment.send :attr_accessor, :file
<add>
<add> form_with(model: @post) do |f|
<add> concat f.fields(:comment, model: @post) { |c|
<add> concat c.file_field(:file)
<add> }
<add> end
<add>
<add> expected = whole_form("/posts/123", method: "patch", multipart: true) do
<add> "<input name='post[comment][file]' type='file' id='post_comment_file' />"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_form_with_with_format
<add> form_with(model: @post, format: :json, id: "edit_post_123", class: "edit_post") do |f|
<add> concat f.label(:title)
<add> end
<add>
<add> expected = whole_form("/posts/123.json", "edit_post_123", "edit_post", method: "patch") do
<add> "<label for='post_title'>Title</label>"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_form_with_with_format_and_url
<add> form_with(model: @post, format: :json, url: "/") do |f|
<add> concat f.label(:title)
<add> end
<add>
<add> expected = whole_form("/", method: "patch") do
<add> "<label for='post_title'>Title</label>"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_form_with_with_model_using_relative_model_naming
<add> blog_post = Blog::Post.new("And his name will be forty and four.", 44)
<add>
<add> form_with(model: blog_post) do |f|
<add> concat f.text_field :title
<add> concat f.submit("Edit post")
<add> end
<add>
<add> expected = whole_form("/posts/44", method: "patch") do
<add> "<input name='post[title]' type='text' id='post_title' value='And his name will be forty and four.' />" +
<add> "<input name='commit' data-disable-with='Edit post' type='submit' value='Edit post' />"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_form_with_with_symbol_scope
<add> form_with(model: @post, scope: "other_name", id: "create-post") do |f|
<add> concat f.label(:title, class: "post_title")
<add> concat f.text_field(:title)
<add> concat f.text_area(:body)
<add> concat f.check_box(:secret)
<add> concat f.submit("Create post")
<add> end
<add>
<add> expected = whole_form("/posts/123", "create-post", method: "patch") do
<add> "<label for='other_name_title' class='post_title'>Title</label>" +
<add> "<input name='other_name[title]' id='other_name_title' value='Hello World' type='text' />" +
<add> "<textarea name='other_name[body]' id='other_name_body'>\nBack to the hill and over it again!</textarea>" +
<add> "<input name='other_name[secret]' value='0' type='hidden' />" +
<add> "<input name='other_name[secret]' checked='checked' id='other_name_secret' value='1' type='checkbox' />" +
<add> "<input name='commit' value='Create post' data-disable-with='Create post' type='submit' />"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_form_tags_do_not_call_private_properties_on_form_object
<add> obj = Class.new do
<add> private def private_property
<add> raise "This method should not be called."
<add> end
<add> end.new
<add>
<add> form_with(model: obj, scope: "other_name", url: "/", id: "edit-other-name") do |f|
<add> assert_raise(NoMethodError) { f.hidden_field(:private_property) }
<add> end
<add> end
<add>
<add> def test_form_with_with_method_as_part_of_html_options
<add> form_with(model: @post, url: "/", id: "create-post", html: { method: :delete }) do |f|
<add> concat f.text_field(:title)
<add> concat f.text_area(:body)
<add> concat f.check_box(:secret)
<add> end
<add>
<add> expected = whole_form("/", "create-post", method: "delete") do
<add> "<input name='post[title]' type='text' id='post_title' value='Hello World' />" +
<add> "<textarea name='post[body]' id='post_body'>\nBack to the hill and over it again!</textarea>" +
<add> "<input name='post[secret]' type='hidden' value='0' />" +
<add> "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_form_with_with_method
<add> form_with(model: @post, url: "/", method: :delete, id: "create-post") do |f|
<add> concat f.text_field(:title)
<add> concat f.text_area(:body)
<add> concat f.check_box(:secret)
<add> end
<add>
<add> expected = whole_form("/", "create-post", method: "delete") do
<add> "<input name='post[title]' type='text' id='post_title' value='Hello World' />" +
<add> "<textarea name='post[body]' id='post_body'>\nBack to the hill and over it again!</textarea>" +
<add> "<input name='post[secret]' type='hidden' value='0' />" +
<add> "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_form_with_with_search_field
<add> # Test case for bug which would emit an "object" attribute
<add> # when used with form_for using a search_field form helper
<add> form_with(model: Post.new, url: "/search", id: "search-post", method: :get) do |f|
<add> concat f.search_field(:title)
<add> end
<add>
<add> expected = whole_form("/search", "search-post", method: "get") do
<add> "<input name='post[title]' type='search' id='post_title' />"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_form_with_enables_remote_by_default
<add> form_with(model: @post, url: "/", id: "create-post", method: :patch) do |f|
<add> concat f.text_field(:title)
<add> concat f.text_area(:body)
<add> concat f.check_box(:secret)
<add> end
<add>
<add> expected = whole_form("/", "create-post", method: "patch") do
<add> "<input name='post[title]' type='text' id='post_title' value='Hello World' />" +
<add> "<textarea name='post[body]' id='post_body'>\nBack to the hill and over it again!</textarea>" +
<add> "<input name='post[secret]' type='hidden' value='0' />" +
<add> "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_form_with_skip_enforcing_utf8_true
<add> form_with(scope: :post, skip_enforcing_utf8: true) do |f|
<add> concat f.text_field(:title)
<add> end
<add>
<add> expected = whole_form("/", skip_enforcing_utf8: true) do
<add> "<input name='post[title]' type='text' id='post_title' value='Hello World' />"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_form_with_skip_enforcing_utf8_false
<add> form_with(scope: :post, skip_enforcing_utf8: false) do |f|
<add> concat f.text_field(:title)
<add> end
<add>
<add> expected = whole_form("/", skip_enforcing_utf8: false) do
<add> "<input name='post[title]' type='text' id='post_title' value='Hello World' />"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_form_with_without_object
<add> form_with(scope: :post, id: "create-post") do |f|
<add> concat f.text_field(:title)
<add> concat f.text_area(:body)
<add> concat f.check_box(:secret)
<add> end
<add>
<add> expected = whole_form("/", "create-post") do
<add> "<input name='post[title]' type='text' id='post_title' value='Hello World' />" +
<add> "<textarea name='post[body]' id='post_body'>\nBack to the hill and over it again!</textarea>" +
<add> "<input name='post[secret]' type='hidden' value='0' />" +
<add> "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_form_with_with_index
<add> form_with(model: @post, scope: "post[]") do |f|
<add> concat f.label(:title)
<add> concat f.text_field(:title)
<add> concat f.text_area(:body)
<add> concat f.check_box(:secret)
<add> end
<add>
<add> expected = whole_form("/posts/123", method: "patch") do
<add> "<label for='post_123_title'>Title</label>" +
<add> "<input name='post[123][title]' type='text' id='post_123_title' value='Hello World' />" +
<add> "<textarea name='post[123][body]' id='post_123_body'>\nBack to the hill and over it again!</textarea>" +
<add> "<input name='post[123][secret]' type='hidden' value='0' />" +
<add> "<input name='post[123][secret]' checked='checked' type='checkbox' id='post_123_secret' value='1' />"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_form_with_with_nil_index_option_override
<add> form_with(model: @post, scope: "post[]", index: nil) do |f|
<add> concat f.text_field(:title)
<add> concat f.text_area(:body)
<add> concat f.check_box(:secret)
<add> end
<add>
<add> expected = whole_form("/posts/123", method: "patch") do
<add> "<input name='post[][title]' type='text' id='post__title' value='Hello World' />" +
<add> "<textarea name='post[][body]' id='post__body'>\nBack to the hill and over it again!</textarea>" +
<add> "<input name='post[][secret]' type='hidden' value='0' />" +
<add> "<input name='post[][secret]' checked='checked' type='checkbox' id='post__secret' value='1' />"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_form_with_label_error_wrapping
<add> form_with(model: @post) do |f|
<add> concat f.label(:author_name, class: "label")
<add> concat f.text_field(:author_name)
<add> concat f.submit("Create post")
<add> end
<add>
<add> expected = whole_form("/posts/123", method: "patch") do
<add> "<div class='field_with_errors'><label for='post_author_name' class='label'>Author name</label></div>" +
<add> "<div class='field_with_errors'><input name='post[author_name]' type='text' id='post_author_name' value='' /></div>" +
<add> "<input name='commit' data-disable-with='Create post' type='submit' value='Create post' />"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_form_with_label_error_wrapping_without_conventional_instance_variable
<add> post = remove_instance_variable :@post
<add>
<add> form_with(model: post) do |f|
<add> concat f.label(:author_name, class: "label")
<add> concat f.text_field(:author_name)
<add> concat f.submit("Create post")
<add> end
<add>
<add> expected = whole_form("/posts/123", method: "patch") do
<add> "<div class='field_with_errors'><label for='post_author_name' class='label'>Author name</label></div>" +
<add> "<div class='field_with_errors'><input name='post[author_name]' type='text' id='post_author_name' value='' /></div>" +
<add> "<input name='commit' data-disable-with='Create post' type='submit' value='Create post' />"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_form_with_label_error_wrapping_block_and_non_block_versions
<add> form_with(model: @post) do |f|
<add> concat f.label(:author_name, "Name", class: "label")
<add> concat f.label(:author_name, class: "label") { "Name" }
<add> end
<add>
<add> expected = whole_form("/posts/123", method: "patch") do
<add> "<div class='field_with_errors'><label for='post_author_name' class='label'>Name</label></div>" +
<add> "<div class='field_with_errors'><label for='post_author_name' class='label'>Name</label></div>"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_form_with_with_namespace
<add> skip "Do namespaces still make sense?"
<add> form_for(@post, namespace: "namespace") do |f|
<add> concat f.text_field(:title)
<add> concat f.text_area(:body)
<add> concat f.check_box(:secret)
<add> end
<add>
<add> expected = whole_form("/posts/123", "namespace_edit_post_123", "edit_post", method: "patch") do
<add> "<input name='post[title]' type='text' id='namespace_post_title' value='Hello World' />" +
<add> "<textarea name='post[body]' id='namespace_post_body'>\nBack to the hill and over it again!</textarea>" +
<add> "<input name='post[secret]' type='hidden' value='0' />" +
<add> "<input name='post[secret]' checked='checked' type='checkbox' id='namespace_post_secret' value='1' />"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_submit_with_object_as_new_record_and_locale_strings
<add> with_locale :submit do
<add> @post.persisted = false
<add> @post.stub(:to_key, nil) do
<add> form_with(model: @post) do |f|
<add> concat f.submit
<add> end
<add>
<add> expected = whole_form("/posts") do
<add> "<input name='commit' data-disable-with='Create Post' type='submit' value='Create Post' />"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add> end
<add> end
<add>
<add> def test_submit_with_object_as_existing_record_and_locale_strings
<add> with_locale :submit do
<add> form_with(model: @post) do |f|
<add> concat f.submit
<add> end
<add>
<add> expected = whole_form("/posts/123", method: "patch") do
<add> "<input name='commit' data-disable-with='Confirm Post changes' type='submit' value='Confirm Post changes' />"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add> end
<add>
<add> def test_submit_without_object_and_locale_strings
<add> with_locale :submit do
<add> form_with(scope: :post) do |f|
<add> concat f.submit class: "extra"
<add> end
<add>
<add> expected = whole_form do
<add> "<input name='commit' class='extra' data-disable-with='Save changes' type='submit' value='Save changes' />"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add> end
<add>
<add> def test_submit_with_object_and_nested_lookup
<add> with_locale :submit do
<add> form_with(model: @post, scope: :another_post) do |f|
<add> concat f.submit
<add> end
<add>
<add> expected = whole_form("/posts/123", method: "patch") do
<add> "<input name='commit' data-disable-with='Update your Post' type='submit' value='Update your Post' />"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add> end
<add>
<add> def test_nested_fields
<add> @comment.body = "Hello World"
<add> form_with(model: @post) do |f|
<add> concat f.fields(model: @comment) { |c|
<add> concat c.text_field(:body)
<add> }
<add> end
<add>
<add> expected = whole_form("/posts/123", method: "patch") do
<add> "<input name='post[comment][body]' type='text' id='post_comment_body' value='Hello World' />"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_deep_nested_fields
<add> @comment.save
<add> form_with(scope: :posts) do |f|
<add> f.fields("post[]", model: @post) do |f2|
<add> f2.text_field(:id)
<add> @post.comments.each do |comment|
<add> concat f2.fields("comment[]", model: comment) { |c|
<add> concat c.text_field(:name)
<add> }
<add> end
<add> end
<add> end
<add>
<add> expected = whole_form do
<add> "<input name='posts[post][0][comment][1][name]' type='text' id='posts_post_0_comment_1_name' value='comment #1' />"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_nested_fields_with_nested_collections
<add> form_with(model: @post, scope: "post[]") do |f|
<add> concat f.text_field(:title)
<add> concat f.fields("comment[]", model: @comment) { |c|
<add> concat c.text_field(:name)
<add> }
<add> end
<add>
<add> expected = whole_form("/posts/123", method: "patch") do
<add> "<input name='post[123][title]' type='text' id='post_123_title' value='Hello World' />" +
<add> "<input name='post[123][comment][][name]' type='text' id='post_123_comment__name' value='new comment' />"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_nested_fields_with_index_and_parent_fields
<add> form_with(model: @post, index: 1) do |c|
<add> concat c.text_field(:title)
<add> concat c.fields("comment", model: @comment, index: 1) { |r|
<add> concat r.text_field(:name)
<add> }
<add> end
<add>
<add> expected = whole_form("/posts/123", method: "patch") do
<add> "<input name='post[1][title]' type='text' id='post_1_title' value='Hello World' />" +
<add> "<input name='post[1][comment][1][name]' type='text' id='post_1_comment_1_name' value='new comment' />"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_form_with_with_index_and_nested_fields
<add> output_buffer = form_with(model: @post, index: 1) do |f|
<add> concat f.fields(:comment, model: @post) { |c|
<add> concat c.text_field(:title)
<add> }
<add> end
<add>
<add> expected = whole_form("/posts/123", method: "patch") do
<add> "<input name='post[1][comment][title]' type='text' id='post_1_comment_title' value='Hello World' />"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_nested_fields_with_index_on_both
<add> form_with(model: @post, index: 1) do |f|
<add> concat f.fields(:comment, model: @post, index: 5) { |c|
<add> concat c.text_field(:title)
<add> }
<add> end
<add>
<add> expected = whole_form("/posts/123", method: "patch") do
<add> "<input name='post[1][comment][5][title]' type='text' id='post_1_comment_5_title' value='Hello World' />"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_nested_fields_with_auto_index
<add> form_with(model: @post, scope: "post[]") do |f|
<add> concat f.fields(:comment, model: @post) { |c|
<add> concat c.text_field(:title)
<add> }
<add> end
<add>
<add> expected = whole_form("/posts/123", method: "patch") do
<add> "<input name='post[123][comment][title]' type='text' id='post_123_comment_title' value='Hello World' />"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_nested_fields_with_index_radio_button
<add> form_with(model: @post) do |f|
<add> concat f.fields(:comment, model: @post, index: 5) { |c|
<add> concat c.radio_button(:title, "hello")
<add> }
<add> end
<add>
<add> expected = whole_form("/posts/123", method: "patch") do
<add> "<input name='post[comment][5][title]' type='radio' id='post_comment_5_title_hello' value='hello' />"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_nested_fields_with_auto_index_on_both
<add> form_with(model: @post, scope: "post[]") do |f|
<add> concat f.fields("comment[]", model: @post) { |c|
<add> concat c.text_field(:title)
<add> }
<add> end
<add>
<add> expected = whole_form("/posts/123", method: "patch") do
<add> "<input name='post[123][comment][123][title]' type='text' id='post_123_comment_123_title' value='Hello World' />"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_nested_fields_with_index_and_auto_index
<add> output_buffer = form_with(model: @post, scope: "post[]") do |f|
<add> concat f.fields(:comment, model: @post, index: 5) { |c|
<add> concat c.text_field(:title)
<add> }
<add> end
<add>
<add> output_buffer << form_with(model: @post, index: 1) do |f|
<add> concat f.fields("comment[]", model: @post) { |c|
<add> concat c.text_field(:title)
<add> }
<add> end
<add>
<add> expected = whole_form("/posts/123", method: "patch") do
<add> "<input name='post[123][comment][5][title]' type='text' id='post_123_comment_5_title' value='Hello World' />"
<add> end + whole_form("/posts/123", method: "patch") do
<add> "<input name='post[1][comment][123][title]' type='text' id='post_1_comment_123_title' value='Hello World' />"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_nested_fields_with_a_new_record_on_a_nested_attributes_one_to_one_association
<add> @post.author = Author.new
<add>
<add> form_with(model: @post) do |f|
<add> concat f.text_field(:title)
<add> concat f.fields(:author) { |af|
<add> concat af.text_field(:name)
<add> }
<add> end
<add>
<add> expected = whole_form("/posts/123", method: "patch") do
<add> '<input name="post[title]" type="text" id="post_title" value="Hello World" />' +
<add> '<input id="post_author_attributes_name" name="post[author_attributes][name]" type="text" value="new author" />'
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_nested_fields_with_explicitly_passed_object_on_a_nested_attributes_one_to_one_association
<add> form_with(model: @post) do |f|
<add> f.fields(:author, model: Author.new(123)) do |af|
<add> assert_not_nil af.object
<add> assert_equal 123, af.object.id
<add> end
<add> end
<add> end
<add>
<add> def test_nested_fields_with_an_existing_record_on_a_nested_attributes_one_to_one_association
<add> @post.author = Author.new(321)
<add>
<add> form_with(model: @post) do |f|
<add> concat f.text_field(:title)
<add> concat f.fields(:author) { |af|
<add> concat af.text_field(:name)
<add> }
<add> end
<add>
<add> expected = whole_form("/posts/123", method: "patch") do
<add> '<input name="post[title]" type="text" id="post_title" value="Hello World" />' +
<add> '<input id="post_author_attributes_name" name="post[author_attributes][name]" type="text" value="author #321" />' +
<add> '<input id="post_author_attributes_id" name="post[author_attributes][id]" type="hidden" value="321" />'
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_nested_fields_with_an_existing_record_on_a_nested_attributes_one_to_one_association_using_erb_and_inline_block
<add> @post.author = Author.new(321)
<add>
<add> form_with(model: @post) do |f|
<add> concat f.text_field(:title)
<add> concat f.fields(:author) { |af|
<add> af.text_field(:name)
<add> }
<add> end
<add>
<add> expected = whole_form("/posts/123", method: "patch") do
<add> '<input name="post[title]" type="text" id="post_title" value="Hello World" />' +
<add> '<input id="post_author_attributes_name" name="post[author_attributes][name]" type="text" value="author #321" />' +
<add> '<input id="post_author_attributes_id" name="post[author_attributes][id]" type="hidden" value="321" />'
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_nested_fields_with_an_existing_record_on_a_nested_attributes_one_to_one_association_with_disabled_hidden_id
<add> @post.author = Author.new(321)
<add>
<add> form_with(model: @post) do |f|
<add> concat f.text_field(:title)
<add> concat f.fields(:author, skip_id: true) { |af|
<add> af.text_field(:name)
<add> }
<add> end
<add>
<add> expected = whole_form("/posts/123", method: "patch") do
<add> '<input name="post[title]" type="text" id="post_title" value="Hello World" />' +
<add> '<input id="post_author_attributes_name" name="post[author_attributes][name]" type="text" value="author #321" />'
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_nested_fields_with_an_existing_record_on_a_nested_attributes_one_to_one_association_with_disabled_hidden_id_inherited
<add> @post.author = Author.new(321)
<add>
<add> form_with(model: @post, skip_id: true) do |f|
<add> concat f.text_field(:title)
<add> concat f.fields(:author) { |af|
<add> af.text_field(:name)
<add> }
<add> end
<add>
<add> expected = whole_form("/posts/123", method: "patch") do
<add> '<input name="post[title]" type="text" id="post_title" value="Hello World" />' +
<add> '<input id="post_author_attributes_name" name="post[author_attributes][name]" type="text" value="author #321" />'
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_nested_fields_with_an_existing_record_on_a_nested_attributes_one_to_one_association_with_disabled_hidden_id_override
<add> @post.author = Author.new(321)
<add>
<add> form_with(model: @post, skip_id: true) do |f|
<add> concat f.text_field(:title)
<add> concat f.fields(:author, skip_id: false) { |af|
<add> af.text_field(:name)
<add> }
<add> end
<add>
<add> expected = whole_form("/posts/123", method: "patch") do
<add> '<input name="post[title]" type="text" id="post_title" value="Hello World" />' +
<add> '<input id="post_author_attributes_name" name="post[author_attributes][name]" type="text" value="author #321" />' +
<add> '<input id="post_author_attributes_id" name="post[author_attributes][id]" type="hidden" value="321" />'
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_nested_fields_with_existing_records_on_a_nested_attributes_one_to_one_association_with_explicit_hidden_field_placement
<add> @post.author = Author.new(321)
<add>
<add> form_with(model: @post) do |f|
<add> concat f.text_field(:title)
<add> concat f.fields(:author) { |af|
<add> concat af.hidden_field(:id)
<add> concat af.text_field(:name)
<add> }
<add> end
<add>
<add> expected = whole_form("/posts/123", method: "patch") do
<add> '<input name="post[title]" type="text" id="post_title" value="Hello World" />' +
<add> '<input id="post_author_attributes_id" name="post[author_attributes][id]" type="hidden" value="321" />' +
<add> '<input id="post_author_attributes_name" name="post[author_attributes][name]" type="text" value="author #321" />'
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_nested_fields_with_existing_records_on_a_nested_attributes_collection_association
<add> @post.comments = Array.new(2) { |id| Comment.new(id + 1) }
<add>
<add> form_with(model: @post) do |f|
<add> concat f.text_field(:title)
<add> @post.comments.each do |comment|
<add> concat f.fields(:comments, model: comment) { |cf|
<add> concat cf.text_field(:name)
<add> }
<add> end
<add> end
<add>
<add> expected = whole_form("/posts/123", method: "patch") do
<add> '<input name="post[title]" type="text" id="post_title" value="Hello World" />' +
<add> '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" type="text" value="comment #1" />' +
<add> '<input id="post_comments_attributes_0_id" name="post[comments_attributes][0][id]" type="hidden" value="1" />' +
<add> '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" type="text" value="comment #2" />' +
<add> '<input id="post_comments_attributes_1_id" name="post[comments_attributes][1][id]" type="hidden" value="2" />'
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_nested_fields_with_existing_records_on_a_nested_attributes_collection_association_with_disabled_hidden_id
<add> @post.comments = Array.new(2) { |id| Comment.new(id + 1) }
<add> @post.author = Author.new(321)
<add>
<add> form_with(model: @post) do |f|
<add> concat f.text_field(:title)
<add> concat f.fields(:author) { |af|
<add> concat af.text_field(:name)
<add> }
<add> @post.comments.each do |comment|
<add> concat f.fields(:comments, model: comment, skip_id: true) { |cf|
<add> concat cf.text_field(:name)
<add> }
<add> end
<add> end
<add>
<add> expected = whole_form("/posts/123", method: "patch") do
<add> '<input name="post[title]" type="text" id="post_title" value="Hello World" />' +
<add> '<input id="post_author_attributes_name" name="post[author_attributes][name]" type="text" value="author #321" />' +
<add> '<input id="post_author_attributes_id" name="post[author_attributes][id]" type="hidden" value="321" />' +
<add> '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" type="text" value="comment #1" />' +
<add> '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" type="text" value="comment #2" />'
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_nested_fields_with_existing_records_on_a_nested_attributes_collection_association_with_disabled_hidden_id_inherited
<add> @post.comments = Array.new(2) { |id| Comment.new(id + 1) }
<add> @post.author = Author.new(321)
<add>
<add> form_with(model: @post, skip_id: true) do |f|
<add> concat f.text_field(:title)
<add> concat f.fields(:author) { |af|
<add> concat af.text_field(:name)
<add> }
<add> @post.comments.each do |comment|
<add> concat f.fields(:comments, model: comment) { |cf|
<add> concat cf.text_field(:name)
<add> }
<add> end
<add> end
<add>
<add> expected = whole_form("/posts/123", method: "patch") do
<add> '<input name="post[title]" type="text" id="post_title" value="Hello World" />' +
<add> '<input id="post_author_attributes_name" name="post[author_attributes][name]" type="text" value="author #321" />' +
<add> '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" type="text" value="comment #1" />' +
<add> '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" type="text" value="comment #2" />'
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_nested_fields_with_existing_records_on_a_nested_attributes_collection_association_with_disabled_hidden_id_override
<add> @post.comments = Array.new(2) { |id| Comment.new(id + 1) }
<add> @post.author = Author.new(321)
<add>
<add> form_with(model: @post, skip_id: true) do |f|
<add> concat f.text_field(:title)
<add> concat f.fields(:author, skip_id: false) { |af|
<add> concat af.text_field(:name)
<add> }
<add> @post.comments.each do |comment|
<add> concat f.fields(:comments, model: comment) { |cf|
<add> concat cf.text_field(:name)
<add> }
<add> end
<add> end
<add>
<add> expected = whole_form("/posts/123", method: "patch") do
<add> '<input name="post[title]" type="text" id="post_title" value="Hello World" />' +
<add> '<input id="post_author_attributes_name" name="post[author_attributes][name]" type="text" value="author #321" />' +
<add> '<input id="post_author_attributes_id" name="post[author_attributes][id]" type="hidden" value="321" />' +
<add> '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" type="text" value="comment #1" />' +
<add> '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" type="text" value="comment #2" />'
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_nested_fields_with_existing_records_on_a_nested_attributes_collection_association_using_erb_and_inline_block
<add> @post.comments = Array.new(2) { |id| Comment.new(id + 1) }
<add>
<add> form_with(model: @post) do |f|
<add> concat f.text_field(:title)
<add> @post.comments.each do |comment|
<add> concat f.fields(:comments, model: comment) { |cf|
<add> cf.text_field(:name)
<add> }
<add> end
<add> end
<add>
<add> expected = whole_form("/posts/123", method: "patch") do
<add> '<input name="post[title]" type="text" id="post_title" value="Hello World" />' +
<add> '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" type="text" value="comment #1" />' +
<add> '<input id="post_comments_attributes_0_id" name="post[comments_attributes][0][id]" type="hidden" value="1" />' +
<add> '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" type="text" value="comment #2" />' +
<add> '<input id="post_comments_attributes_1_id" name="post[comments_attributes][1][id]" type="hidden" value="2" />'
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_nested_fields_with_existing_records_on_a_nested_attributes_collection_association_with_explicit_hidden_field_placement
<add> @post.comments = Array.new(2) { |id| Comment.new(id + 1) }
<add>
<add> form_with(model: @post) do |f|
<add> concat f.text_field(:title)
<add> @post.comments.each do |comment|
<add> concat f.fields(:comments, model: comment) { |cf|
<add> concat cf.hidden_field(:id)
<add> concat cf.text_field(:name)
<add> }
<add> end
<add> end
<add>
<add> expected = whole_form("/posts/123", method: "patch") do
<add> '<input name="post[title]" type="text" id="post_title" value="Hello World" />' +
<add> '<input id="post_comments_attributes_0_id" name="post[comments_attributes][0][id]" type="hidden" value="1" />' +
<add> '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" type="text" value="comment #1" />' +
<add> '<input id="post_comments_attributes_1_id" name="post[comments_attributes][1][id]" type="hidden" value="2" />' +
<add> '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" type="text" value="comment #2" />'
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_nested_fields_with_new_records_on_a_nested_attributes_collection_association
<add> @post.comments = [Comment.new, Comment.new]
<add>
<add> form_with(model: @post) do |f|
<add> concat f.text_field(:title)
<add> @post.comments.each do |comment|
<add> concat f.fields(:comments, model: comment) { |cf|
<add> concat cf.text_field(:name)
<add> }
<add> end
<add> end
<add>
<add> expected = whole_form("/posts/123", method: "patch") do
<add> '<input name="post[title]" type="text" id="post_title" value="Hello World" />' +
<add> '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" type="text" value="new comment" />' +
<add> '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" type="text" value="new comment" />'
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_nested_fields_with_existing_and_new_records_on_a_nested_attributes_collection_association
<add> @post.comments = [Comment.new(321), Comment.new]
<add>
<add> form_with(model: @post) do |f|
<add> concat f.text_field(:title)
<add> @post.comments.each do |comment|
<add> concat f.fields(:comments, model: comment) { |cf|
<add> concat cf.text_field(:name)
<add> }
<add> end
<add> end
<add>
<add> expected = whole_form("/posts/123", method: "patch") do
<add> '<input name="post[title]" type="text" id="post_title" value="Hello World" />' +
<add> '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" type="text" value="comment #321" />' +
<add> '<input id="post_comments_attributes_0_id" name="post[comments_attributes][0][id]" type="hidden" value="321" />' +
<add> '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" type="text" value="new comment" />'
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_nested_fields_with_an_empty_supplied_attributes_collection
<add> form_with(model: @post) do |f|
<add> concat f.text_field(:title)
<add> f.fields(:comments, model: []) do |cf|
<add> concat cf.text_field(:name)
<add> end
<add> end
<add>
<add> expected = whole_form("/posts/123", method: "patch") do
<add> '<input name="post[title]" type="text" id="post_title" value="Hello World" />'
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_nested_fields_with_existing_records_on_a_supplied_nested_attributes_collection
<add> @post.comments = Array.new(2) { |id| Comment.new(id + 1) }
<add>
<add> form_with(model: @post) do |f|
<add> concat f.text_field(:title)
<add> concat f.fields(:comments, model: @post.comments) { |cf|
<add> concat cf.text_field(:name)
<add> }
<add> end
<add>
<add> expected = whole_form("/posts/123", method: "patch") do
<add> '<input name="post[title]" type="text" id="post_title" value="Hello World" />' +
<add> '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" type="text" value="comment #1" />' +
<add> '<input id="post_comments_attributes_0_id" name="post[comments_attributes][0][id]" type="hidden" value="1" />' +
<add> '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" type="text" value="comment #2" />' +
<add> '<input id="post_comments_attributes_1_id" name="post[comments_attributes][1][id]" type="hidden" value="2" />'
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_nested_fields_arel_like
<add> @post.comments = ArelLike.new
<add>
<add> form_with(model: @post) do |f|
<add> concat f.text_field(:title)
<add> concat f.fields(:comments, model: @post.comments) { |cf|
<add> concat cf.text_field(:name)
<add> }
<add> end
<add>
<add> expected = whole_form("/posts/123", method: "patch") do
<add> '<input name="post[title]" type="text" id="post_title" value="Hello World" />' +
<add> '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" type="text" value="comment #1" />' +
<add> '<input id="post_comments_attributes_0_id" name="post[comments_attributes][0][id]" type="hidden" value="1" />' +
<add> '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" type="text" value="comment #2" />' +
<add> '<input id="post_comments_attributes_1_id" name="post[comments_attributes][1][id]" type="hidden" value="2" />'
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_nested_fields_label_translation_with_more_than_10_records
<add> @post.comments = Array.new(11) { |id| Comment.new(id + 1) }
<add>
<add> params = 11.times.map { ["post.comments.body", default: [:"comment.body", ""], scope: "helpers.label"] }
<add> assert_called_with(I18n, :t, params, returns: "Write body here") do
<add> form_with(model: @post) do |f|
<add> f.fields(:comments) do |cf|
<add> concat cf.label(:body)
<add> end
<add> end
<add> end
<add> end
<add>
<add> def test_nested_fields_with_existing_records_on_a_supplied_nested_attributes_collection_different_from_record_one
<add> comments = Array.new(2) { |id| Comment.new(id + 1) }
<add> @post.comments = []
<add>
<add> form_with(model: @post) do |f|
<add> concat f.text_field(:title)
<add> concat f.fields(:comments, model: comments) { |cf|
<add> concat cf.text_field(:name)
<add> }
<add> end
<add>
<add> expected = whole_form("/posts/123", method: "patch") do
<add> '<input name="post[title]" type="text" id="post_title" value="Hello World" />' +
<add> '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" type="text" value="comment #1" />' +
<add> '<input id="post_comments_attributes_0_id" name="post[comments_attributes][0][id]" type="hidden" value="1" />' +
<add> '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" type="text" value="comment #2" />' +
<add> '<input id="post_comments_attributes_1_id" name="post[comments_attributes][1][id]" type="hidden" value="2" />'
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_nested_fields_on_a_nested_attributes_collection_association_yields_only_builder
<add> @post.comments = [Comment.new(321), Comment.new]
<add> yielded_comments = []
<add>
<add> form_with(model: @post) do |f|
<add> concat f.text_field(:title)
<add> concat f.fields(:comments) { |cf|
<add> concat cf.text_field(:name)
<add> yielded_comments << cf.object
<add> }
<add> end
<add>
<add> expected = whole_form("/posts/123", method: "patch") do
<add> '<input name="post[title]" type="text" id="post_title" value="Hello World" />' +
<add> '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" type="text" value="comment #321" />' +
<add> '<input id="post_comments_attributes_0_id" name="post[comments_attributes][0][id]" type="hidden" value="321" />' +
<add> '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" type="text" value="new comment" />'
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> assert_equal yielded_comments, @post.comments
<add> end
<add>
<add> def test_nested_fields_with_child_index_option_override_on_a_nested_attributes_collection_association
<add> @post.comments = []
<add>
<add> form_with(model: @post) do |f|
<add> concat f.fields(:comments, model: Comment.new(321), child_index: "abc") { |cf|
<add> concat cf.text_field(:name)
<add> }
<add> end
<add>
<add> expected = whole_form("/posts/123", method: "patch") do
<add> '<input id="post_comments_attributes_abc_name" name="post[comments_attributes][abc][name]" type="text" value="comment #321" />' +
<add> '<input id="post_comments_attributes_abc_id" name="post[comments_attributes][abc][id]" type="hidden" value="321" />'
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_nested_fields_with_child_index_as_lambda_option_override_on_a_nested_attributes_collection_association
<add> @post.comments = []
<add>
<add> form_with(model: @post) do |f|
<add> concat f.fields(:comments, model: Comment.new(321), child_index: -> { "abc" }) { |cf|
<add> concat cf.text_field(:name)
<add> }
<add> end
<add>
<add> expected = whole_form("/posts/123", method: "patch") do
<add> '<input id="post_comments_attributes_abc_name" name="post[comments_attributes][abc][name]" type="text" value="comment #321" />' +
<add> '<input id="post_comments_attributes_abc_id" name="post[comments_attributes][abc][id]" type="hidden" value="321" />'
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> class FakeAssociationProxy
<add> def to_ary
<add> [1, 2, 3]
<add> end
<add> end
<add>
<add> def test_nested_fields_with_child_index_option_override_on_a_nested_attributes_collection_association_with_proxy
<add> @post.comments = FakeAssociationProxy.new
<add>
<add> form_with(model: @post) do |f|
<add> concat f.fields(:comments, model: Comment.new(321), child_index: "abc") { |cf|
<add> concat cf.text_field(:name)
<add> }
<add> end
<add>
<add> expected = whole_form("/posts/123", method: "patch") do
<add> '<input id="post_comments_attributes_abc_name" name="post[comments_attributes][abc][name]" type="text" value="comment #321" />' +
<add> '<input id="post_comments_attributes_abc_id" name="post[comments_attributes][abc][id]" type="hidden" value="321" />'
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_nested_fields_index_method_with_existing_records_on_a_nested_attributes_collection_association
<add> @post.comments = Array.new(2) { |id| Comment.new(id + 1) }
<add>
<add> form_with(model: @post) do |f|
<add> expected = 0
<add> @post.comments.each do |comment|
<add> f.fields(:comments, model: comment) { |cf|
<add> assert_equal cf.index, expected
<add> expected += 1
<add> }
<add> end
<add> end
<add> end
<add>
<add> def test_nested_fields_index_method_with_existing_and_new_records_on_a_nested_attributes_collection_association
<add> @post.comments = [Comment.new(321), Comment.new]
<add>
<add> form_with(model: @post) do |f|
<add> expected = 0
<add> @post.comments.each do |comment|
<add> f.fields(:comments, model: comment) { |cf|
<add> assert_equal cf.index, expected
<add> expected += 1
<add> }
<add> end
<add> end
<add> end
<add>
<add> def test_nested_fields_index_method_with_existing_records_on_a_supplied_nested_attributes_collection
<add> @post.comments = Array.new(2) { |id| Comment.new(id + 1) }
<add>
<add> form_with(model: @post) do |f|
<add> expected = 0
<add> f.fields(:comments, model: @post.comments) { |cf|
<add> assert_equal cf.index, expected
<add> expected += 1
<add> }
<add> end
<add> end
<add>
<add> def test_nested_fields_index_method_with_child_index_option_override_on_a_nested_attributes_collection_association
<add> @post.comments = []
<add>
<add> form_with(model: @post) do |f|
<add> f.fields(:comments, model: Comment.new(321), child_index: "abc") { |cf|
<add> assert_equal cf.index, "abc"
<add> }
<add> end
<add> end
<add>
<add> def test_nested_fields_uses_unique_indices_for_different_collection_associations
<add> @post.comments = [Comment.new(321)]
<add> @post.tags = [Tag.new(123), Tag.new(456)]
<add> @post.comments[0].relevances = []
<add> @post.tags[0].relevances = []
<add> @post.tags[1].relevances = []
<add>
<add> form_with(model: @post) do |f|
<add> concat f.fields(:comments, model: @post.comments[0]) { |cf|
<add> concat cf.text_field(:name)
<add> concat cf.fields(:relevances, model: CommentRelevance.new(314)) { |crf|
<add> concat crf.text_field(:value)
<add> }
<add> }
<add> concat f.fields(:tags, model: @post.tags[0]) { |tf|
<add> concat tf.text_field(:value)
<add> concat tf.fields(:relevances, model: TagRelevance.new(3141)) { |trf|
<add> concat trf.text_field(:value)
<add> }
<add> }
<add> concat f.fields("tags", model: @post.tags[1]) { |tf|
<add> concat tf.text_field(:value)
<add> concat tf.fields(:relevances, model: TagRelevance.new(31415)) { |trf|
<add> concat trf.text_field(:value)
<add> }
<add> }
<add> end
<add>
<add> expected = whole_form("/posts/123", method: "patch") do
<add> '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" type="text" value="comment #321" />' +
<add> '<input id="post_comments_attributes_0_relevances_attributes_0_value" name="post[comments_attributes][0][relevances_attributes][0][value]" type="text" value="commentrelevance #314" />' +
<add> '<input id="post_comments_attributes_0_relevances_attributes_0_id" name="post[comments_attributes][0][relevances_attributes][0][id]" type="hidden" value="314" />' +
<add> '<input id="post_comments_attributes_0_id" name="post[comments_attributes][0][id]" type="hidden" value="321" />' +
<add> '<input id="post_tags_attributes_0_value" name="post[tags_attributes][0][value]" type="text" value="tag #123" />' +
<add> '<input id="post_tags_attributes_0_relevances_attributes_0_value" name="post[tags_attributes][0][relevances_attributes][0][value]" type="text" value="tagrelevance #3141" />' +
<add> '<input id="post_tags_attributes_0_relevances_attributes_0_id" name="post[tags_attributes][0][relevances_attributes][0][id]" type="hidden" value="3141" />' +
<add> '<input id="post_tags_attributes_0_id" name="post[tags_attributes][0][id]" type="hidden" value="123" />' +
<add> '<input id="post_tags_attributes_1_value" name="post[tags_attributes][1][value]" type="text" value="tag #456" />' +
<add> '<input id="post_tags_attributes_1_relevances_attributes_0_value" name="post[tags_attributes][1][relevances_attributes][0][value]" type="text" value="tagrelevance #31415" />' +
<add> '<input id="post_tags_attributes_1_relevances_attributes_0_id" name="post[tags_attributes][1][relevances_attributes][0][id]" type="hidden" value="31415" />' +
<add> '<input id="post_tags_attributes_1_id" name="post[tags_attributes][1][id]" type="hidden" value="456" />'
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_nested_fields_with_hash_like_model
<add> @author = HashBackedAuthor.new
<add>
<add> form_with(model: @post) do |f|
<add> concat f.fields(:author, model: @author) { |af|
<add> concat af.text_field(:name)
<add> }
<add> end
<add>
<add> expected = whole_form("/posts/123", method: "patch") do
<add> '<input id="post_author_attributes_name" name="post[author_attributes][name]" type="text" value="hash backed author" />'
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_fields
<add> output_buffer = fields(:post, model: @post) do |f|
<add> concat f.text_field(:title)
<add> concat f.text_area(:body)
<add> concat f.check_box(:secret)
<add> end
<add>
<add> expected =
<add> "<input name='post[title]' type='text' id='post_title' value='Hello World' />" +
<add> "<textarea name='post[body]' id='post_body'>\nBack to the hill and over it again!</textarea>" +
<add> "<input name='post[secret]' type='hidden' value='0' />" +
<add> "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />"
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_fields_with_index
<add> output_buffer = fields("post[]", model: @post) do |f|
<add> concat f.text_field(:title)
<add> concat f.text_area(:body)
<add> concat f.check_box(:secret)
<add> end
<add>
<add> expected =
<add> "<input name='post[123][title]' type='text' id='post_123_title' value='Hello World' />" +
<add> "<textarea name='post[123][body]' id='post_123_body'>\nBack to the hill and over it again!</textarea>" +
<add> "<input name='post[123][secret]' type='hidden' value='0' />" +
<add> "<input name='post[123][secret]' checked='checked' type='checkbox' id='post_123_secret' value='1' />"
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_fields_with_nil_index_option_override
<add> output_buffer = fields("post[]", model: @post, index: nil) do |f|
<add> concat f.text_field(:title)
<add> concat f.text_area(:body)
<add> concat f.check_box(:secret)
<add> end
<add>
<add> expected =
<add> "<input name='post[][title]' type='text' id='post__title' value='Hello World' />" +
<add> "<textarea name='post[][body]' id='post__body'>\nBack to the hill and over it again!</textarea>" +
<add> "<input name='post[][secret]' type='hidden' value='0' />" +
<add> "<input name='post[][secret]' checked='checked' type='checkbox' id='post__secret' value='1' />"
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_fields_with_index_option_override
<add> output_buffer = fields("post[]", model: @post, index: "abc") do |f|
<add> concat f.text_field(:title)
<add> concat f.text_area(:body)
<add> concat f.check_box(:secret)
<add> end
<add>
<add> expected =
<add> "<input name='post[abc][title]' type='text' id='post_abc_title' value='Hello World' />" +
<add> "<textarea name='post[abc][body]' id='post_abc_body'>\nBack to the hill and over it again!</textarea>" +
<add> "<input name='post[abc][secret]' type='hidden' value='0' />" +
<add> "<input name='post[abc][secret]' checked='checked' type='checkbox' id='post_abc_secret' value='1' />"
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_fields_without_object
<add> output_buffer = fields(:post) do |f|
<add> concat f.text_field(:title)
<add> concat f.text_area(:body)
<add> concat f.check_box(:secret)
<add> end
<add>
<add> expected =
<add> "<input name='post[title]' type='text' id='post_title' value='Hello World' />" +
<add> "<textarea name='post[body]' id='post_body'>\nBack to the hill and over it again!</textarea>" +
<add> "<input name='post[secret]' type='hidden' value='0' />" +
<add> "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />"
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_fields_with_only_object
<add> output_buffer = fields(model: @post) do |f|
<add> concat f.text_field(:title)
<add> concat f.text_area(:body)
<add> concat f.check_box(:secret)
<add> end
<add>
<add> expected =
<add> "<input name='post[title]' type='text' id='post_title' value='Hello World' />" +
<add> "<textarea name='post[body]' id='post_body'>\nBack to the hill and over it again!</textarea>" +
<add> "<input name='post[secret]' type='hidden' value='0' />" +
<add> "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />"
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_fields_object_with_bracketed_name
<add> output_buffer = fields("author[post]", model: @post) do |f|
<add> concat f.label(:title)
<add> concat f.text_field(:title)
<add> end
<add>
<add> assert_dom_equal "<label for=\"author_post_title\">Title</label>" +
<add> "<input name='author[post][title]' type='text' id='author_post_title' value='Hello World' />",
<add> output_buffer
<add> end
<add>
<add> def test_fields_object_with_bracketed_name_and_index
<add> output_buffer = fields("author[post]", model: @post, index: 1) do |f|
<add> concat f.label(:title)
<add> concat f.text_field(:title)
<add> end
<add>
<add> assert_dom_equal "<label for=\"author_post_1_title\">Title</label>" +
<add> "<input name='author[post][1][title]' type='text' id='author_post_1_title' value='Hello World' />",
<add> output_buffer
<add> end
<add>
<add> def test_form_builder_does_not_have_form_with_method
<add> assert_not_includes ActionView::Helpers::FormBuilder.instance_methods, :form_with
<add> end
<add>
<add> def test_form_with_and_fields
<add> form_with(model: @post, scope: :post, id: "create-post") do |post_form|
<add> concat post_form.text_field(:title)
<add> concat post_form.text_area(:body)
<add>
<add> concat fields(:parent_post, model: @post) { |parent_fields|
<add> concat parent_fields.check_box(:secret)
<add> }
<add> end
<add>
<add> expected = whole_form("/posts/123", "create-post", method: "patch") do
<add> "<input name='post[title]' type='text' id='post_title' value='Hello World' />" +
<add> "<textarea name='post[body]' id='post_body'>\nBack to the hill and over it again!</textarea>" +
<add> "<input name='parent_post[secret]' type='hidden' value='0' />" +
<add> "<input name='parent_post[secret]' checked='checked' type='checkbox' id='parent_post_secret' value='1' />"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_form_with_and_fields_with_object
<add> form_with(model: @post, scope: :post, id: "create-post") do |post_form|
<add> concat post_form.text_field(:title)
<add> concat post_form.text_area(:body)
<add>
<add> concat post_form.fields(model: @comment) { |comment_fields|
<add> concat comment_fields.text_field(:name)
<add> }
<add> end
<add>
<add> expected = whole_form("/posts/123", "create-post", method: "patch") do
<add> "<input name='post[title]' type='text' id='post_title' value='Hello World' />" +
<add> "<textarea name='post[body]' id='post_body'>\nBack to the hill and over it again!</textarea>" +
<add> "<input name='post[comment][name]' type='text' id='post_comment_name' value='new comment' />"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_form_with_and_fields_with_non_nested_association_and_without_object
<add> form_with(model: @post) do |f|
<add> concat f.fields(:category) { |c|
<add> concat c.text_field(:name)
<add> }
<add> end
<add>
<add> expected = whole_form("/posts/123", method: "patch") do
<add> "<input name='post[category][name]' type='text' id='post_category_name' />"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> class LabelledFormBuilder < ActionView::Helpers::FormBuilder
<add> (field_helpers - %w(hidden_field)).each do |selector|
<add> class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
<add> def #{selector}(field, *args, &proc)
<add> ("<label for='\#{field}'>\#{field.to_s.humanize}:</label> " + super + "<br/>").html_safe
<add> end
<add> RUBY_EVAL
<add> end
<add> end
<add>
<add> def test_form_with_with_labelled_builder
<add> form_with(model: @post, builder: LabelledFormBuilder) do |f|
<add> concat f.text_field(:title)
<add> concat f.text_area(:body)
<add> concat f.check_box(:secret)
<add> end
<add>
<add> expected = whole_form("/posts/123", method: "patch") do
<add> "<label for='title'>Title:</label> <input name='post[title]' type='text' id='post_title' value='Hello World' /><br/>" +
<add> "<label for='body'>Body:</label> <textarea name='post[body]' id='post_body'>\nBack to the hill and over it again!</textarea><br/>" +
<add> "<label for='secret'>Secret:</label> <input name='post[secret]' type='hidden' value='0' /><input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' /><br/>"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_default_form_builder
<add> old_default_form_builder, ActionView::Base.default_form_builder =
<add> ActionView::Base.default_form_builder, LabelledFormBuilder
<add>
<add> form_with(model: @post) do |f|
<add> concat f.text_field(:title)
<add> concat f.text_area(:body)
<add> concat f.check_box(:secret)
<add> end
<add>
<add> expected = whole_form("/posts/123", method: "patch") do
<add> "<label for='title'>Title:</label> <input name='post[title]' type='text' id='post_title' value='Hello World' /><br/>" +
<add> "<label for='body'>Body:</label> <textarea name='post[body]' id='post_body'>\nBack to the hill and over it again!</textarea><br/>" +
<add> "<label for='secret'>Secret:</label> <input name='post[secret]' type='hidden' value='0' /><input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' /><br/>"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> ensure
<add> ActionView::Base.default_form_builder = old_default_form_builder
<add> end
<add>
<add> def test_lazy_loading_default_form_builder
<add> old_default_form_builder, ActionView::Base.default_form_builder =
<add> ActionView::Base.default_form_builder, "FormWithActsLikeFormForTest::LabelledFormBuilder"
<add>
<add> form_with(model: @post) do |f|
<add> concat f.text_field(:title)
<add> end
<add>
<add> expected = whole_form("/posts/123", method: "patch") do
<add> "<label for='title'>Title:</label> <input name='post[title]' type='text' id='post_title' value='Hello World' /><br/>"
<add> end
<add>
<add> assert_dom_equal expected, output_buffer
<add> ensure
<add> ActionView::Base.default_form_builder = old_default_form_builder
<add> end
<add>
<add> def test_form_builder_override
<add> self.default_form_builder = LabelledFormBuilder
<add>
<add> output_buffer = fields(:post, model: @post) do |f|
<add> concat f.text_field(:title)
<add> end
<add>
<add> expected = "<label for='title'>Title:</label> <input name='post[title]' type='text' id='post_title' value='Hello World' /><br/>"
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_lazy_loading_form_builder_override
<add> self.default_form_builder = "FormWithActsLikeFormForTest::LabelledFormBuilder"
<add>
<add> output_buffer = fields(:post, model: @post) do |f|
<add> concat f.text_field(:title)
<add> end
<add>
<add> expected = "<label for='title'>Title:</label> <input name='post[title]' type='text' id='post_title' value='Hello World' /><br/>"
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_fields_with_labelled_builder
<add> output_buffer = fields(:post, model: @post, builder: LabelledFormBuilder) do |f|
<add> concat f.text_field(:title)
<add> concat f.text_area(:body)
<add> concat f.check_box(:secret)
<add> end
<add>
<add> expected =
<add> "<label for='title'>Title:</label> <input name='post[title]' type='text' id='post_title' value='Hello World' /><br/>" +
<add> "<label for='body'>Body:</label> <textarea name='post[body]' id='post_body'>\nBack to the hill and over it again!</textarea><br/>" +
<add> "<label for='secret'>Secret:</label> <input name='post[secret]' type='hidden' value='0' /><input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' /><br/>"
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_form_with_with_labelled_builder_with_nested_fields_without_options_hash
<add> klass = nil
<add>
<add> form_with(model: @post, builder: LabelledFormBuilder) do |f|
<add> f.fields(:comments, model: Comment.new) do |nested_fields|
<add> klass = nested_fields.class
<add> ""
<add> end
<add> end
<add>
<add> assert_equal LabelledFormBuilder, klass
<add> end
<add>
<add> def test_form_with_with_labelled_builder_with_nested_fields_with_options_hash
<add> klass = nil
<add>
<add> form_with(model: @post, builder: LabelledFormBuilder) do |f|
<add> f.fields(:comments, model: Comment.new, index: "foo") do |nested_fields|
<add> klass = nested_fields.class
<add> ""
<add> end
<add> end
<add>
<add> assert_equal LabelledFormBuilder, klass
<add> end
<add>
<add> def test_form_with_with_labelled_builder_path
<add> path = nil
<add>
<add> form_with(model: @post, builder: LabelledFormBuilder) do |f|
<add> path = f.to_partial_path
<add> ""
<add> end
<add>
<add> assert_equal "labelled_form", path
<add> end
<add>
<add> class LabelledFormBuilderSubclass < LabelledFormBuilder; end
<add>
<add> def test_form_with_with_labelled_builder_with_nested_fields_with_custom_builder
<add> klass = nil
<add>
<add> form_with(model: @post, builder: LabelledFormBuilder) do |f|
<add> f.fields(:comments, model: Comment.new, builder: LabelledFormBuilderSubclass) do |nested_fields|
<add> klass = nested_fields.class
<add> ""
<add> end
<add> end
<add>
<add> assert_equal LabelledFormBuilderSubclass, klass
<add> end
<add>
<add> def test_form_with_with_html_options_adds_options_to_form_tag
<add> form_with(model: @post, html: { id: "some_form", class: "some_class", multipart: true }) do |f| end
<add> expected = whole_form("/posts/123", "some_form", "some_class", method: "patch", multipart: "multipart/form-data")
<add>
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_form_with_with_string_url_option
<add> form_with(model: @post, url: "http://www.otherdomain.com") do |f| end
<add>
<add> assert_dom_equal whole_form("http://www.otherdomain.com", method: "patch"), output_buffer
<add> end
<add>
<add> def test_form_with_with_hash_url_option
<add> form_with(model: @post, url: { controller: "controller", action: "action" }) do |f| end
<add>
<add> assert_equal "controller", @url_for_options[:controller]
<add> assert_equal "action", @url_for_options[:action]
<add> end
<add>
<add> def test_form_with_with_record_url_option
<add> form_with(model: @post, url: @post) do |f| end
<add>
<add> expected = whole_form("/posts/123", method: "patch")
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_form_with_with_existing_object
<add> form_with(model: @post) do |f| end
<add>
<add> expected = whole_form("/posts/123", method: "patch")
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_form_with_with_new_object
<add> post = Post.new
<add> post.persisted = false
<add> def post.to_key; nil; end
<add>
<add> form_with(model: post) {}
<add>
<add> expected = whole_form("/posts")
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_form_with_with_existing_object_in_list
<add> @comment.save
<add> form_with(model: [@post, @comment]) {}
<add>
<add> expected = whole_form(post_comment_path(@post, @comment), method: "patch")
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_form_with_with_new_object_in_list
<add> form_with(model: [@post, @comment]) {}
<add>
<add> expected = whole_form(post_comments_path(@post))
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_form_with_with_existing_object_and_namespace_in_list
<add> @comment.save
<add> form_with(model: [:admin, @post, @comment]) {}
<add>
<add> expected = whole_form(admin_post_comment_path(@post, @comment), method: "patch")
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_form_with_with_new_object_and_namespace_in_list
<add> form_with(model: [:admin, @post, @comment]) {}
<add>
<add> expected = whole_form(admin_post_comments_path(@post))
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_form_with_with_existing_object_and_custom_url
<add> form_with(model: @post, url: "/super_posts") do |f| end
<add>
<add> expected = whole_form("/super_posts", method: "patch")
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_form_with_with_default_method_as_patch
<add> form_with(model: @post) {}
<add> expected = whole_form("/posts/123", method: "patch")
<add> assert_dom_equal expected, output_buffer
<add> end
<add>
<add> def test_form_with_with_data_attributes
<add> form_with(model: @post, data: { behavior: "stuff" }) {}
<add> assert_match %r|data-behavior="stuff"|, output_buffer
<add> assert_match %r|data-remote="true"|, output_buffer
<add> end
<add>
<add> def test_fields_returns_block_result
<add> output = fields(model: Post.new) { |f| "fields" }
<add> assert_equal "fields", output
<add> end
<add>
<add> def test_form_with_only_instantiates_builder_once
<add> initialization_count = 0
<add> builder_class = Class.new(ActionView::Helpers::FormBuilder) do
<add> define_method :initialize do |*args|
<add> super(*args)
<add> initialization_count += 1
<add> end
<add> end
<add>
<add> form_with(model: @post, builder: builder_class) {}
<add> assert_equal 1, initialization_count, "form builder instantiated more than once"
<add> end
<add>
<add> protected
<add> def hidden_fields(options = {})
<add> method = options[:method]
<add>
<add> if options.fetch(:skip_enforcing_utf8, false)
<add> txt = ""
<add> else
<add> txt = %{<input name="utf8" type="hidden" value="✓" />}
<add> end
<add>
<add> if method && !%w(get post).include?(method.to_s)
<add> txt << %{<input name="_method" type="hidden" value="#{method}" />}
<add> end
<add>
<add> txt
<add> end
<add>
<add> def form_text(action = "/", id = nil, html_class = nil, local = nil, multipart = nil, method = nil)
<add> txt = %{<form accept-charset="UTF-8" action="#{action}"}
<add> txt << %{ enctype="multipart/form-data"} if multipart
<add> txt << %{ data-remote="true"} unless local
<add> txt << %{ class="#{html_class}"} if html_class
<add> txt << %{ id="#{id}"} if id
<add> method = method.to_s == "get" ? "get" : "post"
<add> txt << %{ method="#{method}">}
<add> end
<add>
<add> def whole_form(action = "/", id = nil, html_class = nil, local: false, **options)
<add> contents = block_given? ? yield : ""
<add>
<add> method, multipart = options.values_at(:method, :multipart)
<add>
<add> form_text(action, id, html_class, local, multipart, method) + hidden_fields(options.slice :method, :skip_enforcing_utf8) + contents + "</form>"
<add> end
<add>
<add> def protect_against_forgery?
<add> false
<add> end
<add>
<add> def with_locale(testing_locale = :label)
<add> old_locale, I18n.locale = I18n.locale, testing_locale
<add> yield
<add> ensure
<add> I18n.locale = old_locale
<add> end
<add>end
| 2
|
Python
|
Python
|
add _2_24 to valid manylinux names
|
6e4e8b789e8d0fe4591d80a578ff21b388b1956d
|
<ide><path>tools/openblas_support.py
<ide> def get_manylinux(arch):
<ide> default = '2014'
<ide> ret = os.environ.get("MB_ML_VER", default)
<ide> # XXX For PEP 600 this can be a glibc version
<del> assert ret in ('1', '2010', '2014'), f'invalid MB_ML_VER {ret}'
<add> assert ret in ('1', '2010', '2014', '_2_24'), f'invalid MB_ML_VER {ret}'
<ide> return ret
<ide>
<ide>
| 1
|
Java
|
Java
|
join identical catch branches
|
a218bf40cde2998f7db041d87d85e605e1a880b4
|
<ide><path>spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAdviceParameterNameDiscoverer.java
<ide> public String[] getParameterNames(Method method) {
<ide> }
<ide> }
<ide> }
<del> catch (AmbiguousBindingException ambigEx) {
<del> if (this.raiseExceptions) {
<del> throw ambigEx;
<del> }
<del> else {
<del> return null;
<del> }
<del> }
<del> catch (IllegalArgumentException ex) {
<add> catch (AmbiguousBindingException | IllegalArgumentException ex) {
<ide> if (this.raiseExceptions) {
<ide> throw ex;
<ide> }
<ide><path>spring-expression/src/test/java/org/springframework/expression/spel/ExpressionLanguageScenarioTests.java
<ide> public void testScenario_UsingStandardInfrastructure() {
<ide> assertEquals("hello world", value);
<ide> assertEquals(String.class, value.getClass());
<ide> }
<del> catch (EvaluationException ee) {
<del> ee.printStackTrace();
<del> fail("Unexpected Exception: " + ee.getMessage());
<del> }
<del> catch (ParseException pe) {
<del> pe.printStackTrace();
<del> fail("Unexpected Exception: " + pe.getMessage());
<add> catch (EvaluationException | ParseException ex) {
<add> ex.printStackTrace();
<add> fail("Unexpected Exception: " + ex.getMessage());
<ide> }
<ide> }
<ide>
<ide> public void testScenario_RegisteringJavaMethodsAsFunctionsAndCallingThem() throw
<ide> assertEquals("hellohello", value);
<ide>
<ide> }
<del> catch (EvaluationException ee) {
<del> ee.printStackTrace();
<del> fail("Unexpected Exception: " + ee.getMessage());
<del> }
<del> catch (ParseException pe) {
<del> pe.printStackTrace();
<del> fail("Unexpected Exception: " + pe.getMessage());
<add> catch (EvaluationException | ParseException ex) {
<add> ex.printStackTrace();
<add> fail("Unexpected Exception: " + ex.getMessage());
<ide> }
<ide> }
<ide>
<ide><path>spring-expression/src/test/java/org/springframework/expression/spel/SetValueTests.java
<ide> protected void setValue(String expression, Object value) {
<ide> e.setValue(lContext, value);
<ide> assertEquals("Retrieved value was not equal to set value", value, e.getValue(lContext,value.getClass()));
<ide> }
<del> catch (EvaluationException ee) {
<del> ee.printStackTrace();
<del> fail("Unexpected Exception: " + ee.getMessage());
<del> }
<del> catch (ParseException pe) {
<del> pe.printStackTrace();
<del> fail("Unexpected Exception: " + pe.getMessage());
<add> catch (EvaluationException | ParseException ex) {
<add> ex.printStackTrace();
<add> fail("Unexpected Exception: " + ex.getMessage());
<ide> }
<ide> }
<ide>
<ide> protected void setValue(String expression, Object value, Object expectedValue) {
<ide> // assertEquals("Retrieved value was not equal to set value", expectedValue, e.getValue(lContext));
<ide> }
<ide> }
<del> catch (EvaluationException ee) {
<del> ee.printStackTrace();
<del> fail("Unexpected Exception: " + ee.getMessage());
<del> }
<del> catch (ParseException pe) {
<del> pe.printStackTrace();
<del> fail("Unexpected Exception: " + pe.getMessage());
<add> catch (EvaluationException | ParseException ex) {
<add> ex.printStackTrace();
<add> fail("Unexpected Exception: " + ex.getMessage());
<ide> }
<ide> }
<ide>
<ide><path>spring-tx/src/main/java/org/springframework/transaction/jta/SpringJtaSynchronizationAdapter.java
<ide> public void beforeCompletion() {
<ide> boolean readOnly = TransactionSynchronizationManager.isCurrentTransactionReadOnly();
<ide> this.springSynchronization.beforeCommit(readOnly);
<ide> }
<del> catch (RuntimeException ex) {
<add> catch (RuntimeException | Error ex) {
<ide> setRollbackOnlyIfPossible();
<ide> throw ex;
<ide> }
<del> catch (Error err) {
<del> setRollbackOnlyIfPossible();
<del> throw err;
<del> }
<ide> finally {
<ide> // Process Spring's beforeCompletion early, in order to avoid issues
<ide> // with strict JTA implementations that issue warnings when doing JDBC
<ide><path>spring-tx/src/test/java/org/springframework/transaction/jta/MockUOWManager.java
<ide> public void runUnderUOW(int type, boolean join, UOWAction action) throws UOWActi
<ide> action.run();
<ide> this.status = (this.rollbackOnly ? UOW_STATUS_ROLLEDBACK : UOW_STATUS_COMMITTED);
<ide> }
<del> catch (Error err) {
<del> this.status = UOW_STATUS_ROLLEDBACK;
<del> throw err;
<del> }
<del> catch (RuntimeException ex) {
<add> catch (Error | RuntimeException ex) {
<ide> this.status = UOW_STATUS_ROLLEDBACK;
<ide> throw ex;
<del> }
<del> catch (Exception ex) {
<add> } catch (Exception ex) {
<ide> this.status = UOW_STATUS_ROLLEDBACK;
<ide> throw new UOWActionException(ex);
<ide> }
| 5
|
Text
|
Text
|
add ing to list of users
|
85fcc2d5c7ff91359868a270c1fd6ad220078f25
|
<ide><path>README.md
<ide> Currently **officially** using Airflow:
<ide> * [FreshBooks](https://github.com/freshbooks) [[@DinoCow](https://github.com/DinoCow)]
<ide> * [Holimetrix](http://holimetrix.com/) [[@thibault-ketterer](https://github.com/thibault-ketterer)]
<ide> * [Handy](http://www.handy.com/careers/73115?gh_jid=73115&gh_src=o5qcxn) [[@marcintustin](https://github.com/marcintustin) / [@mtustin-handy](https://github.com/mtustin-handy)]
<add>* ING
<ide> * [Jampp](https://github.com/jampp)
<ide> * [LingoChamp](http://www.liulishuo.com/) [[@haitaoyao](https://github.com/haitaoyao)]
<ide> * Lyft
| 1
|
Javascript
|
Javascript
|
remove duplicate setpauseonexception call
|
937288aeabf0ad54dcff997f68b5df52bdad0432
|
<ide><path>lib/internal/debugger/inspect_repl.js
<ide> function createRepl(inspector) {
<ide> await Profiler.enable();
<ide> await Profiler.setSamplingInterval({ interval: 100 });
<ide> await Debugger.enable();
<del> await Debugger.setPauseOnExceptions({ state: 'none' });
<ide> await Debugger.setAsyncCallStackDepth({ maxDepth: 0 });
<ide> await Debugger.setBlackboxPatterns({ patterns: [] });
<ide> await Debugger.setPauseOnExceptions({ state: pauseOnExceptionState });
| 1
|
PHP
|
PHP
|
add beforeresolving method
|
61b4de9bc4693470d142395fdd475c5a0178aeb1
|
<ide><path>src/Illuminate/Container/Container.php
<ide> protected function unresolvablePrimitive(ReflectionParameter $parameter)
<ide> throw new BindingResolutionException($message);
<ide> }
<ide>
<add> /**
<add> * Register a new before resolving callback for all types.
<add> *
<add> * @param \Closure|string $abstract
<add> * @param \Closure|null $callback
<add> * @return void
<add> */
<add> public function beforeResolving($abstract, Closure $callback = null)
<add> {
<add> if (is_string($abstract)) {
<add> $abstract = $this->getAlias($abstract);
<add> }
<add>
<add> if ($abstract instanceof Closure && is_null($callback)) {
<add> $this->globalBeforeResolvingCallbacks[] = $abstract;
<add> } else {
<add> $this->beforeResolvingCallbacks[$abstract][] = $callback;
<add> }
<add> }
<add>
<ide> /**
<ide> * Register a new resolving callback.
<ide> *
<ide> public function afterResolving($abstract, Closure $callback = null)
<ide> * @param array $parameters
<ide> * @return void
<ide> */
<del> protected function fireBeforeResolvingCallbacks($abstract, $parameters)
<add> protected function fireBeforeResolvingCallbacks($abstract, $parameters = [])
<ide> {
<del> foreach ($this->globalBeforeResolvingCallbacks as $callback) {
<del> $callback($abstract, $parameters, $this);
<del> }
<add> $this->fireBeforeCallbackArray($abstract, $parameters, $this->globalBeforeResolvingCallbacks);
<ide>
<del> foreach ($this->beforeResolvingCallbacks as $type => $callback) {
<add> foreach ($this->beforeResolvingCallbacks as $type => $callbacks) {
<ide> if ($type === $abstract || is_subclass_of($abstract, $type)) {
<del> $callback($abstract, $parameters, $this);
<add> $this->fireBeforeCallbackArray($abstract, $parameters, $callbacks);
<ide> }
<ide> }
<ide> }
<ide>
<add> /**
<add> * Fire an array of callbacks with an object.
<add> *
<add> * @param string $abstract
<add> * @param array $parameters
<add> * @param array $callbacks
<add> * @return void
<add> */
<add> protected function fireBeforeCallbackArray($abstract, $parameters, array $callbacks)
<add> {
<add> foreach ($callbacks as $callback) {
<add> $callback($abstract, $parameters, $this);
<add> }
<add> }
<add>
<ide> /**
<ide> * Fire all of the resolving callbacks.
<ide> *
| 1
|
Ruby
|
Ruby
|
set the default log_level to info in all tests
|
6f08eeb6e8fe1082d5a427c0399c75ef8fcf380c
|
<ide><path>railties/test/isolation/abstract_unit.rb
<ide> def make_basic_app
<ide> app.secrets.secret_key_base = "3b7cd727ee24e8444053437c36cc66c4"
<ide> app.config.session_store :cookie_store, key: "_myapp_session"
<ide> app.config.active_support.deprecation = :log
<add> app.config.log_level = :info
<ide>
<ide> yield app if block_given?
<ide> app.initialize!
| 1
|
Javascript
|
Javascript
|
intialize start and end time as undefined in stats
|
6fa6720abcb3e6f07d29a5ba4bc4710bfc7b4f8d
|
<ide><path>lib/Stats.js
<ide> class Stats {
<ide> constructor(compilation) {
<ide> this.compilation = compilation;
<ide> this.hash = compilation.hash;
<add> this.startTime = undefined;
<add> this.endTime = undefined;
<ide> }
<ide>
<ide> static filterWarnings(warnings, warningsFilter) {
| 1
|
PHP
|
PHP
|
add zip function to collection
|
118dede7e042dc1678fbfd4320471a6e0ffa1ecf
|
<ide><path>src/Illuminate/Support/Collection.php
<ide> protected function valueRetriever($value)
<ide> };
<ide> }
<ide>
<add> /**
<add> * Zip the collection together with one or more arrays
<add> *
<add> * e.g. new Collection([1, 2, 3])->zip([4, 5, 6]);
<add> * => [[1, 4], [2, 5], [3, 6]]
<add> *
<add> * @param \Illuminate\Support\Collection|\Illuminate\Contracts\Support\Arrayable|array ...$items
<add> * @return static
<add> */
<add> public function zip($items)
<add> {
<add> $arrayableItems = array_map(function ($items) {
<add> return $this->getArrayableItems($items);
<add> }, func_get_args());
<add>
<add> $params = array_merge([function () {
<add> return new static(func_get_args());
<add> }, $this->items], $arrayableItems);
<add>
<add> return new static(call_user_func_array('array_map', $params));
<add> }
<add>
<ide> /**
<ide> * Get the collection of items as a plain array.
<ide> *
<ide><path>tests/Support/SupportCollectionTest.php
<ide> public function testPaginate()
<ide> $this->assertEquals([], $c->forPage(3, 2)->all());
<ide> }
<ide>
<add>
<add> public function testZip()
<add> {
<add> $c = new Collection([1, 2, 3]);
<add> $c = $c->zip(new Collection([4, 5, 6]));
<add> $this->assertInstanceOf('Illuminate\Support\Collection', $c);
<add> $this->assertInstanceOf('Illuminate\Support\Collection', $c[0]);
<add> $this->assertInstanceOf('Illuminate\Support\Collection', $c[1]);
<add> $this->assertInstanceOf('Illuminate\Support\Collection', $c[2]);
<add> $this->assertEquals(3, $c->count());
<add> $this->assertEquals([1, 4], $c[0]->all());
<add> $this->assertEquals([2, 5], $c[1]->all());
<add> $this->assertEquals([3, 6], $c[2]->all());
<add>
<add> $c = new Collection([1, 2, 3]);
<add> $c = $c->zip([4, 5, 6], [7, 8, 9]);
<add> $this->assertEquals(3, $c->count());
<add> $this->assertEquals([1, 4, 7], $c[0]->all());
<add> $this->assertEquals([2, 5, 8], $c[1]->all());
<add> $this->assertEquals([3, 6, 9], $c[2]->all());
<add>
<add> $c = new Collection([1, 2, 3]);
<add> $c = $c->zip([4, 5, 6], [7]);
<add> $this->assertEquals(3, $c->count());
<add> $this->assertEquals([1, 4, 7], $c[0]->all());
<add> $this->assertEquals([2, 5, null], $c[1]->all());
<add> $this->assertEquals([3, 6, null], $c[2]->all());
<add> }
<add>
<ide> }
<ide>
<ide> class TestAccessorEloquentTestStub
| 2
|
PHP
|
PHP
|
fix remaining failing helper tests
|
b50bfe5ae54ae9566c6a4af85e162316b087d1b3
|
<ide><path>tests/TestCase/View/Helper/FlashHelperTest.php
<ide> public function testFlashWithStack()
<ide> */
<ide> public function testFlashWithPrefix()
<ide> {
<del> $this->View->request->params['prefix'] = 'Admin';
<add> $this->View->request = $this->View->request->withParam('prefix', 'Admin');
<ide> $result = $this->Flash->render('flash');
<ide> $expected = 'flash element from Admin prefix folder';
<ide> $this->assertContains($expected, $result);
<ide><path>tests/TestCase/View/Helper/UrlHelperTest.php
<ide> public function testAssetTimestamp()
<ide> $result = $this->Helper->assetTimestamp(Configure::read('App.cssBaseUrl') . 'cake.generic.css?someparam');
<ide> $this->assertEquals(Configure::read('App.cssBaseUrl') . 'cake.generic.css?someparam', $result);
<ide>
<del> $this->Helper->request->webroot = '/some/dir/';
<add> $this->Helper->request = $this->Helper->request->withAttribute('webroot', '/some/dir/');
<ide> $result = $this->Helper->assetTimestamp('/some/dir/' . Configure::read('App.cssBaseUrl') . 'cake.generic.css');
<ide> $this->assertRegExp('/' . preg_quote(Configure::read('App.cssBaseUrl') . 'cake.generic.css?', '/') . '[0-9]+/', $result);
<ide> }
<ide> public function testCss()
<ide> */
<ide> public function testWebrootPaths()
<ide> {
<del> $this->Helper->request->webroot = '/';
<add> $this->Helper->request = $this->Helper->request->withAttribute('webroot', '/');
<ide> $result = $this->Helper->webroot('/img/cake.power.gif');
<ide> $expected = '/img/cake.power.gif';
<ide> $this->assertEquals($expected, $result);
| 2
|
Text
|
Text
|
fix fixes from testing with check-all-the-errors
|
a43ab685966c758c6bb4284e9d9dddcd373b1abf
|
<ide><path>threejs/lessons/ru/threejs-lights.md
<ide> scene.add(light.target);
<ide> scene.add(helper);
<ide> ```
<ide>
<del>Угол конуса прожектора задается с помощью свойства [`angle`](Spotlight.angle)
<add>Угол конуса прожектора задается с помощью свойства [`angle`](SpotLight.angle)
<ide> в радианах. Мы будем использовать наш `DegRadHelper` из
<ide> [статьи про текстуры](threejs-textures.html) для представления пользовательского интерфейса в градусах..
<ide>
<ide><path>threejs/lessons/ru/threejs-materials.md
<ide> const m5 = new THREE.MeshBasicMaterial({color: 'hsl(0,100%,50%)'); // red
<ide>
<ide> прим. переводчика:
<ide> Блик - световое пятно на ярко освещённой выпуклой или плоской глянцевой поверхности.
<del>[Зеркальное отражение](http://compgraph.tpu.ru/mir_reflection.htm) я часто буду называть бликом,
<add>[Зеркальное отражение](http://compgraph.tpu.ru/mir_reflection.html) я часто буду называть бликом,
<ide> хотя это скорее частный случай.
<ide>
<ide> Итак, давайте рассмотрим набор материалов Three.js.
<ide><path>threejs/lessons/ru/threejs-textures.md
<ide> Mips - это копии текстуры, каждая из которых в
<ide> которые используют 4 или 5 текстур одновременно. 4 текстуры * 8 пикселей на текстуру -
<ide> это поиск 32 пикселей для каждого пикселя. Это может быть особенно важно учитывать на мобильных устройствах.
<ide>
<del>## <a href="uvmanipulation"></a> Повторение, смещение, вращение, наложение текстуры
<add>## <a name="uvmanipulation"></a> Повторение, смещение, вращение, наложение текстуры
<ide>
<ide> Текстуры имеют настройки для повторения, смещения и поворота текстуры.
<ide>
<ide><path>threejs/lessons/threejs-align-html-elements-to-3d.md
<ide> where min, max, lat, lon, are all in latitude and longitude degrees.
<ide> Let's load it up. The code is based on the examples from [optimizing lots of
<ide> objects](threejs-optimize-lots-of-objects.html) though we are not drawing lots
<ide> of objects we'll be using the same solutions for [rendering on
<del>demand](threejs-rendering-on-demand.htm).
<add>demand](threejs-rendering-on-demand.html).
<ide>
<ide> The first thing is to make a sphere and use the outline texture.
<ide>
<ide><path>threejs/lessons/threejs-debugging-javascript.md
<ide> enormously in your learning.
<ide>
<ide> All browsers have developer tools.
<ide> [Chrome](https://developers.google.com/web/tools/chrome-devtools/),
<del>[Firefox](https://developer.mozilla.org/son/docs/Tools),
<add>[Firefox](https://developer.mozilla.org/en-US/docs/Tools),
<ide> [Safari](https://developer.apple.com/safari/tools/),
<ide> [Edge](https://docs.microsoft.com/en-us/microsoft-edge/devtools-guide).
<ide>
<ide><path>threejs/lessons/threejs-game.md
<ide> things. To do that I made a `StatusDisplayHelper` component.
<ide>
<ide> I uses a `PolarGridHelper` to draw a circle around each character
<ide> and it uses html elements to let each character show some status using
<del>the techniques covered in [the article on aligning html elements to 3D](threejs-align-html-elements-to-3d).
<add>the techniques covered in [the article on aligning html elements to 3D](threejs-align-html-elements-to-3d.html).
<ide>
<ide> First we need to add some HTML to host these elements
<ide>
<ide><path>threejs/lessons/threejs-indexed-textures.md
<ide> but what about highlighting the selected countries?
<ide>
<ide> For that we can take inspiration from *paletted graphics*.
<ide>
<del>[Paletted graphics](https://en.wikipedia.org/wiki/Palette_(computing))
<add>[Paletted graphics](https://en.wikipedia.org/wiki/Palette_%28computing%29)
<ide> or [Indexed Color](https://en.wikipedia.org/wiki/Indexed_color) is
<ide> what older systems like the Atari 800, Amiga, NES,
<ide> Super Nintendo, and even older IBM PCs used. Instead of storing bitmaps
<ide><path>threejs/lessons/threejs-lights.md
<ide> scene.add(light.target);
<ide> scene.add(helper);
<ide> ```
<ide>
<del>The spotlight's cone's angle is set with the [`angle`](Spotlight.angle)
<add>The spotlight's cone's angle is set with the [`angle`](SpotLight.angle)
<ide> property in radians. We'll use our `DegRadHelper` from the
<ide> [texture article](threejs-textures.html) to present a UI in
<ide> degrees.
<ide><path>threejs/lessons/threejs-offscreencanvas.md
<ide> of the DOM events they use. Maybe we could pass in our own
<ide> object that has the same API surface as a DOM element.
<ide> We only need to support the features the OrbitControls need.
<ide>
<del>Digging through the [OrbitControls source code](https://github.com/gfxfundamentals/threejsfundamentals/blob/master/threejs/resources/threejs/r112/js/controls/OrbitControls.js)
<add>Digging through the [OrbitControls source code](https://github.com/gfxfundamentals/threejsfundamentals/blob/master/threejs/resources/threejs/r112/examples/js/controls/OrbitControls.js)
<ide> it looks like we need to handle the following events.
<ide>
<ide> * contextmenu
<ide><path>threejs/lessons/threejs-optimize-lots-of-objects.md
<ide> re-create the [WebGL Globe](https://globe.chromeexperiments.com/).
<ide> The first thing we need to do is get some data. The WebGL Globe said the data
<ide> they use comes from [SEDAC](http://sedac.ciesin.columbia.edu/gpw/). Checking out
<ide> the site I saw there was [demographic data in a grid
<del>format](http://sedac.ciesin.columbia.edu/data/set/gpw-v4-basic-demographic-characteristics-rev10).
<add>format](https://beta.sedac.ciesin.columbia.edu/data/set/gpw-v4-basic-demographic-characteristics-rev10).
<ide> I downloaded the data at 60 minute resolution. Then I took a look at the data
<ide>
<ide> It looks like this
<ide> didn't do this it would scale from the center but we want them to grow away from
<ide> </div>
<ide>
<ide> Of course we could also solve that by parenting the box to more `THREE.Object3D`
<del>objects like we covered in [scene graphs](threejs-scenegraphs.html) but the more
<add>objects like we covered in [scene graphs](threejs-scenegraph.html) but the more
<ide> nodes we add to a scene graph the slower it gets.
<ide>
<ide> We also setup this small hierarchy of nodes of `lonHelper`, `latHelper`, and
<ide><path>threejs/lessons/threejs-prerequisites.md
<ide> for (const [key, value] of Object.entries(someObject)) {
<ide>
<ide> ### Use `forEach`, `map`, and `filter` where useful
<ide>
<del>Arrays added the functions [`forEach`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach,
<add>Arrays added the functions [`forEach`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach),
<ide> [`map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map), and
<ide> [`filter`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter) and
<ide> are used fairly extensively in modern JavaScript.
<ide><path>threejs/lessons/threejs-textures.md
<ide> we'll eventually have materials that use 4 or 5 textures all at once. 4 textures
<ide> pixels per texture is looking up 32 pixels for ever pixel rendered.
<ide> This can be especially important to consider on mobile devices.
<ide>
<del>## <a href="uvmanipulation"></a> Repeating, offseting, rotating, wrapping a texture
<add>## <a name="uvmanipulation"></a> Repeating, offseting, rotating, wrapping a texture
<ide>
<ide> Textures have settings for repeating, offseting, and rotating a texture.
<ide>
<ide><path>threejs/lessons/threejs-transparency.md
<ide> First we'll go over the easy part. Let's make a
<ide> scene with 8 cubes placed in a 2x2x2 grid.
<ide>
<ide> We'll start with the example from
<del>[the article on rendering on demand](threejs-rendering-on-demand.md)
<add>[the article on rendering on demand](threejs-rendering-on-demand.html)
<ide> which had 3 cubes and modify it to have 8. First
<ide> let's change our `makeInstance` function to take
<ide> an x, y, and z
<ide><path>threejs/lessons/threejs-webvr-look-to-select.md
<ide> selected.
<ide> Let's implement "look to select"! We'll start with
<ide> [an example from the previous article](threejs-webvr.html)
<ide> and to do it we'll add the `PickHelper` we made in
<del>[the article on picking](threejs-picking). Here it is.
<add>[the article on picking](threejs-picking.html). Here it is.
<ide>
<ide> ```js
<ide> class PickHelper {
| 14
|
Javascript
|
Javascript
|
add loaddocs android app to showcase
|
e59efc1f023e4c78c3973dcd2ed77385c6cc4261
|
<ide><path>website/src/react-native/showcase.js
<ide> var apps = [
<ide> {
<ide> name: 'LoadDocs',
<ide> icon: 'http://a2.mzstatic.com/us/r30/Purple3/v4/b5/ca/78/b5ca78ca-392d-6874-48bf-762293482d42/icon350x350.jpeg',
<del> link: 'https://itunes.apple.com/us/app/loaddocs/id1041596066',
<add> linkAppStore: 'https://itunes.apple.com/us/app/loaddocs/id1041596066',
<add> linkPlayStore: 'https://play.google.com/store/apps/details?id=com.convoy.loaddoc&hl=en',
<ide> author: 'LoadDocs',
<ide> },
<ide> {
| 1
|
Ruby
|
Ruby
|
remove obsolete comment [skip ci]
|
3e04e03598b03f548e096d12b303041a17db2073
|
<ide><path>actionpack/lib/action_dispatch/testing/assertions/routing.rb
<ide> def assert_generates(expected_path, options, defaults = {}, extras = {}, message
<ide> else
<ide> expected_path = "/#{expected_path}" unless expected_path.start_with?("/")
<ide> end
<del> # Load routes.rb if it hasn't been loaded.
<ide>
<ide> options = options.clone
<ide> generated_path, query_string_keys = @routes.generate_extras(options, defaults)
| 1
|
Text
|
Text
|
fix laterpay link
|
5377bda9420b5806cfcfceddcfdfbedf5629f6ce
|
<ide><path>docs/topics/kickstarter-announcement.md
<ide> Our platinum sponsors have each made a hugely substantial contribution to the fu
<ide> Our gold sponsors include companies large and small. Many thanks for their significant funding of the project and their commitment to sustainable open-source development.
<ide>
<ide> <ul class="sponsor gold">
<del><li><a href="https://laterpay-net/" rel="nofollow" style="background-image:url(../img/sponsors/2-laterpay.png);">LaterPay</a></li>
<add><li><a href="https://laterpay.net/" rel="nofollow" style="background-image:url(../img/sponsors/2-laterpay.png);">LaterPay</a></li>
<ide> <li><a href="https://www.schubergphilis.com/" rel="nofollow" style="background-image:url(../img/sponsors/2-schuberg_philis.png);">Schuberg Philis</a></li>
<ide> <!--Jens-->
<ide> <!--Silvio-->
| 1
|
Go
|
Go
|
fix tests in api_test.go
|
53a8229ce7f8d4d1dfb7a85a31ed25613a9f9813
|
<ide><path>api_test.go
<ide> import (
<ide> "net/http/httptest"
<ide> "os"
<ide> "path"
<add> "strings"
<ide> "testing"
<ide> "time"
<ide> )
<ide> func TestGetAuth(t *testing.T) {
<ide> if body == nil {
<ide> t.Fatalf("No body received\n")
<ide> }
<del> if r.Code != http.StatusOK {
<del> t.Fatalf("%d OK expected, received %d\n", http.StatusOK, r.Code)
<add> if r.Code != http.StatusOK && r.Code != 0 {
<add> t.Fatalf("%d OK or 0 expected, received %d\n", http.StatusOK, r.Code)
<ide> }
<ide>
<ide> if runtime.authConfig.Username != authConfig.Username ||
<ide> func TestGetImagesJson(t *testing.T) {
<ide>
<ide> srv := &Server{runtime: runtime}
<ide>
<del> // FIXME: Do more tests with filter
<del> req, err := http.NewRequest("GET", "/images/json?quiet=0&all=0", nil)
<add> // only_ids=0&all=0
<add> req, err := http.NewRequest("GET", "/images/json?only_ids=0&all=0", nil)
<ide> if err != nil {
<ide> t.Fatal(err)
<ide> }
<ide> func TestGetImagesJson(t *testing.T) {
<ide> if images[0].Repository != "docker-ut" {
<ide> t.Errorf("Excepted image docker-ut, %s found", images[0].Repository)
<ide> }
<add>
<add> // only_ids=1&all=1
<add> req2, err := http.NewRequest("GET", "/images/json?only_ids=1&all=1", nil)
<add> if err != nil {
<add> t.Fatal(err)
<add> }
<add>
<add> body2, err := getImagesJson(srv, nil, req2, nil)
<add> if err != nil {
<add> t.Fatal(err)
<add> }
<add>
<add> images2 := []ApiImages{}
<add> err = json.Unmarshal(body2, &images2)
<add> if err != nil {
<add> t.Fatal(err)
<add> }
<add>
<add> if len(images2) != 1 {
<add> t.Errorf("Excepted 1 image, %d found", len(images2))
<add> }
<add>
<add> if images2[0].Repository != "" {
<add> t.Errorf("Excepted no image Repository, %s found", images2[0].Repository)
<add> }
<add>
<add> if images2[0].Id == "" {
<add> t.Errorf("Excepted image Id, %s found", images2[0].Id)
<add> }
<add>
<add> // filter=a
<add> req3, err := http.NewRequest("GET", "/images/json?filter=a", nil)
<add> if err != nil {
<add> t.Fatal(err)
<add> }
<add>
<add> body3, err := getImagesJson(srv, nil, req3, nil)
<add> if err != nil {
<add> t.Fatal(err)
<add> }
<add>
<add> images3 := []ApiImages{}
<add> err = json.Unmarshal(body3, &images3)
<add> if err != nil {
<add> t.Fatal(err)
<add> }
<add>
<add> if len(images3) != 0 {
<add> t.Errorf("Excepted 1 image, %d found", len(images3))
<add> }
<ide> }
<ide>
<ide> func TestGetImagesViz(t *testing.T) {
<del> //FIXME: Implement this test (or remove this endpoint)
<del> t.Log("Test not implemented")
<add> runtime, err := newTestRuntime()
<add> if err != nil {
<add> t.Fatal(err)
<add> }
<add> defer nuke(runtime)
<add>
<add> srv := &Server{runtime: runtime}
<add>
<add> r := httptest.NewRecorder()
<add>
<add> _, err = getImagesViz(srv, r, nil, nil)
<add> if err != nil {
<add> t.Fatal(err)
<add> }
<add>
<add> if r.Code != http.StatusOK {
<add> t.Fatalf("%d OK expected, received %d\n", http.StatusOK, r.Code)
<add> }
<add>
<add> reader := bufio.NewReader(r.Body)
<add> line, err := reader.ReadString('\n')
<add> if err != nil {
<add> t.Fatal(err)
<add> }
<add> if line != "digraph docker {\n" {
<add> t.Errorf("Excepted digraph docker {\n, %s found", line)
<add> }
<ide> }
<ide>
<ide> func TestGetImagesSearch(t *testing.T) {
<ide> func TestGetContainersPs(t *testing.T) {
<ide> }
<ide>
<ide> func TestGetContainersExport(t *testing.T) {
<del> //FIXME: Implement this test
<del> t.Log("Test not implemented")
<add> runtime, err := newTestRuntime()
<add> if err != nil {
<add> t.Fatal(err)
<add> }
<add> defer nuke(runtime)
<add>
<add> srv := &Server{runtime: runtime}
<add>
<add> builder := NewBuilder(runtime)
<add>
<add> // Create a container and remove a file
<add> container, err := builder.Create(
<add> &Config{
<add> Image: GetTestImage(runtime).Id,
<add> Cmd: []string{"/bin/rm", "/etc/passwd"},
<add> },
<add> )
<add> if err != nil {
<add> t.Fatal(err)
<add> }
<add> defer runtime.Destroy(container)
<add>
<add> if err := container.Run(); err != nil {
<add> t.Fatal(err)
<add> }
<add>
<add> r := httptest.NewRecorder()
<add>
<add> _, err = getContainersExport(srv, r, nil, map[string]string{"name": container.Id})
<add> if err != nil {
<add> t.Fatal(err)
<add> }
<add>
<add> if r.Code != http.StatusOK {
<add> t.Fatalf("%d OK expected, received %d\n", http.StatusOK, r.Code)
<add> }
<add>
<add> if r.Body == nil {
<add> t.Fatalf("Body expected, found 0")
<add> }
<ide> }
<ide>
<ide> func TestGetContainersChanges(t *testing.T) {
<ide> func TestGetContainersChanges(t *testing.T) {
<ide> }
<ide>
<ide> func TestGetContainersByName(t *testing.T) {
<del> //FIXME: Implement this test
<del> t.Log("Test not implemented")
<add> runtime, err := newTestRuntime()
<add> if err != nil {
<add> t.Fatal(err)
<add> }
<add> defer nuke(runtime)
<add>
<add> srv := &Server{runtime: runtime}
<add>
<add> builder := NewBuilder(runtime)
<add>
<add> // Create a container and remove a file
<add> container, err := builder.Create(
<add> &Config{
<add> Image: GetTestImage(runtime).Id,
<add> Cmd: []string{"/bin/rm", "/etc/passwd"},
<add> },
<add> )
<add> if err != nil {
<add> t.Fatal(err)
<add> }
<add> defer runtime.Destroy(container)
<add>
<add> body, err := getContainersByName(srv, nil, nil, map[string]string{"name": container.Id})
<add> if err != nil {
<add> t.Fatal(err)
<add> }
<add> outContainer := Container{}
<add> if err := json.Unmarshal(body, &outContainer); err != nil {
<add> t.Fatal(err)
<add> }
<ide> }
<ide>
<ide> func TestPostAuth(t *testing.T) {
<ide> func TestPostAuth(t *testing.T) {
<ide> }
<ide>
<ide> func TestPostCommit(t *testing.T) {
<del> //FIXME: Implement this test
<del> t.Log("Test not implemented")
<add> runtime, err := newTestRuntime()
<add> if err != nil {
<add> t.Fatal(err)
<add> }
<add> defer nuke(runtime)
<add>
<add> srv := &Server{runtime: runtime}
<add>
<add> r := httptest.NewRecorder()
<add>
<add> builder := NewBuilder(runtime)
<add>
<add> // Create a container and remove a file
<add> container, err := builder.Create(
<add> &Config{
<add> Image: GetTestImage(runtime).Id,
<add> Cmd: []string{"/bin/rm", "/etc/passwd"},
<add> },
<add> )
<add> if err != nil {
<add> t.Fatal(err)
<add> }
<add> defer runtime.Destroy(container)
<add>
<add> if err := container.Run(); err != nil {
<add> t.Fatal(err)
<add> }
<add>
<add> req, err := http.NewRequest("POST", "/commit?repo=testrepo&testtag=tag&container="+container.Id, bytes.NewReader([]byte{}))
<add> if err != nil {
<add> t.Fatal(err)
<add> }
<add>
<add> body, err := postCommit(srv, r, req, nil)
<add> if err != nil {
<add> t.Fatal(err)
<add> }
<add>
<add> if body == nil {
<add> t.Fatalf("Body expected, received: 0\n")
<add> }
<add> if r.Code != http.StatusCreated {
<add> t.Fatalf("%d Created expected, received %d\n", http.StatusCreated, r.Code)
<add> }
<ide> }
<ide>
<ide> func TestPostBuild(t *testing.T) {
<del> //FIXME: Implement this test
<del> t.Log("Test not implemented")
<add> runtime, err := newTestRuntime()
<add> if err != nil {
<add> t.Fatal(err)
<add> }
<add> defer nuke(runtime)
<add>
<add> srv := &Server{runtime: runtime}
<add>
<add> stdin, stdinPipe := io.Pipe()
<add> stdout, stdoutPipe := io.Pipe()
<add>
<add> c1 := make(chan struct{})
<add> go func() {
<add> r := &hijackTester{
<add> ResponseRecorder: httptest.NewRecorder(),
<add> in: stdin,
<add> out: stdoutPipe,
<add> }
<add>
<add> body, err := postBuild(srv, r, nil, nil)
<add> close(c1)
<add> if err != nil {
<add> t.Fatal(err)
<add> }
<add> if body != nil {
<add> t.Fatalf("No body expected, received: %s\n", body)
<add> }
<add> }()
<add>
<add> // Acknowledge hijack
<add> setTimeout(t, "hijack acknowledge timed out", 2*time.Second, func() {
<add> stdout.Read([]byte{})
<add> stdout.Read(make([]byte, 4096))
<add> })
<add>
<add> setTimeout(t, "read/write assertion timed out", 2*time.Second, func() {
<add> if err := assertPipe("from docker-ut\n", "FROM docker-ut", stdout, stdinPipe, 15); err != nil {
<add> t.Fatal(err)
<add> }
<add> })
<add>
<add> // Close pipes (client disconnects)
<add> if err := closeWrap(stdin, stdinPipe, stdout, stdoutPipe); err != nil {
<add> t.Fatal(err)
<add> }
<add>
<add> // Wait for build to finish, the client disconnected, therefore, Build finished his job
<add> setTimeout(t, "Waiting for CmdBuild timed out", 2*time.Second, func() {
<add> <-c1
<add> })
<add>
<ide> }
<ide>
<ide> func TestPostImagesCreate(t *testing.T) {
<del> //FIXME: Implement this test
<del> t.Log("Test not implemented")
<add> runtime, err := newTestRuntime()
<add> if err != nil {
<add> t.Fatal(err)
<add> }
<add> defer nuke(runtime)
<add>
<add> srv := &Server{runtime: runtime}
<add>
<add> stdin, stdinPipe := io.Pipe()
<add> stdout, stdoutPipe := io.Pipe()
<add>
<add> c1 := make(chan struct{})
<add> go func() {
<add> r := &hijackTester{
<add> ResponseRecorder: httptest.NewRecorder(),
<add> in: stdin,
<add> out: stdoutPipe,
<add> }
<add>
<add> req, err := http.NewRequest("POST", "/images/create?fromImage=docker-ut", bytes.NewReader([]byte{}))
<add> if err != nil {
<add> t.Fatal(err)
<add> }
<add>
<add> body, err := postImagesCreate(srv, r, req, nil)
<add> close(c1)
<add> if err != nil {
<add> t.Fatal(err)
<add> }
<add> if body != nil {
<add> t.Fatalf("No body expected, received: %s\n", body)
<add> }
<add> }()
<add>
<add> // Acknowledge hijack
<add> setTimeout(t, "hijack acknowledge timed out", 2*time.Second, func() {
<add> stdout.Read([]byte{})
<add> stdout.Read(make([]byte, 4096))
<add> })
<add>
<add> setTimeout(t, "Waiting for imagesCreate output", 5*time.Second, func() {
<add> reader := bufio.NewReader(stdout)
<add> line, err := reader.ReadString('\n')
<add> if err != nil {
<add> t.Fatal(err)
<add> }
<add> if !strings.HasPrefix(line, "Pulling repository docker-ut from") {
<add> t.Fatalf("Expected Pulling repository docker-ut from..., found %s", line)
<add> }
<add> })
<add>
<add> // Close pipes (client disconnects)
<add> if err := closeWrap(stdin, stdinPipe, stdout, stdoutPipe); err != nil {
<add> t.Fatal(err)
<add> }
<add>
<add> // Wait for imagesCreate to finish, the client disconnected, therefore, Create finished his job
<add> setTimeout(t, "Waiting for imagesCreate timed out", 10*time.Second, func() {
<add> <-c1
<add> })
<ide> }
<ide>
<ide> func TestPostImagesInsert(t *testing.T) {
<ide> func TestPostImagesInsert(t *testing.T) {
<ide> }
<ide>
<ide> func TestPostImagesPush(t *testing.T) {
<del> //FIXME: Implement this test
<del> t.Log("Test not implemented")
<add> runtime, err := newTestRuntime()
<add> if err != nil {
<add> t.Fatal(err)
<add> }
<add> defer nuke(runtime)
<add>
<add> srv := &Server{runtime: runtime}
<add>
<add> stdin, stdinPipe := io.Pipe()
<add> stdout, stdoutPipe := io.Pipe()
<add>
<add> c1 := make(chan struct{})
<add> go func() {
<add> r := &hijackTester{
<add> ResponseRecorder: httptest.NewRecorder(),
<add> in: stdin,
<add> out: stdoutPipe,
<add> }
<add>
<add> req, err := http.NewRequest("POST", "/images/docker-ut/push", bytes.NewReader([]byte{}))
<add> if err != nil {
<add> t.Fatal(err)
<add> }
<add>
<add> body, err := postImagesPush(srv, r, req, map[string]string{"name": "docker-ut"})
<add> close(c1)
<add> if err != nil {
<add> t.Fatal(err)
<add> }
<add> if body != nil {
<add> t.Fatalf("No body expected, received: %s\n", body)
<add> }
<add> }()
<add>
<add> // Acknowledge hijack
<add> setTimeout(t, "hijack acknowledge timed out", 2*time.Second, func() {
<add> stdout.Read([]byte{})
<add> stdout.Read(make([]byte, 4096))
<add> })
<add>
<add> setTimeout(t, "Waiting for imagesCreate output", 5*time.Second, func() {
<add> reader := bufio.NewReader(stdout)
<add> line, err := reader.ReadString('\n')
<add> if err != nil {
<add> t.Fatal(err)
<add> }
<add> if !strings.HasPrefix(line, "Processing checksum") {
<add> t.Fatalf("Processing checksum..., found %s", line)
<add> }
<add> })
<add>
<add> // Close pipes (client disconnects)
<add> if err := closeWrap(stdin, stdinPipe, stdout, stdoutPipe); err != nil {
<add> t.Fatal(err)
<add> }
<add>
<add> // Wait for imagesPush to finish, the client disconnected, therefore, Push finished his job
<add> setTimeout(t, "Waiting for imagesPush timed out", 10*time.Second, func() {
<add> <-c1
<add> })
<ide> }
<ide>
<ide> func TestPostImagesTag(t *testing.T) {
<del> //FIXME: Implement this test
<del> t.Log("Test not implemented")
<add> runtime, err := newTestRuntime()
<add> if err != nil {
<add> t.Fatal(err)
<add> }
<add> defer nuke(runtime)
<add>
<add> srv := &Server{runtime: runtime}
<add>
<add> r := httptest.NewRecorder()
<add>
<add> req, err := http.NewRequest("POST", "/images/docker-ut/tag?repo=testrepo&tag=testtag", bytes.NewReader([]byte{}))
<add> if err != nil {
<add> t.Fatal(err)
<add> }
<add>
<add> body, err := postImagesTag(srv, r, req, map[string]string{"name": "docker-ut"})
<add> if err != nil {
<add> t.Fatal(err)
<add> }
<add>
<add> if body != nil {
<add> t.Fatalf("No body expected, received: %s\n", body)
<add> }
<add> if r.Code != http.StatusCreated {
<add> t.Fatalf("%d Created expected, received %d\n", http.StatusCreated, r.Code)
<add> }
<ide> }
<ide>
<ide> func TestPostContainersCreate(t *testing.T) {
| 1
|
Go
|
Go
|
move isgittransport() to gitutils
|
d3d1aabcc68f65d40acbf1b3adc02d13997bb8e2
|
<ide><path>builder/remotecontext/git/gitutils.go
<ide> func Clone(remoteURL string) (string, error) {
<ide> func parseRemoteURL(remoteURL string) (gitRepo, error) {
<ide> repo := gitRepo{}
<ide>
<del> if !urlutil.IsGitTransport(remoteURL) {
<add> if !isGitTransport(remoteURL) {
<ide> remoteURL = "https://" + remoteURL
<ide> }
<ide>
<ide> func gitWithinDir(dir string, args ...string) ([]byte, error) {
<ide> func git(args ...string) ([]byte, error) {
<ide> return exec.Command("git", args...).CombinedOutput()
<ide> }
<add>
<add>// isGitTransport returns true if the provided str is a git transport by inspecting
<add>// the prefix of the string for known protocols used in git.
<add>func isGitTransport(str string) bool {
<add> return urlutil.IsURL(str) || strings.HasPrefix(str, "git://") || strings.HasPrefix(str, "git@")
<add>}
<ide><path>builder/remotecontext/git/gitutils_test.go
<ide> func TestCheckoutGit(t *testing.T) {
<ide> assert.Equal(t, c.exp, string(b))
<ide> }
<ide> }
<add>
<add>func TestValidGitTransport(t *testing.T) {
<add> gitUrls := []string{
<add> "git://github.com/docker/docker",
<add> "git@github.com:docker/docker.git",
<add> "git@bitbucket.org:atlassianlabs/atlassian-docker.git",
<add> "https://github.com/docker/docker.git",
<add> "http://github.com/docker/docker.git",
<add> "http://github.com/docker/docker.git#branch",
<add> "http://github.com/docker/docker.git#:dir",
<add> }
<add> incompleteGitUrls := []string{
<add> "github.com/docker/docker",
<add> }
<add>
<add> for _, url := range gitUrls {
<add> if !isGitTransport(url) {
<add> t.Fatalf("%q should be detected as valid Git prefix", url)
<add> }
<add> }
<add>
<add> for _, url := range incompleteGitUrls {
<add> if isGitTransport(url) {
<add> t.Fatalf("%q should not be detected as valid Git prefix", url)
<add> }
<add> }
<add>}
<ide><path>pkg/urlutil/urlutil.go
<ide> func IsGitURL(str string) bool {
<ide> return checkURL(str, "git")
<ide> }
<ide>
<del>// IsGitTransport returns true if the provided str is a git transport by inspecting
<del>// the prefix of the string for known protocols used in git.
<del>func IsGitTransport(str string) bool {
<del> return IsURL(str) || strings.HasPrefix(str, "git://") || strings.HasPrefix(str, "git@")
<del>}
<del>
<ide> // IsTransportURL returns true if the provided str is a transport (tcp, tcp+tls, udp, unix) URL.
<ide> func IsTransportURL(str string) bool {
<ide> return checkURL(str, "transport")
<ide><path>pkg/urlutil/urlutil_test.go
<ide> var (
<ide> }
<ide> )
<ide>
<del>func TestValidGitTransport(t *testing.T) {
<del> for _, url := range gitUrls {
<del> if !IsGitTransport(url) {
<del> t.Fatalf("%q should be detected as valid Git prefix", url)
<del> }
<del> }
<del>
<del> for _, url := range incompleteGitUrls {
<del> if IsGitTransport(url) {
<del> t.Fatalf("%q should not be detected as valid Git prefix", url)
<del> }
<del> }
<del>}
<del>
<ide> func TestIsGIT(t *testing.T) {
<ide> for _, url := range gitUrls {
<ide> if !IsGitURL(url) {
| 4
|
Ruby
|
Ruby
|
remove versions module
|
5194d74c2142c5d0bd4671f2c5eddea821d58661
|
<ide><path>Library/Homebrew/utils/versions.rb
<del># frozen_string_literal: true
<del>
<del>module Versions
<del> module_function
<del>
<del> def current_formula_version(formula_name)
<del> Formula[formula_name].version.to_s.to_f
<del> rescue
<del> nil
<del> end
<del>
<del> def livecheck_formula(formula)
<del> ohai "Checking livecheck formula : #{formula}" if Homebrew.args.verbose?
<del>
<del> response = Utils.popen_read(HOMEBREW_BREW_FILE, "livecheck", formula, "--quiet").chomp
<del>
<del> parse_livecheck_response(response)
<del> end
<del>
<del> def parse_livecheck_response(response)
<del> output = response.delete(" ").split(/:|==>/)
<del>
<del> # eg: ["openclonk", "7.0", "8.1"]
<del> package_name, brew_version, latest_version = output
<del>
<del> {
<del> name: package_name,
<del> formula_version: brew_version,
<del> livecheck_version: latest_version,
<del> }
<del> end
<del>
<del> def fetch_pull_requests(query, tap_full_name, state: nil)
<del> GitHub.issues_for_formula(query, tap_full_name: tap_full_name, state: state).select do |pr|
<del> pr["html_url"].include?("/pull/") &&
<del> /(^|\s)#{Regexp.quote(query)}(:|\s|$)/i =~ pr["title"]
<del> end
<del> rescue GitHub::RateLimitExceededError => e
<del> opoo e.message
<del> []
<del> end
<del>
<del> def check_for_duplicate_pull_requests(formula, version)
<del> formula = Formula[formula]
<del> tap_full_name = formula.tap&.full_name
<del>
<del> # check for open requests
<del> pull_requests = fetch_pull_requests(formula.name, tap_full_name, state: "open")
<del>
<del> # if we haven't already found open requests, try for an exact match across all requests
<del> pull_requests = fetch_pull_requests("#{formula.name} #{version}", tap_full_name) if pull_requests.blank?
<del> return if pull_requests.blank?
<del>
<del> pull_requests.map { |pr| { title: pr["title"], url: pr["html_url"] } }
<del> end
<del>end
| 1
|
Ruby
|
Ruby
|
use github api to get pr commits
|
415c36041a87ef59eab0c04f557f8f498d762b90
|
<ide><path>Library/Homebrew/dev-cmd/pr-pull.rb
<ide> def autosquash!(original_commit, path: ".", args: nil)
<ide> raise
<ide> end
<ide>
<del> def cherry_pick_pr!(pr, args:, path: ".")
<add> def cherry_pick_pr!(user, repo, pr, args:, path: ".")
<ide> if args.dry_run?
<ide> puts <<~EOS
<ide> git fetch --force origin +refs/pull/#{pr}/head
<ide> git merge-base HEAD FETCH_HEAD
<ide> git cherry-pick --ff --allow-empty $merge_base..FETCH_HEAD
<ide> EOS
<del> else
<del> safe_system "git", "-C", path, "fetch", "--quiet", "--force", "origin", "+refs/pull/#{pr}/head"
<del> merge_base = Utils.popen_read("git", "-C", path, "merge-base", "HEAD", "FETCH_HEAD").strip
<del> commit_count = Utils.popen_read("git", "-C", path, "rev-list", "#{merge_base}..FETCH_HEAD").lines.count
<del>
<del> ohai "Using #{commit_count} commit#{"s" unless commit_count == 1} from ##{pr}"
<del> Utils::Git.cherry_pick!(path, "--ff", "--allow-empty", "#{merge_base}..FETCH_HEAD",
<del> verbose: args.verbose?, resolve: args.resolve?)
<add> return
<ide> end
<add>
<add> commits = GitHub.pull_request_commits(user, repo, pr)
<add> safe_system "git", "-C", path, "fetch", "--quiet", "--force", "origin", commits.last
<add> ohai "Using #{commits.count} commit#{"s" unless commits.count == 1} from ##{pr}"
<add> Utils::Git.cherry_pick!(path, "--ff", "--allow-empty", *commits, verbose: args.verbose?, resolve: args.resolve?)
<ide> end
<ide>
<ide> def check_branch(path, ref, args:)
<ide> def pr_pull
<ide> Dir.mktmpdir pr do |dir|
<ide> cd dir do
<ide> original_commit = Utils.popen_read("git", "-C", tap.path, "rev-parse", "HEAD").chomp
<del> cherry_pick_pr!(pr, path: tap.path, args: args)
<add> cherry_pick_pr!(user, repo, pr, path: tap.path, args: args)
<ide> autosquash!(original_commit, path: tap.path, args: args) if args.autosquash?
<ide> signoff!(pr, tap: tap, args: args) unless args.clean?
<ide>
<ide><path>Library/Homebrew/test/utils/github_spec.rb
<ide> expect(url).to eq("https://api.github.com/repos/Homebrew/homebrew-core/actions/artifacts/3557392/zip")
<ide> end
<ide> end
<add>
<add> describe "::pull_request_commits", :needs_network do
<add> it "gets the correct commits hashes for a pull request" do
<add> hashes = %w[188606a4a9587365d930b02c98ad6857b1d00150 25a71fe1ea1558415d6496d23834dc70778ddee5]
<add> expect(subject.pull_request_commits("Homebrew", "legacy-homebrew", 50678)).to eq(hashes)
<add> end
<add> end
<ide> end
<ide><path>Library/Homebrew/utils/github.rb
<ide> def create_bump_pr(info, args:)
<ide> end
<ide> end
<ide> end
<add>
<add> def pull_request_commits(user, repo, pr)
<add> open_api(url_to("repos", user, repo, "pulls", pr, "commits?per_page=100")).map { |c| c["sha"] }
<add> end
<ide> end
| 3
|
PHP
|
PHP
|
fix route bidnings
|
544faace7a605ab2dbf91365f4d46502194357f8
|
<ide><path>src/Illuminate/Routing/RouteDependencyResolverTrait.php
<ide> protected function resolveClassMethodDependencies(array $parameters, $instance,
<ide> /**
<ide> * Resolve the given method's type-hinted dependencies.
<ide> *
<del> * @param array $parameters
<add> * @param array $originalParameters
<ide> * @param \ReflectionFunctionAbstract $reflector
<ide> * @return array
<ide> */
<del> public function resolveMethodDependencies(array $parameters, ReflectionFunctionAbstract $reflector)
<add> public function resolveMethodDependencies(array $originalParameters, ReflectionFunctionAbstract $reflector)
<ide> {
<del> $originalParameters = $parameters;
<add> $parameters = [];
<add>
<add> $values = array_values($originalParameters);
<add>
<add> $instancesCount = 0;
<ide>
<ide> foreach ($reflector->getParameters() as $key => $parameter) {
<ide> $instance = $this->transformDependency(
<del> $parameter, $parameters, $originalParameters
<add> $parameter, $originalParameters
<ide> );
<ide>
<ide> if (! is_null($instance)) {
<del> $this->spliceIntoParameters($parameters, $key, $instance);
<add> $instancesCount++;
<add>
<add> $parameters[] = $instance;
<add> } else {
<add> $parameters[] = isset($values[$key - $instancesCount])
<add> ? $values[$key - $instancesCount] : $parameter->getDefaultValue();
<ide> }
<ide> }
<ide>
<ide> public function resolveMethodDependencies(array $parameters, ReflectionFunctionA
<ide> *
<ide> * @param \ReflectionParameter $parameter
<ide> * @param array $parameters
<del> * @param array $originalParameters
<ide> * @return mixed
<ide> */
<del> protected function transformDependency(ReflectionParameter $parameter, $parameters, $originalParameters)
<add> protected function transformDependency(ReflectionParameter $parameter, $parameters)
<ide> {
<ide> $class = $parameter->getClass();
<ide>
<ide> protected function alreadyInParameters($class, array $parameters)
<ide> return $value instanceof $class;
<ide> }));
<ide> }
<del>
<del> /**
<del> * Splice the given value into the parameter list.
<del> *
<del> * @param array $parameters
<del> * @param string $key
<del> * @param mixed $instance
<del> * @return void
<del> */
<del> protected function spliceIntoParameters(array &$parameters, $key, $instance)
<del> {
<del> array_splice(
<del> $parameters, $key, 0, [$instance]
<del> );
<del> }
<ide> }
<ide><path>tests/Routing/RoutingRouteTest.php
<ide> public function testClassesCanBeInjectedIntoRoutes()
<ide> unset($_SERVER['__test.route_inject']);
<ide> }
<ide>
<add> public function testClassesAndVariablesCanBeInjectedIntoRoutes()
<add> {
<add> unset($_SERVER['__test.route_inject']);
<add> $router = $this->getRouter();
<add> $router->get('foo/{var}/{bar?}/{baz?}', function (stdClass $foo, $var, $bar = 'test', Request $baz = null) {
<add> $_SERVER['__test.route_inject'] = func_get_args();
<add>
<add> return 'hello';
<add> });
<add> $this->assertEquals('hello', $router->dispatch(Request::create('foo/bar', 'GET'))->getContent());
<add> $this->assertInstanceOf('stdClass', $_SERVER['__test.route_inject'][0]);
<add> $this->assertEquals('bar', $_SERVER['__test.route_inject'][1]);
<add> $this->assertEquals('test', $_SERVER['__test.route_inject'][2]);
<add> $this->assertArrayHasKey(3, $_SERVER['__test.route_inject']);
<add> $this->assertInstanceOf('Illuminate\Http\Request', $_SERVER['__test.route_inject'][3]);
<add> unset($_SERVER['__test.route_inject']);
<add> }
<add>
<ide> public function testOptionsResponsesAreGeneratedByDefault()
<ide> {
<ide> $router = $this->getRouter();
| 2
|
Ruby
|
Ruby
|
move runtime back to connection
|
304c49b1468ce71beb7e3ea0ca4c5add73a1534e
|
<ide><path>activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
<ide> class AbstractAdapter
<ide> include QueryCache
<ide> include ActiveSupport::Callbacks
<ide>
<add> attr_accessor :runtime
<ide> define_callbacks :checkout, :checkin
<ide>
<ide> def initialize(connection, logger = nil) #:nodoc:
<ide> @active = nil
<ide> @connection, @logger = connection, logger
<add> @runtime = 0
<ide> @query_cache_enabled = false
<ide> @query_cache = {}
<ide> end
<ide> def prefetch_primary_key?(table_name = nil)
<ide> false
<ide> end
<ide>
<add> def reset_runtime #:nodoc:
<add> rt, @runtime = @runtime, 0
<add> rt
<add> end
<add>
<ide> # QUOTING ==================================================
<ide>
<ide> # Override to return the quoted table name. Defaults to column quoting.
<ide><path>activerecord/lib/active_record/log_subscriber.rb
<ide> module ActiveRecord
<ide> class LogSubscriber < ActiveSupport::LogSubscriber
<del> def self.runtime=(value)
<del> Thread.current["active_record_sql_runtime"] = value
<del> end
<del>
<del> def self.runtime
<del> Thread.current["active_record_sql_runtime"] ||= 0
<del> end
<del>
<del> def self.reset_runtime
<del> rt, self.runtime = runtime, 0
<del> rt
<del> end
<del>
<ide> def initialize
<ide> super
<ide> @odd_or_even = false
<ide> end
<ide>
<ide> def sql(event)
<del> self.class.runtime += event.duration
<add> connection.runtime += event.duration
<ide> return unless logger.debug?
<ide>
<ide> name = '%s (%.1fms)' % [event.payload[:name], event.duration]
<ide> def odd?
<ide> @odd_or_even = !@odd_or_even
<ide> end
<ide>
<add> def connection
<add> ActiveRecord::Base.connection
<add> end
<add>
<ide> def logger
<ide> ActiveRecord::Base.logger
<ide> end
<ide> end
<ide> end
<ide>
<del>ActiveRecord::LogSubscriber.attach_to :active_record
<ide>\ No newline at end of file
<add>ActiveRecord::LogSubscriber.attach_to :active_record
<ide><path>activerecord/lib/active_record/railties/controller_runtime.rb
<ide> module ControllerRuntime
<ide>
<ide> def cleanup_view_runtime
<ide> if ActiveRecord::Base.connected?
<del> db_rt_before_render = ActiveRecord::LogSubscriber.reset_runtime
<add> db_rt_before_render = ActiveRecord::Base.connection.reset_runtime
<ide> runtime = super
<del> db_rt_after_render = ActiveRecord::LogSubscriber.reset_runtime
<add> db_rt_after_render = ActiveRecord::Base.connection.reset_runtime
<ide> self.db_runtime = db_rt_before_render + db_rt_after_render
<ide> runtime - db_rt_after_render
<ide> else
<ide><path>activerecord/test/cases/log_subscriber_test.rb
<ide> def test_cached_queries_doesnt_log_when_level_is_not_debug
<ide> wait
<ide> assert_equal 0, @logger.logged(:debug).size
<ide> end
<del>
<del> def test_initializes_runtime
<del> Thread.new { assert_equal 0, ActiveRecord::LogSubscriber.runtime }.join
<del> end
<ide> end
| 4
|
PHP
|
PHP
|
update auth test case
|
590872d3c6ec91d06fcc3c21e70a34d4de0be8a7
|
<ide><path>laravel/tests/cases/auth.test.php
<ide> class AuthTest extends PHPUnit_Framework_TestCase {
<ide> public function setUp()
<ide> {
<ide> $_SERVER['auth.login.stub'] = null;
<add> $_SERVER['test.user.login'] = null;
<add> $_SERVER['test.user.logout'] = null;
<add>
<ide> Cookie::$jar = array();
<ide> Config::$items = array();
<ide> Auth::driver()->user = null;
<ide> public function setUp()
<ide> public function tearDown()
<ide> {
<ide> $_SERVER['auth.login.stub'] = null;
<add> $_SERVER['test.user.login'] = null;
<add> $_SERVER['test.user.logout'] = null;
<add>
<ide> Cookie::$jar = array();
<ide> Config::$items = array();
<ide> Auth::driver()->user = null;
<ide> public function testLogoutMethodLogsOutUser()
<ide> $this->assertTrue(Cookie::$jar['laravel_auth_drivers_fluent_remember']['expiration'] < time());
<ide> }
<ide>
<add> /**
<add> * Test `laravel.auth: login` and `laravel.auth: logout` is called properly
<add> *
<add> * @group laravel
<add> */
<add> public function testAuthEventIsCalledProperly()
<add> {
<add> Session::$instance = new Payload($this->getMock('Laravel\\Session\\Drivers\\Driver'));
<add>
<add> Event::listen('laravel.auth: login', function ()
<add> {
<add> $_SERVER['test.user.login'] = 'foo';
<add> });
<add>
<add> Event::listen('laravel.auth: logout', function ()
<add> {
<add> $_SERVER['test.user.logout'] = 'foo';
<add> });
<add>
<add> $this->assertNull($_SERVER['test.user.login']);
<add> $this->assertNull($_SERVER['test.user.logout']);
<add>
<add> Auth::login(1, true);
<add>
<add> $this->assertEquals('foo', $_SERVER['test.user.login']);
<add>
<add> Auth::logout();
<add>
<add> $this->assertEquals('foo', $_SERVER['test.user.logout']);
<add> }
<add>
<ide> }
<ide>
<ide> class AuthUserReturnsNull extends Laravel\Auth\Drivers\Driver {
| 1
|
Python
|
Python
|
fix compatibility comment regarding ordereddict
|
07ad0474c0cef8f8e88d299eca9dffbe6d01c10d
|
<ide><path>rest_framework/compat.py
<ide> def unicode_to_repr(value):
<ide> # OrderedDict only available in Python 2.7.
<ide> # This will always be the case in Django 1.7 and above, as these versions
<ide> # no longer support Python 2.6.
<del># For Django <= 1.6 and Python 2.6 fall back to OrderedDict.
<add># For Django <= 1.6 and Python 2.6 fall back to SortedDict.
<ide> try:
<ide> from collections import OrderedDict
<ide> except ImportError:
| 1
|
Javascript
|
Javascript
|
add more unit-tests for `primitives.js`
|
d70e07fb90715807f3585aa60edf631778e8ae6e
|
<ide><path>test/unit/primitives_spec.js
<ide> /* globals expect, it, describe, beforeEach, Name, Dict, Ref, RefSet, Cmd,
<del> jasmine, isDict, isRefsEqual */
<add> jasmine, isName, isCmd, isDict, isRef, isRefsEqual */
<ide>
<ide> 'use strict';
<ide>
<ide> describe('primitives', function() {
<add> function XRefMock(array) {
<add> this.map = Object.create(null);
<add> for (var elem in array) {
<add> var obj = array[elem];
<add> var ref = obj.ref, data = obj.data;
<add> this.map[ref.toString()] = data;
<add> }
<add> }
<add> XRefMock.prototype = {
<add> fetch: function (ref) {
<add> return this.map[ref.toString()];
<add> },
<add> fetchIfRef: function (obj) {
<add> if (!isRef(obj)) {
<add> return obj;
<add> }
<add> return this.fetch(obj);
<add> },
<add> };
<add>
<ide> describe('Name', function() {
<ide> it('should retain the given name', function() {
<ide> var givenName = 'Font';
<ide> var name = Name.get(givenName);
<ide> expect(name.name).toEqual(givenName);
<ide> });
<add>
<add> it('should create only one object for a name and cache it', function () {
<add> var firstFont = Name.get('Font');
<add> var secondFont = Name.get('Font');
<add> var firstSubtype = Name.get('Subtype');
<add> var secondSubtype = Name.get('Subtype');
<add>
<add> expect(firstFont).toBe(secondFont);
<add> expect(firstSubtype).toBe(secondSubtype);
<add> expect(firstFont).not.toBe(firstSubtype);
<add> });
<ide> });
<ide>
<ide> describe('Cmd', function() {
<ide> describe('primitives', function() {
<ide> var secondBT = Cmd.get('BT');
<ide> var firstET = Cmd.get('ET');
<ide> var secondET = Cmd.get('ET');
<add>
<ide> expect(firstBT).toBe(secondBT);
<ide> expect(firstET).toBe(secondET);
<ide> expect(firstBT).not.toBe(firstET);
<ide> describe('primitives', function() {
<ide> expect(callbackSpyCalls.argsFor(2)).toEqual(['FontFile3', testFontFile3]);
<ide> expect(callbackSpyCalls.count()).toEqual(3);
<ide> });
<add>
<add> it('should handle keys pointing to indirect objects', function () {
<add> var fontRef = new Ref(1, 0);
<add> var xref = new XRefMock([
<add> { ref: fontRef, data: testFontFile, }
<add> ]);
<add> var fontDict = new Dict(xref);
<add> fontDict.set('FontFile', fontRef);
<add>
<add> expect(fontDict.getRaw('FontFile')).toEqual(fontRef);
<add> expect(fontDict.get('FontFile')).toEqual(testFontFile);
<add> });
<add>
<add> it('should handle arrays containing indirect objects', function () {
<add> var minCoordRef = new Ref(1, 0), maxCoordRef = new Ref(2, 0);
<add> var minCoord = 0, maxCoord = 1;
<add> var xref = new XRefMock([
<add> { ref: minCoordRef, data: minCoord, },
<add> { ref: maxCoordRef, data: maxCoord, }
<add> ]);
<add> var xObjectDict = new Dict(xref);
<add> xObjectDict.set('BBox', [minCoord, maxCoord, minCoordRef, maxCoordRef]);
<add>
<add> expect(xObjectDict.get('BBox')).toEqual(
<add> [minCoord, maxCoord, minCoordRef, maxCoordRef]);
<add> expect(xObjectDict.getArray('BBox')).toEqual(
<add> [minCoord, maxCoord, minCoord, maxCoord]);
<add> });
<add>
<add> it('should get all key names', function () {
<add> var expectedKeys = ['FontFile', 'FontFile2', 'FontFile3'];
<add> var keys = dictWithManyKeys.getKeys();
<add>
<add> expect(keys.sort()).toEqual(expectedKeys);
<add> });
<add>
<add> it('should create only one object for Dict.empty', function () {
<add> var firstDictEmpty = Dict.empty;
<add> var secondDictEmpty = Dict.empty;
<add>
<add> expect(firstDictEmpty).toBe(secondDictEmpty);
<add> expect(firstDictEmpty).not.toBe(emptyDict);
<add> });
<add>
<add> it('should correctly merge dictionaries', function () {
<add> var expectedKeys = ['FontFile', 'FontFile2', 'FontFile3', 'Size'];
<add>
<add> var fontFileDict = new Dict();
<add> fontFileDict.set('FontFile', 'Type1 font file');
<add> var mergedDict = Dict.merge(null,
<add> [dictWithManyKeys, dictWithSizeKey, fontFileDict]);
<add> var mergedKeys = mergedDict.getKeys();
<add>
<add> expect(mergedKeys.sort()).toEqual(expectedKeys);
<add> expect(mergedDict.get('FontFile')).toEqual(testFontFile);
<add> });
<ide> });
<ide>
<ide> describe('Ref', function() {
<ide> describe('primitives', function() {
<ide> });
<ide> });
<ide>
<add> describe('isName', function () {
<add> it('handles non-names', function () {
<add> var nonName = {};
<add> expect(isName(nonName)).toEqual(false);
<add> });
<add>
<add> it('handles names', function () {
<add> var name = Name.get('Font');
<add> expect(isName(name)).toEqual(true);
<add> });
<add> });
<add>
<add> describe('isCmd', function () {
<add> it('handles non-commands', function () {
<add> var nonCmd = {};
<add> expect(isCmd(nonCmd)).toEqual(false);
<add> });
<add>
<add> it('handles commands', function () {
<add> var cmd = Cmd.get('BT');
<add> expect(isCmd(cmd)).toEqual(true);
<add> });
<add>
<add> it('handles commands with cmd check', function () {
<add> var cmd = Cmd.get('BT');
<add> expect(isCmd(cmd, 'BT')).toEqual(true);
<add> expect(isCmd(cmd, 'ET')).toEqual(false);
<add> });
<add> });
<add>
<ide> describe('isDict', function() {
<add> it('handles non-dictionaries', function () {
<add> var nonDict = {};
<add> expect(isDict(nonDict)).toEqual(false);
<add> });
<add>
<ide> it('handles empty dictionaries with type check', function() {
<del> var dict = new Dict();
<add> var dict = Dict.empty;
<add> expect(isDict(dict)).toEqual(true);
<ide> expect(isDict(dict, 'Page')).toEqual(false);
<ide> });
<ide>
<ide> it('handles dictionaries with type check', function() {
<ide> var dict = new Dict();
<ide> dict.set('Type', Name.get('Page'));
<ide> expect(isDict(dict, 'Page')).toEqual(true);
<add> expect(isDict(dict, 'Contents')).toEqual(false);
<add> });
<add> });
<add>
<add> describe('isRef', function () {
<add> it ('handles non-refs', function () {
<add> var nonRef = {};
<add> expect(isRef(nonRef)).toEqual(false);
<add> });
<add>
<add> it ('handles refs', function () {
<add> var ref = new Ref(1, 0);
<add> expect(isRef(ref)).toEqual(true);
<ide> });
<ide> });
<ide>
| 1
|
Javascript
|
Javascript
|
fix memory leak with https.request()
|
db5a8791fac4d7e088114488f9f5fda4c660ed5a
|
<ide><path>lib/_http_agent.js
<ide> Agent.prototype.addRequest = function(req, options) {
<ide> options = util._extend({}, options);
<ide> options = util._extend(options, this.options);
<ide>
<add> if (!options.servername) {
<add> options.servername = options.host;
<add> const hostHeader = req.getHeader('host');
<add> if (hostHeader) {
<add> options.servername = hostHeader.replace(/:.*$/, '');
<add> }
<add> }
<add>
<ide> var name = this.getName(options);
<ide> if (!this.sockets[name]) {
<ide> this.sockets[name] = [];
<ide><path>test/parallel/test-https-agent-sockets-leak.js
<add>'use strict';
<add>
<add>const common = require('../common');
<add>if (!common.hasCrypto) {
<add> common.skip('missing crypto');
<add> return;
<add>}
<add>
<add>const fs = require('fs');
<add>const https = require('https');
<add>const assert = require('assert');
<add>
<add>const options = {
<add> key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
<add> cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem'),
<add> ca: fs.readFileSync(common.fixturesDir + '/keys/ca1-cert.pem')
<add>};
<add>
<add>const server = https.Server(options, common.mustCall((req, res) => {
<add> res.writeHead(200);
<add> res.end('https\n');
<add>}));
<add>
<add>const agent = new https.Agent({
<add> keepAlive: false
<add>});
<add>
<add>server.listen(0, common.mustCall(() => {
<add> https.get({
<add> host: server.address().host,
<add> port: server.address().port,
<add> headers: {host: 'agent1'},
<add> rejectUnauthorized: true,
<add> ca: options.ca,
<add> agent: agent
<add> }, common.mustCall((res) => {
<add> res.resume();
<add> server.close();
<add>
<add> // Only one entry should exist in agent.sockets pool
<add> // If there are more entries in agent.sockets,
<add> // removeSocket will not delete them resulting in a resource leak
<add> assert.strictEqual(Object.keys(agent.sockets).length, 1);
<add>
<add> res.req.on('close', common.mustCall(() => {
<add> // To verify that no leaks occur, check that no entries
<add> // exist in agent.sockets pool after both request and socket
<add> // has been closed.
<add> assert.strictEqual(Object.keys(agent.sockets).length, 0);
<add> }));
<add> }));
<add>}));
| 2
|
Go
|
Go
|
record the error of removing volumes
|
49da0290309771891a2ea9238709bc5a248609c9
|
<ide><path>daemon/delete.go
<ide> func (daemon *Daemon) ContainerRm(name string, config *ContainerRmConfig) error
<ide> return fmt.Errorf("Cannot destroy container %s: %v", name, err)
<ide> }
<ide>
<del> container.removeMountPoints(config.RemoveVolume)
<add> if err := container.removeMountPoints(config.RemoveVolume); err != nil {
<add> logrus.Errorf("%v", err)
<add> }
<add>
<ide> return nil
<ide> }
<ide>
| 1
|
Javascript
|
Javascript
|
use _loadasfile from _loadasdir
|
306c929000b385dee02dc3495caebd252a7b1307
|
<ide><path>packager/src/node-haste/DependencyGraph/ResolutionRequest.js
<ide> class ResolutionRequest<TModule: Moduleish, TPackage: Packageish> {
<ide> ): TModule {
<ide> const packageJsonPath = path.join(potentialDirPath, 'package.json');
<ide> if (this._options.hasteFS.exists(packageJsonPath)) {
<del> const main = this._options.moduleCache
<del> .getPackage(packageJsonPath)
<del> .getMain();
<del> return tryResolveSync(
<del> () => this._loadAsFileOrThrow(main, fromModule, toModule),
<del> () => this._loadAsDir(main, fromModule, toModule),
<del> );
<add> const package_ = this._options.moduleCache.getPackage(packageJsonPath);
<add> const mainPrefixPath = package_.getMain();
<add> const dirPath = path.dirname(mainPrefixPath);
<add> const prefixName = path.basename(mainPrefixPath);
<add> const candidates = [];
<add> const module = this._loadAsFile(dirPath, prefixName, candidates);
<add> if (module != null) {
<add> return module;
<add> }
<add> return this._loadAsDir(mainPrefixPath, fromModule, toModule);
<ide> }
<ide>
<ide> return this._loadAsFileOrThrow(
| 1
|
Ruby
|
Ruby
|
improve format of git cask info --json output
|
0bfc6bd490d0ee12624c1c20f7b525bc1939a744
|
<ide><path>Library/Homebrew/cask/lib/hbc/artifact/abstract_flight_block.rb
<ide> def uninstall_phase(**)
<ide> abstract_phase(self.class.uninstall_dsl_key)
<ide> end
<ide>
<add> def summarize
<add> directives.keys.map(&:to_s).join(", ")
<add> end
<add>
<ide> private
<ide>
<ide> def class_for_dsl_key(dsl_key)
<ide> def abstract_phase(dsl_key)
<ide> return if (block = directives[dsl_key]).nil?
<ide> class_for_dsl_key(dsl_key).new(cask).instance_eval(&block)
<ide> end
<del>
<del> def summarize
<del> directives.keys.map(&:to_s).join(", ")
<del> end
<ide> end
<ide> end
<ide> end
<ide><path>Library/Homebrew/cask/lib/hbc/cask.rb
<ide> def to_hash
<ide> "appcast" => appcast,
<ide> "version" => version,
<ide> "sha256" => sha256,
<del> "artifacts" => artifacts,
<add> "artifacts" => {},
<ide> "caveats" => caveats,
<ide> "depends_on" => depends_on,
<ide> "conflicts_with" => conflicts_with,
<ide> def to_hash
<ide> "auto_updates" => auto_updates
<ide> }
<ide>
<add> artifacts.each do |a|
<add> hsh["artifacts"][a.class.english_name] = a.summarize
<add> end
<add>
<add> hsh["conflicts_with"] = [] if hsh["conflicts_with"] == nil
<add>
<ide> hsh
<ide> end
<ide> end
| 2
|
Python
|
Python
|
add function for xor gate
|
a662d96196d58c2415d6a6933fa78a59996cc3fa
|
<ide><path>boolean_algebra/xor_gate.py
<add>"""
<add>A XOR Gate is a logic gate in boolean algebra which results to 1 (True) if only one of
<add>the two inputs is 1, and 0 (False) if an even number of inputs are 1.
<add>Following is the truth table of a XOR Gate:
<add> ------------------------------
<add> | Input 1 | Input 2 | Output |
<add> ------------------------------
<add> | 0 | 0 | 0 |
<add> | 0 | 1 | 1 |
<add> | 1 | 0 | 1 |
<add> | 1 | 1 | 0 |
<add> ------------------------------
<add>
<add>Refer - https://www.geeksforgeeks.org/logic-gates-in-python/
<add>"""
<add>
<add>
<add>def xor_gate(input_1: int, input_2: int) -> int:
<add> """
<add> calculate xor of the input values
<add>
<add> >>> xor_gate(0, 0)
<add> 0
<add> >>> xor_gate(0, 1)
<add> 1
<add> >>> xor_gate(1, 0)
<add> 1
<add> >>> xor_gate(1, 1)
<add> 0
<add> """
<add> return (input_1, input_2).count(0) % 2
<add>
<add>
<add>def test_xor_gate() -> None:
<add> """
<add> Tests the xor_gate function
<add> """
<add> assert xor_gate(0, 0) == 0
<add> assert xor_gate(0, 1) == 1
<add> assert xor_gate(1, 0) == 1
<add> assert xor_gate(1, 1) == 0
<add>
<add>
<add>if __name__ == "__main__":
<add> print(xor_gate(0, 0))
<add> print(xor_gate(0, 1))
| 1
|
Java
|
Java
|
add maybe.hide() marble diagram
|
e51cf16db0d9d100da09476aa0dab5b1c3c35de8
|
<ide><path>src/main/java/io/reactivex/Maybe.java
<ide> public final Completable flatMapCompletable(final Function<? super T, ? extends
<ide>
<ide> /**
<ide> * Hides the identity of this Maybe and its Disposable.
<add> * <p>
<add> * <img width="640" height="300" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Maybe.hide.png" alt="">
<ide> * <p>Allows preventing certain identity-based
<ide> * optimizations (fusion).
<ide> * <dl>
| 1
|
Mixed
|
Python
|
add optional `id` property to entityruler patterns
|
1e19f34e29c03dd2751804a437bbb7f62c50771c
|
<ide><path>.github/contributors/kabirkhan.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 | Kabir Khan |
<add>| Company name (if applicable) | |
<add>| Title or role (if applicable) | |
<add>| Date | 2019-04-08 |
<add>| GitHub username | kabirkhan |
<add>| Website (optional) | |
<ide><path>spacy/pipeline/entityruler.py
<ide> def __init__(self, nlp, **cfg):
<ide> self.phrase_patterns = defaultdict(list)
<ide> self.matcher = Matcher(nlp.vocab)
<ide> self.phrase_matcher = PhraseMatcher(nlp.vocab)
<add> self.ent_id_sep = cfg.get("ent_id_sep", "||")
<ide> patterns = cfg.get("patterns")
<ide> if patterns is not None:
<ide> self.add_patterns(patterns)
<ide> def __call__(self, doc):
<ide> continue
<ide> # check for end - 1 here because boundaries are inclusive
<ide> if start not in seen_tokens and end - 1 not in seen_tokens:
<del> new_entities.append(Span(doc, start, end, label=match_id))
<add> if self.ent_ids:
<add> label_ = self.nlp.vocab.strings[match_id]
<add> ent_label, ent_id = self._split_label(label_)
<add> span = Span(doc, start, end, label=ent_label)
<add> if ent_id:
<add> for token in span:
<add> token.ent_id_ = ent_id
<add> else:
<add> span = Span(doc, start, end, label=match_id)
<add> new_entities.append(span)
<ide> entities = [
<ide> e for e in entities if not (e.start < end and e.end > start)
<ide> ]
<ide> def labels(self):
<ide> all_labels.update(self.phrase_patterns.keys())
<ide> return tuple(all_labels)
<ide>
<add> @property
<add> def ent_ids(self):
<add> """All entity ids present in the match patterns meta dicts.
<add>
<add> RETURNS (set): The string entity ids.
<add>
<add> DOCS: https://spacy.io/api/entityruler#labels
<add> """
<add> all_ent_ids = set()
<add> for l in self.labels:
<add> if self.ent_id_sep in l:
<add> _, ent_id = self._split_label(l)
<add> all_ent_ids.add(ent_id)
<add> return tuple(all_ent_ids)
<add>
<ide> @property
<ide> def patterns(self):
<ide> """Get all patterns that were added to the entity ruler.
<ide> def patterns(self):
<ide> all_patterns = []
<ide> for label, patterns in self.token_patterns.items():
<ide> for pattern in patterns:
<del> all_patterns.append({"label": label, "pattern": pattern})
<add> ent_label, ent_id = self._split_label(label)
<add> p = {"label": ent_label, "pattern": pattern}
<add> if ent_id:
<add> p["id"] = ent_id
<add> all_patterns.append(p)
<ide> for label, patterns in self.phrase_patterns.items():
<ide> for pattern in patterns:
<del> all_patterns.append({"label": label, "pattern": pattern.text})
<add> ent_label, ent_id = self._split_label(label)
<add> p = {"label": ent_label, "pattern": pattern.text}
<add> if ent_id:
<add> p["id"] = ent_id
<add> all_patterns.append(p)
<add>
<ide> return all_patterns
<ide>
<ide> def add_patterns(self, patterns):
<ide> def add_patterns(self, patterns):
<ide> """
<ide> for entry in patterns:
<ide> label = entry["label"]
<add> if "id" in entry:
<add> label = self._create_label(label, entry["id"])
<ide> pattern = entry["pattern"]
<ide> if isinstance(pattern, basestring_):
<ide> self.phrase_patterns[label].append(self.nlp(pattern))
<ide> def add_patterns(self, patterns):
<ide> for label, patterns in self.phrase_patterns.items():
<ide> self.phrase_matcher.add(label, None, *patterns)
<ide>
<add> def _split_label(self, label):
<add> """Split Entity label into ent_label and ent_id if it contains self.ent_id_sep
<add>
<add> RETURNS (tuple): ent_label, ent_id
<add> """
<add> if self.ent_id_sep in label:
<add> ent_label, ent_id = label.rsplit(self.ent_id_sep, 1)
<add> else:
<add> ent_label = label
<add> ent_id = None
<add>
<add> return ent_label, ent_id
<add>
<add> def _create_label(self, label, ent_id):
<add> """Join Entity label with ent_id if the pattern has an `id` attribute
<add>
<add> RETURNS (str): The ent_label joined with configured `ent_id_sep`
<add> """
<add> if isinstance(ent_id, basestring_):
<add> label = "{}{}{}".format(label, self.ent_id_sep, ent_id)
<add> return label
<add>
<ide> def from_bytes(self, patterns_bytes, **kwargs):
<ide> """Load the entity ruler from a bytestring.
<ide>
<ide><path>spacy/tests/pipeline/test_entity_ruler.py
<ide> def patterns():
<ide> {"label": "BYE", "pattern": [{"LOWER": "bye"}, {"LOWER": "bye"}]},
<ide> {"label": "HELLO", "pattern": [{"ORTH": "HELLO"}]},
<ide> {"label": "COMPLEX", "pattern": [{"ORTH": "foo", "OP": "*"}]},
<add> {"label": "TECH_ORG", "pattern": "Apple", "id": "a1"},
<ide> ]
<ide>
<ide>
<ide> def add_ent_component(doc):
<ide> def test_entity_ruler_init(nlp, patterns):
<ide> ruler = EntityRuler(nlp, patterns=patterns)
<ide> assert len(ruler) == len(patterns)
<del> assert len(ruler.labels) == 3
<add> assert len(ruler.labels) == 4
<ide> assert "HELLO" in ruler
<ide> assert "BYE" in ruler
<ide> nlp.add_pipe(ruler)
<ide> def test_entity_ruler_existing_complex(nlp, patterns, add_ent):
<ide> assert len(doc.ents[1]) == 2
<ide>
<ide>
<add>def test_entity_ruler_entity_id(nlp, patterns):
<add> ruler = EntityRuler(nlp, patterns=patterns, overwrite_ents=True)
<add> nlp.add_pipe(ruler)
<add> doc = nlp("Apple is a technology company")
<add> assert len(doc.ents) == 1
<add> assert doc.ents[0].label_ == "TECH_ORG"
<add> assert doc.ents[0].ent_id_ == "a1"
<add>
<add>
<add>def test_entity_ruler_cfg_ent_id_sep(nlp, patterns):
<add> ruler = EntityRuler(nlp, patterns=patterns, overwrite_ents=True, ent_id_sep="**")
<add> assert "TECH_ORG**a1" in ruler.phrase_patterns
<add> nlp.add_pipe(ruler)
<add> doc = nlp("Apple is a technology company")
<add> assert len(doc.ents) == 1
<add> assert doc.ents[0].label_ == "TECH_ORG"
<add> assert doc.ents[0].ent_id_ == "a1"
<add>
<add>
<ide> def test_entity_ruler_serialize_bytes(nlp, patterns):
<ide> ruler = EntityRuler(nlp, patterns=patterns)
<ide> assert len(ruler) == len(patterns)
<del> assert len(ruler.labels) == 3
<add> assert len(ruler.labels) == 4
<ide> ruler_bytes = ruler.to_bytes()
<ide> new_ruler = EntityRuler(nlp)
<ide> assert len(new_ruler) == 0
<ide> assert len(new_ruler.labels) == 0
<ide> new_ruler = new_ruler.from_bytes(ruler_bytes)
<ide> assert len(ruler) == len(patterns)
<del> assert len(ruler.labels) == 3
<add> assert len(ruler.labels) == 4
| 3
|
Javascript
|
Javascript
|
update ext_blend_minmax handling for webgl 2.0
|
6065f4f7db0a744a05ac0dbd45d2511a6b73c6c2
|
<ide><path>src/renderers/webgl/WebGLExtensions.js
<ide> function WebGLExtensions( gl ) {
<ide> 'OES_element_index_uint',
<ide> 'OES_standard_derivatives',
<ide> 'EXT_frag_depth',
<del> 'EXT_shader_texture_lod' ].indexOf( name ) >= 0 ) {
<add> 'EXT_shader_texture_lod',
<add> 'EXT_blend_minmax' ].indexOf( name ) >= 0 ) {
<ide>
<ide> extension = gl;
<ide>
<ide><path>src/renderers/webgl/WebGLUtils.js
<ide> function WebGLUtils( gl, extensions ) {
<ide>
<ide> if ( extension !== null ) {
<ide>
<del> if ( p === MinEquation ) return extension.MIN_EXT;
<del> if ( p === MaxEquation ) return extension.MAX_EXT;
<add> if ( p === MinEquation ) return isWebGL2 ? extension.MIN : extension.MIN_EXT;
<add> if ( p === MaxEquation ) return isWebGL2 ? extension.MAX : extension.MAX_EXT;
<ide>
<ide> }
<ide>
| 2
|
PHP
|
PHP
|
use integer for plural rule calc
|
cee3aadd04e2fc6d6543f0bb8c3692aa645363dd
|
<ide><path>src/I18n/PluralRules.php
<ide> class PluralRules
<ide> * to the countable provided in $n.
<ide> *
<ide> * @param string $locale The locale to get the rule calculated for.
<del> * @param int|float $n The number to apply the rules to.
<add> * @param int $n The number to apply the rules to.
<ide> * @return int The plural rule number that should be used.
<ide> * @link http://localization-guide.readthedocs.org/en/latest/l10n/pluralforms.html
<ide> * @link https://developer.mozilla.org/en-US/docs/Mozilla/Localization/Localization_and_Plurals#List_of_Plural_Rules
<ide><path>src/I18n/Translator.php
<ide> public function translate($key, array $tokensValues = []): string
<ide> // Resolve plural form.
<ide> if (is_array($message)) {
<ide> $count = $tokensValues['_count'] ?? 0;
<del> $form = PluralRules::calculate($this->locale, $count);
<add> $form = PluralRules::calculate($this->locale, (int)$count);
<ide> $message = $message[$form] ?? (string)end($message);
<ide> }
<ide>
| 2
|
PHP
|
PHP
|
use chdir() instead of calling multiple commands
|
31cd0ff07d5a317eb8f3f729b97d168fe507e1bc
|
<ide><path>src/Shell/Task/PluginTask.php
<ide> protected function _modifyAutoloader($plugin, $path) {
<ide> }
<ide>
<ide> try {
<del> $command = 'cd ' . escapeshellarg($path) . '; ';
<del> $command .= 'php ' . escapeshellarg($composer) . ' dump-autoload';
<add> chdir($path);
<add> $command = 'php ' . escapeshellarg($composer) . ' dump-autoload';
<ide> $this->callProcess($command);
<ide> } catch (\RuntimeException $e) {
<ide> $error = $e->getMessage();
<ide><path>tests/TestCase/Shell/Task/PluginTaskTest.php
<ide> public function testExecuteUpdateComposer() {
<ide>
<ide> $this->Task->expects($this->at(3))
<ide> ->method('callProcess')
<del> ->with('cd ' . escapeshellarg($path) . '; php ' . escapeshellarg('composer.phar') . ' dump-autoload');
<add> ->with('php ' . escapeshellarg('composer.phar') . ' dump-autoload');
<ide>
<ide> $this->Task->main('BakeTestPlugin');
<ide>
| 2
|
Javascript
|
Javascript
|
use null instead of [] for ops with no args
|
081866a184932cec784c221ce55914ec3a9a8bec
|
<ide><path>src/core/evaluator.js
<ide> var PartialEvaluator = (function PartialEvaluatorClosure() {
<ide> var name = args[0].name;
<ide> if (imageCache.key === name) {
<ide> operatorList.addOp(imageCache.fn, imageCache.args);
<del> args = [];
<add> args = null;
<ide> continue;
<ide> }
<ide>
<ide> var PartialEvaluator = (function PartialEvaluatorClosure() {
<ide> } else if (type.name === 'Image') {
<ide> self.buildPaintImageXObject(resources, xobj, false,
<ide> operatorList, name, imageCache);
<del> args = [];
<add> args = null;
<ide> continue;
<ide> } else if (type.name === 'PS') {
<ide> // PostScript XObjects are unused when viewing documents.
<ide> var PartialEvaluator = (function PartialEvaluatorClosure() {
<ide> var cacheKey = args[0].cacheKey;
<ide> if (cacheKey && imageCache.key === cacheKey) {
<ide> operatorList.addOp(imageCache.fn, imageCache.args);
<del> args = [];
<add> args = null;
<ide> continue;
<ide> }
<ide> self.buildPaintImageXObject(resources, args[0], true,
<ide> operatorList, cacheKey, imageCache);
<del> args = [];
<add> args = null;
<ide> continue;
<ide> case OPS.showText:
<ide> args[0] = self.handleText(args[0], stateManager.state);
<ide> var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
<ide> },
<ide>
<ide> read: function EvaluatorPreprocessor_read(operation) {
<del> var args = [];
<add> // We use an array to represent args, except we use |null| to represent
<add> // no args because it's more compact than an empty array.
<add> var args = null;
<ide> while (true) {
<ide> var obj = this.parser.getObj();
<ide> if (isEOF(obj)) {
<ide> var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
<ide> if (!isCmd(obj)) {
<ide> // argument
<ide> if (obj !== null) {
<add> if (!args) {
<add> args = [];
<add> }
<ide> args.push((obj instanceof Dict ? obj.getAll() : obj));
<ide> assert(args.length <= 33, 'Too many arguments');
<ide> }
<ide> var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
<ide>
<ide> if (!opSpec.variableArgs) {
<ide> // Some post script commands can be nested, e.g. /F2 /GS2 gs 5.711 Tf
<del> if (args.length !== numArgs) {
<add> var argsLength = args !== null ? args.length : 0;
<add> if (argsLength !== numArgs) {
<ide> var nonProcessedArgs = this.nonProcessedArgs;
<del> while (args.length > numArgs) {
<add> while (argsLength > numArgs) {
<ide> nonProcessedArgs.push(args.shift());
<add> argsLength--;
<ide> }
<del> while (args.length < numArgs && nonProcessedArgs.length !== 0) {
<add> while (argsLength < numArgs && nonProcessedArgs.length !== 0) {
<add> if (!args) {
<add> args = [];
<add> }
<ide> args.unshift(nonProcessedArgs.pop());
<add> argsLength++;
<ide> }
<ide> }
<ide>
<del> if (args.length < numArgs) {
<add> if (argsLength < numArgs) {
<ide> // If we receive too few args, it's not possible to possible
<ide> // to execute the command, so skip the command
<ide> info('Command ' + fn + ': because expected ' +
<del> numArgs + ' args, but received ' + args.length +
<add> numArgs + ' args, but received ' + argsLength +
<ide> ' args; skipping');
<del> args = [];
<add> args = null;
<ide> continue;
<ide> }
<del> } else if (args.length > numArgs) {
<add> } else if (argsLength > numArgs) {
<ide> info('Command ' + fn + ': expected [0,' + numArgs +
<del> '] args, but received ' + args.length + ' args');
<add> '] args, but received ' + argsLength + ' args');
<ide> }
<ide>
<ide> // TODO figure out how to type-check vararg functions
<ide><path>test/unit/evaluator_spec.js
<ide> describe('evaluator', function() {
<ide> expect(!!result.fnArray && !!result.argsArray).toEqual(true);
<ide> expect(result.fnArray.length).toEqual(1);
<ide> expect(result.fnArray[0]).toEqual(OPS.fill);
<del> expect(result.argsArray[0].length).toEqual(0);
<add> expect(result.argsArray[0]).toEqual(null);
<ide> });
<ide> });
<ide>
<ide> describe('evaluator', function() {
<ide> expect(result.argsArray[0][0]).toEqual(true);
<ide> expect(result.argsArray[1].length).toEqual(1);
<ide> expect(result.argsArray[1][0]).toEqual(false);
<del> expect(result.argsArray[2].length).toEqual(0);
<add> expect(result.argsArray[2]).toEqual(null);
<ide> });
<ide> });
<ide> });
| 2
|
Python
|
Python
|
add a test for ticket
|
e74585da4b5519115995cbca915e69b48370a162
|
<ide><path>numpy/core/tests/test_einsum.py
<ide> def test_einsum_misc(self):
<ide> assert_equal(np.einsum('ijklm,ijn,ijn->',a,b,b),
<ide> np.einsum('ijklm,ijn->',a,b))
<ide>
<add> # Issue #2027, was a problem in the contiguous 3-argument
<add> # inner loop implementation
<add> a = np.arange(1, 3)
<add> b = np.arange(1, 5).reshape(2, 2)
<add> c = np.arange(1, 9).reshape(4, 2)
<add> assert_equal(np.einsum('x,yx,zx->xzy', a, b, c),
<add> [[[1, 3], [3, 9], [5, 15], [7, 21]],
<add> [[8, 16], [16, 32], [24, 48], [32, 64]]])
<add>
<ide> if __name__ == "__main__":
<ide> run_module_suite()
| 1
|
Ruby
|
Ruby
|
reduce iterations for non-homogeneous collections
|
7c0dea18ce6593416b1242973b0695e06b64d657
|
<ide><path>actionview/lib/action_view/renderer/collection_renderer.rb
<ide> def each_with_info
<ide> end
<ide>
<ide> def render_collection_with_partial(collection, partial, context, block)
<del> collection = build_collection_iterator(collection, partial, context)
<add> collection = SameCollectionIterator.new(collection, partial, retrieve_variable(partial))
<ide>
<del> template = find_template(partial, template_keys(partial)) if partial
<del>
<del> if !block && (layout = @options[:layout])
<del> layout = find_template(layout.to_s, template_keys(partial))
<del> end
<del>
<del> render_collection(collection, context, template, partial, layout)
<add> render_collection(collection, context, partial, block)
<ide> end
<ide>
<ide> def render_collection_derive_partial(collection, context, block)
<ide> def render_collection_derive_partial(collection, context, block)
<ide> raise NotImplementedError, "render caching requires a template. Please specify a partial when rendering"
<ide> end
<ide>
<del> render_collection_with_partial(collection, nil, context, block)
<add> paths.map! { |path| retrieve_variable(path).unshift(path) }
<add> collection = MixedCollectionIterator.new(collection, paths)
<add> render_collection(collection, context, nil, block)
<ide> end
<ide> end
<ide>
<ide> def retrieve_variable(path)
<ide> vars
<ide> end
<ide>
<del> def build_collection_iterator(collection, path, context)
<del> if path
<del> SameCollectionIterator.new(collection, path, retrieve_variable(path))
<del> else
<del> paths = collection.map { |o| partial_path(o, context) }
<del> paths.map! { |path| retrieve_variable(path).unshift(path) }
<del> MixedCollectionIterator.new(collection, paths)
<add> def render_collection(collection, view, path, block)
<add> template = find_template(path, template_keys(path)) if path
<add>
<add> if !block && (layout = @options[:layout])
<add> layout = find_template(layout.to_s, template_keys(path))
<ide> end
<del> end
<ide>
<del> def render_collection(collection, view, template, path, layout)
<ide> identifier = (template && template.identifier) || path
<ide> instrument(:collection, identifier: identifier, count: collection.size) do |payload|
<ide> spacer = if @options.key?(:spacer_template)
| 1
|
Ruby
|
Ruby
|
fix method name in update! error message [ci skip]
|
fcc83e47384b69ea33c7eeb3c15f350d6d8914b5
|
<ide><path>activerecord/lib/active_record/persistence.rb
<ide> def update!(id = :all, attributes)
<ide> if id.is_a?(Array)
<ide> if id.any?(ActiveRecord::Base)
<ide> raise ArgumentError,
<del> "You are passing an array of ActiveRecord::Base instances to `update`. " \
<add> "You are passing an array of ActiveRecord::Base instances to `update!`. " \
<ide> "Please pass the ids of the objects by calling `pluck(:id)` or `map(&:id)`."
<ide> end
<ide> id.map { |one_id| find(one_id) }.each_with_index { |object, idx|
<ide> def update!(id = :all, attributes)
<ide> else
<ide> if ActiveRecord::Base === id
<ide> raise ArgumentError,
<del> "You are passing an instance of ActiveRecord::Base to `update`. " \
<add> "You are passing an instance of ActiveRecord::Base to `update!`. " \
<ide> "Please pass the id of the object by calling `.id`."
<ide> end
<ide> object = find(id)
| 1
|
Ruby
|
Ruby
|
warn people not to change boot.rb
|
9d88348e2ef367bcca612b2b5fba5e7189e2db20
|
<ide><path>railties/environments/boot.rb
<add># Don't change this file. Configuration is done in config/environment.rb and config/environments/*.rb
<add>
<ide> unless defined?(RAILS_ROOT)
<ide> root_path = File.join(File.dirname(__FILE__), '..')
<ide> unless RUBY_PLATFORM =~ /mswin32/
| 1
|
PHP
|
PHP
|
reduce discoverability of session cookie name
|
a7f2c060b2456d389aec9d7ddf127a2b8ff1bb82
|
<ide><path>config/session.php
<ide> |
<ide> */
<ide>
<del> 'cookie' => 'laravel_session',
<add> 'cookie' => env('SESSION_COOKIE', snake_case(env('APP_NAME', 'laravel')).'_session'),
<ide>
<ide> /*
<ide> |--------------------------------------------------------------------------
| 1
|
Mixed
|
Ruby
|
add string#in_time_zone method
|
331a82a1c8ec25cd8df3297b434cbb7cc020207a
|
<ide><path>activesupport/CHANGELOG.md
<ide> ## Rails 4.0.0 (unreleased) ##
<ide>
<add>* Add `String#in_time_zone` method to convert a string to an ActiveSupport::TimeWithZone. *Andrew White*
<add>
<ide> * Deprecate `ActiveSupport::BasicObject` in favor of `ActiveSupport::ProxyObject`.
<ide> This class is used for proxy classes. It avoids confusion with Ruby's BasicObject
<ide> class.
<ide><path>activesupport/lib/active_support/core_ext/string.rb
<ide> require 'active_support/core_ext/string/strip'
<ide> require 'active_support/core_ext/string/inquiry'
<ide> require 'active_support/core_ext/string/indent'
<add>require 'active_support/core_ext/string/zones'
<ide><path>activesupport/lib/active_support/core_ext/string/zones.rb
<add>require 'active_support/core_ext/time/zones'
<add>
<add>class String
<add> # Converts String to a TimeWithZone in the current zone if Time.zone or Time.zone_default
<add> # is set, otherwise converts String to a Time via String#to_time
<add> def in_time_zone(zone = ::Time.zone)
<add> if zone
<add> ::Time.find_zone!(zone).parse(self)
<add> else
<add> to_time
<add> end
<add> end
<add>end
<ide><path>activesupport/test/core_ext/string_ext_test.rb
<ide> def test_ord
<ide> assert_equal 97, 'abc'.ord
<ide> end
<ide>
<del> def test_string_to_time
<del> assert_equal Time.utc(2005, 2, 27, 23, 50), "2005-02-27 23:50".to_time
<del> assert_equal Time.local(2005, 2, 27, 23, 50), "2005-02-27 23:50".to_time(:local)
<del> assert_equal Time.utc(2005, 2, 27, 23, 50, 19, 275038), "2005-02-27T23:50:19.275038".to_time
<del> assert_equal Time.local(2005, 2, 27, 23, 50, 19, 275038), "2005-02-27T23:50:19.275038".to_time(:local)
<del> assert_equal DateTime.civil(2039, 2, 27, 23, 50), "2039-02-27 23:50".to_time
<del> assert_equal Time.local_time(2039, 2, 27, 23, 50), "2039-02-27 23:50".to_time(:local)
<del> assert_equal Time.utc(2011, 2, 27, 23, 50), "2011-02-27 22:50 -0100".to_time
<del> assert_nil "".to_time
<del> end
<del>
<del> def test_string_to_datetime
<del> assert_equal DateTime.civil(2039, 2, 27, 23, 50), "2039-02-27 23:50".to_datetime
<del> assert_equal 0, "2039-02-27 23:50".to_datetime.offset # use UTC offset
<del> assert_equal ::Date::ITALY, "2039-02-27 23:50".to_datetime.start # use Ruby's default start value
<del> assert_equal DateTime.civil(2039, 2, 27, 23, 50, 19 + Rational(275038, 1000000), "-04:00"), "2039-02-27T23:50:19.275038-04:00".to_datetime
<del> assert_nil "".to_datetime
<del> end
<del>
<del> def test_string_to_date
<del> assert_equal Date.new(2005, 2, 27), "2005-02-27".to_date
<del> assert_nil "".to_date
<del> end
<del>
<ide> def test_access
<ide> s = "hello"
<ide> assert_equal "h", s.at(0)
<ide> def test_safe_constantize
<ide> end
<ide> end
<ide>
<add>class StringConversionsTest < ActiveSupport::TestCase
<add> def test_string_to_time
<add> assert_equal Time.utc(2005, 2, 27, 23, 50), "2005-02-27 23:50".to_time
<add> assert_equal Time.local(2005, 2, 27, 23, 50), "2005-02-27 23:50".to_time(:local)
<add> assert_equal Time.utc(2005, 2, 27, 23, 50, 19, 275038), "2005-02-27T23:50:19.275038".to_time
<add> assert_equal Time.local(2005, 2, 27, 23, 50, 19, 275038), "2005-02-27T23:50:19.275038".to_time(:local)
<add> assert_equal DateTime.civil(2039, 2, 27, 23, 50), "2039-02-27 23:50".to_time
<add> assert_equal Time.local_time(2039, 2, 27, 23, 50), "2039-02-27 23:50".to_time(:local)
<add> assert_equal Time.utc(2011, 2, 27, 23, 50), "2011-02-27 22:50 -0100".to_time
<add> assert_nil "".to_time
<add> end
<add>
<add> def test_string_to_datetime
<add> assert_equal DateTime.civil(2039, 2, 27, 23, 50), "2039-02-27 23:50".to_datetime
<add> assert_equal 0, "2039-02-27 23:50".to_datetime.offset # use UTC offset
<add> assert_equal ::Date::ITALY, "2039-02-27 23:50".to_datetime.start # use Ruby's default start value
<add> assert_equal DateTime.civil(2039, 2, 27, 23, 50, 19 + Rational(275038, 1000000), "-04:00"), "2039-02-27T23:50:19.275038-04:00".to_datetime
<add> assert_nil "".to_datetime
<add> end
<add>
<add> def test_string_to_date
<add> assert_equal Date.new(2005, 2, 27), "2005-02-27".to_date
<add> assert_nil "".to_date
<add> end
<add>
<add> def test_string_in_time_zone
<add> with_tz_default "US/Eastern" do
<add> assert_equal Time.utc(2012,6,7,16,30).in_time_zone, "2012-06-07 12:30:00".in_time_zone
<add> assert_equal Time.utc(2012,6,7,11,30).in_time_zone, "2012-06-07 12:30:00 +0100".in_time_zone
<add> assert_equal Time.utc(2012,6,7,19,30).in_time_zone("US/Pacific"), "2012-06-07 12:30:00".in_time_zone("US/Pacific")
<add> assert_nil "".in_time_zone
<add> end
<add> end
<add>
<add> private
<add> def with_tz_default(tz = nil)
<add> old_tz = Time.zone
<add> Time.zone = tz
<add> yield
<add> ensure
<add> Time.zone = old_tz
<add> end
<add>end
<add>
<ide> class StringBehaviourTest < ActiveSupport::TestCase
<ide> def test_acts_like_string
<ide> assert 'Bambi'.acts_like_string?
| 4
|
Javascript
|
Javascript
|
do a hard reload if hot update can't be applied
|
3b1dbccaaf90aa05a0b25e4853e6b8d48da1deaf
|
<ide><path>Libraries/Core/InitializeCore.js
<ide> require('./setUpSegmentFetcher');
<ide> if (__DEV__) {
<ide> require('./checkNativeVersion');
<ide> require('./setUpDeveloperTools');
<add>
<add> // This is used by the require.js polyfill for hot reloading.
<add> // TODO(t9759686) Scan polyfills for dependencies, too
<add> const reload = require('../NativeModules/specs/NativeDevSettings').default
<add> .reload;
<add> if (typeof reload !== 'function') {
<add> throw new Error('Could not find the reload() implementation.');
<add> }
<add> (require: any).reload = reload;
<ide> }
<ide>
<ide> const GlobalPerformanceLogger = require('../Utilities/GlobalPerformanceLogger');
| 1
|
Text
|
Text
|
remove references to inactive guides. - fixes #571
|
e84fde145cbd6feae68d0b12fb164cf44fec42a7
|
<ide><path>README.md
<ide> For new users, we recommend downloading the [Ember.js Starter Kit](https://githu
<ide>
<ide> We also recommend that you check out the [annotated Todos example](http://annotated-todos.strobeapp.com/), which shows you the best practices for architecting an MVC-based web application. You can also [browse or fork the code on Github](https://github.com/emberjs/todos).
<ide>
<del>[Guides are available](http://guides.sproutcore20.com/) for Ember.js. If you find an error, please [fork the guides on GitHub](https://github.com/sproutcore/sproutguides/tree/v2.0) and submit a pull request. (Note that Ember.js guides are on the `v2.0` branch.)
<del>
<ide> # Building Ember.js
<ide>
<ide> NOTE: Due to the rename, these instructions may be in flux
| 1
|
Mixed
|
Javascript
|
add docs for 'intentandroid'
|
2f32cccce782c46705826ae4d8990bc680539b0f
|
<ide><path>docs/KnownIssues.md
<ide> There are known cases where the APIs could be made more consistent across iOS an
<ide>
<ide> - `<AndroidViewPager>` and `<ScrollView pagingEnabled={true}>` on iOS do a similar thing. We might want to unify them to `<ViewPager>`.
<ide> - `alert()` needs Android support (once the Dialogs module is open sourced)
<del>- It might be possible to bring `LinkingIOS` and `IntentAndroid` (to be open sourced) closer together.
<add>- It might be possible to bring `LinkingIOS` and `IntentAndroid` closer together.
<ide> - `ActivityIndicator` could render a native spinning indicator on both platforms (currently this is done using `ActivityIndicatorIOS` on iOS and `ProgressBarAndroid` on Android).
<ide> - `ProgressBar` could render a horizontal progress bar on both platforms (on iOS this is `ProgressViewIOS`, on Android it's `ProgressBarAndroid`).
<ide>
<ide> Adding these to your apps should be made simpler. Here's [an example](https://gi
<ide>
<ide> ### The `overflow` style property defaults to `hidden` and cannot be changed on Android
<ide>
<del>This is a result of how Android rendering works. This feature is not being worked on as it would be a significant undertaking and there are many more important tasks.
<add>This is a result of how Android rendering works. This feature is not being worked on as it would be a significant undertaking and there are many more important tasks.
<ide>
<ide> Another issue with `overflow: 'hidden'` on Android: a view is not clipped by the parent's `borderRadius` even if the parent has `overflow: 'hidden'` enabled – the corners of the inner view will be visible outside of the rounded corners. This is only on Android; it works as expected on iOS. See a [demo of the bug](https://rnplay.org/apps/BlGjdQ) and the [corresponding issue](https://github.com/facebook/react-native/issues/3198).
<ide>
<ide><path>website/server/extractDocs.js
<ide> var apis = [
<ide> '../Libraries/Utilities/BackAndroid.android.js',
<ide> '../Libraries/CameraRoll/CameraRoll.js',
<ide> '../Libraries/Utilities/Dimensions.js',
<add> '../Libraries/Components/Intent/IntentAndroid.android.js',
<ide> '../Libraries/Interaction/InteractionManager.js',
<ide> '../Libraries/LayoutAnimation/LayoutAnimation.js',
<ide> '../Libraries/LinkingIOS/LinkingIOS.js',
| 2
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.