summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2015-12-14 23:29:50 +0000
committerRobert Speicher <robert@gitlab.com>2015-12-14 23:29:50 +0000
commit2b4a3bc524c0db3f6e4e3d2b2f34ec29e358b240 (patch)
tree742a9f156e9cbc8bbbb73777aac27fd0b5332116
parentf28c2de41f1891fc9c20f8a327cd664767ae4193 (diff)
parent5afe03315d12d1379c31a87a02fc9d9b6952f539 (diff)
downloadgitlab-ce-2b4a3bc524c0db3f6e4e3d2b2f34ec29e358b240.tar.gz
Merge branch 'preserve-trailing-new-lines-at-eof' into 'master'
Preserve trailing new lines at the end of file on the online editor Fixes #3784 Because Haml automatically indents the HTML source code, the contents of whitespace-sensitive tags like pre and textarea can get screwed up. See merge request !2099
-rw-r--r--CHANGELOG1
-rw-r--r--app/views/projects/blob/_editor.html.haml3
-rw-r--r--features/project/source/browse_files.feature11
-rw-r--r--features/steps/project/source/browse_files.rb8
4 files changed, 21 insertions, 2 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 6ff06091f61..7f9dfd98cd7 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -54,6 +54,7 @@ v 8.3.0 (unreleased)
- Suppress warning about missing `.gitlab-ci.yml` if builds are disabled
- Do not show build status unless builds are enabled and `.gitlab-ci.yml` is present
- Persist runners registration token in database
+ - Fix online editor should not remove newlines at the end of the file
v 8.2.3
- Fix application settings cache not expiring after changes (Stan Hu)
diff --git a/app/views/projects/blob/_editor.html.haml b/app/views/projects/blob/_editor.html.haml
index 333f5d470ed..10b02813733 100644
--- a/app/views/projects/blob/_editor.html.haml
+++ b/app/views/projects/blob/_editor.html.haml
@@ -16,8 +16,7 @@
= select_tag :encoding, options_for_select([ "base64", "text" ], "text"), class: 'select2'
.file-content.code
- %pre.js-edit-mode-pane#editor
- = params[:content] || local_assigns[:blob_data]
+ %pre.js-edit-mode-pane#editor #{params[:content] || local_assigns[:blob_data]}
- if local_assigns[:path]
.js-edit-mode-pane#preview.hide
.center
diff --git a/features/project/source/browse_files.feature b/features/project/source/browse_files.feature
index 439787f2641..02159ee3776 100644
--- a/features/project/source/browse_files.feature
+++ b/features/project/source/browse_files.feature
@@ -35,6 +35,17 @@ Feature: Project Source Browse Files
And I should see its new content
@javascript
+ Scenario: I can create and commit file with new lines at the end of file
+ Given I click on "New file" link in repo
+ And I edit code with new lines at end of file
+ And I fill the new file name
+ And I fill the commit message
+ And I click on "Commit Changes"
+ Then I am redirected to the new file
+ And I click button "Edit"
+ And I should see its content with new lines preserved at end of file
+
+ @javascript
Scenario: I can upload file and commit
Given I click on "Upload file" link in repo
And I upload a new text file
diff --git a/features/steps/project/source/browse_files.rb b/features/steps/project/source/browse_files.rb
index f2b95764267..b88709620ab 100644
--- a/features/steps/project/source/browse_files.rb
+++ b/features/steps/project/source/browse_files.rb
@@ -37,6 +37,10 @@ class Spinach::Features::ProjectSourceBrowseFiles < Spinach::FeatureSteps
expect(page).to have_content new_gitignore_content
end
+ step 'I should see its content with new lines preserved at end of file' do
+ expect(evaluate_script('blob.editor.getValue()')).to eq "Sample\n\n\n"
+ end
+
step 'I click link "Raw"' do
click_link 'Raw'
end
@@ -62,6 +66,10 @@ class Spinach::Features::ProjectSourceBrowseFiles < Spinach::FeatureSteps
set_new_content
end
+ step 'I edit code with new lines at end of file' do
+ execute_script('blob.editor.setValue("Sample\n\n\n")')
+ end
+
step 'I fill the new file name' do
fill_in :file_name, with: new_file_name
end