-
-
Notifications
You must be signed in to change notification settings - Fork 631
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
Fix symlink regression #541
Changes from 1 commit
1c4affb
8e72bf8
7ecdc36
168f3c8
d32a8cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,6 +62,48 @@ module ReactOnRails | |
end.to raise_exception(AssetsPrecompile::SymlinkTargetDoesNotExistException) | ||
end | ||
end | ||
|
||
it "creates a proper symlink when a file exists at destination" do | ||
filename = File.basename(Tempfile.new("tempfile", assets_path)) | ||
existing_filename = File.basename(Tempfile.new("tempfile", assets_path)) | ||
digest_filename = existing_filename | ||
|
||
AssetsPrecompile.new(assets_path: assets_path).symlink_file(filename, digest_filename) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. usually we have a line between the action taken and the expectation |
||
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 | ||
end | ||
|
||
it "creates a proper symlink when a symlink file exists at destination" do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is it a valid symlink or invalid symlink? It doesn't do anything if it's valid, just outputs a message context "when there is already a valid symlink in place" do
it "outputs a message saying that it need not perform any action" do |
||
filename = File.basename(Tempfile.new("tempfile", assets_path)) | ||
existing_filename = File.basename(Tempfile.new("tempfile", assets_path)) | ||
digest_file = Tempfile.new("tempfile", assets_path) | ||
digest_filename = File.basename(digest_file) | ||
File.delete(digest_file) | ||
File.symlink(existing_filename, digest_filename) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't get what's going on here compared to your test description |
||
|
||
AssetsPrecompile.new(assets_path: assets_path).symlink_file(filename, digest_filename) | ||
expect(assets_path.join(digest_filename).lstat.symlink?).to be true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. usually we have a line between the action taken and the expectation |
||
expect(File.identical?(assets_path.join(filename), | ||
assets_path.join(digest_filename))).to be true | ||
File.delete(digest_filename) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unnecessary, this is a |
||
end | ||
|
||
it "creates a proper symlink when an invalid symlink exists at destination" do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. context "when there is an existing invalid symlink" do
it "replaces it with a valid one" do |
||
filename = File.basename(Tempfile.new("tempfile", assets_path)) | ||
existing_file = Tempfile.new("tempfile", assets_path) | ||
existing_filename = File.basename(existing_file) | ||
digest_file = Tempfile.new("tempfile", assets_path) | ||
digest_filename = File.basename(digest_file) | ||
File.symlink(existing_filename, digest_filename) | ||
File.delete(existing_file) # now digest_filename is an invalid link | ||
|
||
AssetsPrecompile.new(assets_path: assets_path).symlink_file(filename, digest_filename) | ||
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 | ||
File.delete(digest_filename) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why are you doing this, it's a |
||
end | ||
end | ||
|
||
describe "symlink_non_digested_assets" do | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should specify which destination you are talking about