Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed bug to allow filenames with spaces in assets_precompile.rb #513

Merged
merged 1 commit into from
Aug 11, 2016
Merged

Fixed bug to allow filenames with spaces in assets_precompile.rb #513

merged 1 commit into from
Aug 11, 2016

Conversation

dzirtusss
Copy link
Contributor

@dzirtusss dzirtusss commented Aug 10, 2016

#510 moved to a branch


This change is Reviewable

@justin808
Copy link
Member

@dzirtusss There's no need for a separate PR. You can do a push -f to replace what the server has for your old branch. First change the old branch to some new name, then rename this branch to the old name. And then do a push force.

@justin808 justin808 closed this Aug 10, 2016
@justin808 justin808 reopened this Aug 10, 2016
@justin808
Copy link
Member

It was my mistake in that I asked Sergey to rename his fixes to a branch. The original review comments are in #510. I should have asked Sergey to rebase to origin/master on the remote, which means creating a named remote, such as "shakacode" (rather than origin, as that's Sergey's fork) and rebasing on top of that. My bad.

@justin808
Copy link
Member

:lgtm: I'll update the CHANGELOG.


Reviewed 3 of 3 files at r1.
Review status: all files reviewed at latest revision, 4 unresolved discussions.


CHANGELOG.md, line 10 [r1] (raw file):

- React on Rails server rendering now supports contexts outside of browser rendering, such as ActionMailer templates [#486](https://github.com/shakacode/react_on_rails/pull/486) by [eacaps](https://github.com/eacaps).
- React on Rails now correctly parses single-digit version strings from package.json [#491](https://github.com/shakacode/react_on_rails/pull/491) by [samphilipd ](https://github.com/samphilipd ).
- Fixed assets symlinking to correctly use filenames with spaces [#510](https://github.com/shakacode/react_on_rails/pull/510) 

Update this to 513. I'll do this. And we should have the author!


lib/react_on_rails/assets_precompile.rb, line 46 [r1] (raw file):

        FileUtils.chdir(dest_path) do
          File.symlink(target_filename, symlink_filename)
        end

👍


spec/react_on_rails/assets_precompile_spec.rb, line 29 [r1] (raw file):

                        .symlink_file(filename, digest_filename)

        expect(File.readlink(assets_path.join(digest_filename)).to_s).to eq(filename)

It's worth noting that digest_filename and filename are all relative paths in the manifest.

I would have probably kept in the removed test that verified that confirms the value of readLink is not the absolute path of filename. Then again, it's clear from the code a few lines above that calls File.basename. 😄


spec/react_on_rails/assets_precompile_spec.rb, line 40 [r1] (raw file):

        expect(assets_path.join(digest_filename).lstat.symlink?).to be true
        expect(File.identical?(assets_path.join(filename),
                               assets_path.join(digest_filename))).to be true

Critical that we fixed this.


Comments from Reviewable

@dzirtusss
Copy link
Contributor Author

Review status: all files reviewed at latest revision, 4 unresolved discussions, some commit checks failed.


CHANGELOG.md, line 10 [r1] (raw file):

Previously, justin808 (Justin Gordon) wrote…

Update this to 513. I'll do this. And we should have the author!

Done.

lib/react_on_rails/assets_precompile.rb, line 46 [r1] (raw file):

Previously, justin808 (Justin Gordon) wrote…

👍

Done.

spec/react_on_rails/assets_precompile_spec.rb, line 29 [r1] (raw file):

Previously, justin808 (Justin Gordon) wrote…

It's worth noting that digest_filename and filename are all relative paths in the manifest.

I would have probably kept in the removed test that verified that confirms the value of readLink is not the absolute path of filename. Then again, it's clear from the code a few lines above that calls File.basename. 😄

In #510 you commented - _If we test for equality, that's a bit more of a sure thing. Only having an "expectation not" can result in a test that passes due to an error in writing the test._

Actually I totally agree with that comment. To be double-proof we can have both expects:

expect.to eq(filename)          # positive expectation
expect.not_to eq(global_path)   # negative expectation

Than we check for both filename and path.

Should do like this?


spec/react_on_rails/assets_precompile_spec.rb, line 40 [r1] (raw file):

Previously, justin808 (Justin Gordon) wrote…

Critical that we fixed this.

I'm really-really sorry I don't understand here. What would U like to fix here?

We have exact same test (original) at L:12 for filename without spaces, and then this new one, which specially tests for fix condition - for filename with spaces "temp file". Test is exact replica of original only with spaces in filenames.

If U want to test it on old source without fix, then first test will pass and this will fail.


Comments from Reviewable

@dzirtusss
Copy link
Contributor Author

ok


Review status: all files reviewed at latest revision, 4 unresolved discussions, some commit checks failed.


Comments from Reviewable

@justin808
Copy link
Member

Reviewed 1 of 1 files at r2.
Review status: all files reviewed at latest revision, 5 unresolved discussions.


CHANGELOG.md, line 10 [r2] (raw file):

- React on Rails server rendering now supports contexts outside of browser rendering, such as ActionMailer templates [#486](https://github.com/shakacode/react_on_rails/pull/486) by [eacaps](https://github.com/eacaps).
- React on Rails now correctly parses single-digit version strings from package.json [#491](https://github.com/shakacode/react_on_rails/pull/491) by [samphilipd ](https://github.com/samphilipd ).
- Fixed assets symlinking to correctly use filenames with spaces. Begining in [#510](https://github.com/shakacode/react_on_rails/pull/510), end in [#513](https://github.com/shakacode/react_on_rails/pull/513) by Sergey Tarasov [https://github.com/dzirtusss]  

see other names in the changelog for the format


Comments from Reviewable

@justin808
Copy link
Member

couple comments


Review status: all files reviewed at latest revision, 3 unresolved discussions.


spec/react_on_rails/assets_precompile_spec.rb, line 29 [r1] (raw file):

Previously, dzirtusss (Sergey Tarasov) wrote…

In #510 you commented - If we test for equality, that's a bit more of a sure thing. Only having an "expectation not" can result in a test that passes due to an error in writing the test.

Actually I totally agree with that comment. To be double-proof we can have both expects:

expect.to eq(filename)          # positive expectation
expect.not_to eq(global_path)   # negative expectation

Than we check for both filename and path.

Should do like this?

Sure.

spec/react_on_rails/assets_precompile_spec.rb, line 40 [r1] (raw file):

Previously, dzirtusss (Sergey Tarasov) wrote…

I'm really-really sorry I don't understand here. What would U like to fix here?

We have exact same test (original) at L:12 for filename without spaces, and then this new one, which specially tests for fix condition - for filename with spaces "temp file". Test is exact replica of original only with spaces in filenames.

If U want to test it on old source without fix, then first test will pass and this will fail.

I'm saying 👍 on this fix. Great job. That's it.

Comments from Reviewable

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 799b60a on dzirtusss:fix-spaces into * on shakacode:master*.

@dzirtusss
Copy link
Contributor Author

Done


Review status: 1 of 3 files reviewed at latest revision, 3 unresolved discussions.


CHANGELOG.md, line 10 [r2] (raw file):

Previously, justin808 (Justin Gordon) wrote…

see other names in the changelog for the format

Done

spec/react_on_rails/assets_precompile_spec.rb, line 29 [r1] (raw file):

Previously, justin808 (Justin Gordon) wrote…

Sure.

Done.

spec/react_on_rails/assets_precompile_spec.rb, line 40 [r1] (raw file):

Previously, justin808 (Justin Gordon) wrote…

I'm saying 👍 on this fix. Great job. That's it.

Done.

Comments from Reviewable

@justin808
Copy link
Member

one more comment


Reviewed 2 of 2 files at r3.
Review status: all files reviewed at latest revision, 1 unresolved discussion.


CHANGELOG.md, line 10 [r3] (raw file):

- React on Rails server rendering now supports contexts outside of browser rendering, such as ActionMailer templates [#486](https://github.com/shakacode/react_on_rails/pull/486) by [eacaps](https://github.com/eacaps).
- React on Rails now correctly parses single-digit version strings from package.json [#491](https://github.com/shakacode/react_on_rails/pull/491) by [samphilipd ](https://github.com/samphilipd ).
- Fixed assets symlinking to correctly use filenames with spaces. Begining in [#510](https://github.com/shakacode/react_on_rails/pull/510), ending in [#513](https://github.com/shakacode/react_on_rails/pull/513) by [Sergey Tarasov](https://github.com/dzirtusss) 

almost...see other entries. We use the github id.


Comments from Reviewable

@justin808
Copy link
Member

Be sure to run rake lint before pushing!

Offenses:
spec/react_on_rails/assets_precompile_spec.rb:31:13: C: Style/MultilineMethodCallIndentation: Use 2 (not 4) spaces for indenting an expression spanning multiple lines.
.not_to eq(File.expand_path(assets_path.join(filename)).to_s)
^^^^^^^
91 files inspected, 1 offense detected
rake aborted!
Command failed with status (1): [cd /home/travis/build/shakacode/react_on_r...]
/home/travis/build/shakacode/react_on_rails/rakelib/task_helpers.rb:20:in block in sh_in_dir' /home/travis/build/shakacode/react_on_rails/rakelib/task_helpers.rb:20:ineach'
/home/travis/build/shakacode/react_on_rails/rakelib/task_helpers.rb:20:in sh_in_dir' /home/travis/build/shakacode/react_on_rails/rakelib/lint.rake:7:inblock (2 levels) in <top (required)>'
/home/travis/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/exe/rake:27:in <top (required)>' /home/travis/.rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:ineval'
/home/travis/.rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in `

'
Tasks: TOP => default => lint => lint:lint => lint:rubocop
(See full trace by running task with --trace)


Review status: all files reviewed at latest revision, 1 unresolved discussion, some commit checks failed.


Comments from Reviewable

@dzirtusss
Copy link
Contributor Author

Done


Review status: 1 of 3 files reviewed at latest revision, 1 unresolved discussion.


CHANGELOG.md, line 10 [r3] (raw file):

Previously, justin808 (Justin Gordon) wrote…

almost...see other entries. We use the github id.

😕 Done

Comments from Reviewable

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 1bead68 on dzirtusss:fix-spaces into * on shakacode:master*.

@justin808
Copy link
Member

:lgtm:


Reviewed 2 of 2 files at r4.
Review status: all files reviewed at latest revision, all discussions resolved.


Comments from Reviewable

@dzirtusss
Copy link
Contributor Author

Done, squashed commits


Review status: all files reviewed at latest revision, all discussions resolved, some commit checks pending.


Comments from Reviewable

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 035ecb0 on dzirtusss:fix-spaces into * on shakacode:master*.

@justin808
Copy link
Member

:lgtm_strong:


Review status: :shipit: all files reviewed at latest revision, all discussions resolved, all commit checks successful.


Comments from Reviewable

@justin808 justin808 merged commit c49f5d2 into shakacode:master Aug 11, 2016
@dzirtusss dzirtusss deleted the fix-spaces branch August 23, 2016 07:28
robwise added a commit that referenced this pull request Sep 5, 2016
When we changed this method in #513 we introduced a regression due
to the difference between calling the shell's `ln -s` command and
using Ruby's `File.symlink` command.

Specifically, the former would not error if the symlink already
existed, while the latter did throw an error. Because it is
sometimes the case that the symlink will already exist, throwing
in this case is not desirable.

This should have not been a problem, however, as this scenario
was supposed to have been properly handled, but that code was not
correct. This commit fixes that code.
robwise added a commit that referenced this pull request Sep 5, 2016
When we changed this method in #513 we introduced a regression due
to the difference between calling the shell's `ln -s` command and
using Ruby's `File.symlink` command.

Specifically, the former would not error if the symlink already
existed, while the latter did throw an error. Because it is
sometimes the case that the symlink will already exist, throwing
in this case is not desirable.

This should have not been a problem, however, as this scenario
was supposed to have been properly handled, but that code was not
correct. This commit fixes that code.
robwise added a commit that referenced this pull request Sep 5, 2016
When we changed this method in #513 we introduced a regression due
to the difference between calling the shell's `ln -s` command and
using Ruby's `File.symlink` command.

Specifically, the former would not error if the symlink already
existed, while the latter did throw an error. Because it is
sometimes the case that the symlink will already exist, throwing
in this case is not desirable.

This should have not been a problem, however, as this scenario
was supposed to have been properly handled, but that code was not
correct. This commit fixes that code.
justin808 pushed a commit that referenced this pull request Sep 10, 2016
Fix AssetsPrecompile#symlink_file logic

When we changed this method in #513 we introduced a regression due
to the difference between calling the shell's `ln -s` command and
using Ruby's `File.symlink` command.

Specifically, the former would not error if the symlink already
existed, while the latter did throw an error. Because it is
sometimes the case that the symlink will already exist, throwing
in this case is not desirable.

This should have not been a problem, however, as this scenario
was supposed to have been properly handled, but that code was not
correct. This commit fixes that code.

* Allow filtering react_on_rails specs with :focus
* Fix possible open resource leak in AssetsPrecompile spec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants