Commit d4bc1255 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge pull request #7856 from cirosantilli/error-to-msg

Fix missing flash on file edit error from web UI.
parents d7ec8451 2d235221
...@@ -20,7 +20,7 @@ class Projects::BlobController < Projects::ApplicationController ...@@ -20,7 +20,7 @@ class Projects::BlobController < Projects::ApplicationController
flash[:notice] = "Your changes have been successfully committed" flash[:notice] = "Your changes have been successfully committed"
redirect_to project_tree_path(@project, @ref) redirect_to project_tree_path(@project, @ref)
else else
flash[:alert] = result[:error] flash[:alert] = result[:message]
render :show render :show
end end
end end
......
...@@ -22,7 +22,7 @@ class Projects::EditTreeController < Projects::BaseTreeController ...@@ -22,7 +22,7 @@ class Projects::EditTreeController < Projects::BaseTreeController
redirect_to after_edit_path redirect_to after_edit_path
else else
flash[:alert] = result[:error] flash[:alert] = result[:message]
render :show render :show
end end
end end
......
...@@ -10,12 +10,6 @@ module Files ...@@ -10,12 +10,6 @@ module Files
private private
def success
out = super()
out[:error] = ''
out
end
def repository def repository
project.repository project.repository
end end
......
...@@ -34,6 +34,16 @@ Feature: Project Source Browse Files ...@@ -34,6 +34,16 @@ Feature: Project Source Browse Files
Then I am redirected to the new file Then I am redirected to the new file
And I should see its new content And I should see its new content
@javascript
Scenario: If I enter an illegal file name I see an error message
Given I click on "new file" link in repo
And I fill the new file name with an illegal name
And I edit code
And I fill the commit message
And I click on "Commit changes"
Then I am on the new file page
And I see a commit error message
@javascript @javascript
Scenario: I can edit file Scenario: I can edit file
Given I click on ".gitignore" file in repo Given I click on ".gitignore" file in repo
...@@ -50,6 +60,16 @@ Feature: Project Source Browse Files ...@@ -50,6 +60,16 @@ Feature: Project Source Browse Files
Then I am redirected to the ".gitignore" Then I am redirected to the ".gitignore"
And I should see its new content And I should see its new content
@javascript @wip
Scenario: If I don't change the content of the file I see an error message
Given I click on ".gitignore" file in repo
And I click button "edit"
And I fill the commit message
And I click on "Commit changes"
# Test fails because carriage returns are added to the file.
Then I am on the ".gitignore" edit file page
And I see a commit error message
@javascript @javascript
Scenario: I can see editing preview Scenario: I can see editing preview
Given I click on ".gitignore" file in repo Given I click on ".gitignore" file in repo
......
...@@ -61,6 +61,10 @@ class Spinach::Features::ProjectSourceBrowseFiles < Spinach::FeatureSteps ...@@ -61,6 +61,10 @@ class Spinach::Features::ProjectSourceBrowseFiles < Spinach::FeatureSteps
fill_in :file_name, with: new_file_name fill_in :file_name, with: new_file_name
end end
step 'I fill the new file name with an illegal name' do
fill_in :file_name, with: '.git'
end
step 'I fill the commit message' do step 'I fill the commit message' do
fill_in :commit_message, with: 'Not yet a commit message.' fill_in :commit_message, with: 'Not yet a commit message.'
end end
...@@ -151,6 +155,10 @@ class Spinach::Features::ProjectSourceBrowseFiles < Spinach::FeatureSteps ...@@ -151,6 +155,10 @@ class Spinach::Features::ProjectSourceBrowseFiles < Spinach::FeatureSteps
expect(page).not_to have_link('permalink') expect(page).not_to have_link('permalink')
end end
step 'I see a commit error message' do
expect(page).to have_content('Your changes could not be committed')
end
private private
def set_new_content def set_new_content
......
...@@ -265,6 +265,15 @@ module SharedPaths ...@@ -265,6 +265,15 @@ module SharedPaths
visit project_blob_path(@project, File.join(root_ref, '.gitignore')) visit project_blob_path(@project, File.join(root_ref, '.gitignore'))
end end
step 'I am on the new file page' do
current_path.should eq(project_new_tree_path(@project, root_ref))
end
step 'I am on the ".gitignore" edit file page' do
current_path.should eq(project_edit_tree_path(
@project, File.join(root_ref, '.gitignore')))
end
step 'I visit project source page for "6d39438"' do step 'I visit project source page for "6d39438"' do
visit project_tree_path(@project, "6d39438") visit project_tree_path(@project, "6d39438")
end end
......
...@@ -85,7 +85,7 @@ module API ...@@ -85,7 +85,7 @@ module API
branch_name: branch_name branch_name: branch_name
} }
else else
render_api_error!(result[:error], 400) render_api_error!(result[:message], 400)
end end
end end
...@@ -117,7 +117,7 @@ module API ...@@ -117,7 +117,7 @@ module API
branch_name: branch_name branch_name: branch_name
} }
else else
render_api_error!(result[:error], 400) render_api_error!(result[:message], 400)
end end
end end
...@@ -149,7 +149,7 @@ module API ...@@ -149,7 +149,7 @@ module API
branch_name: branch_name branch_name: branch_name
} }
else else
render_api_error!(result[:error], 400) render_api_error!(result[:message], 400)
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment