Skip to content

Commit

Permalink
Use :message key, not :error for File::Service.
Browse files Browse the repository at this point in the history
  • Loading branch information
cirosantilli committed Sep 29, 2014
1 parent efcac2b commit 1af0c64
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/controllers/projects/blob_controller.rb
Expand Up @@ -20,7 +20,7 @@ def destroy
flash[:notice] = "Your changes have been successfully committed"
redirect_to project_tree_path(@project, @ref)
else
flash[:alert] = result[:error]
flash[:alert] = result[:message]
render :show
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/projects/edit_tree_controller.rb
Expand Up @@ -22,7 +22,7 @@ def update

redirect_to after_edit_path
else
flash[:alert] = result[:error]
flash[:alert] = result[:message]
render :show
end
end
Expand Down
6 changes: 0 additions & 6 deletions app/services/files/base_service.rb
Expand Up @@ -10,12 +10,6 @@ def initialize(project, user, params, ref, path = nil)

private

def success
out = super()
out[:error] = ''
out
end

def repository
project.repository
end
Expand Down
20 changes: 20 additions & 0 deletions features/project/source/browse_files.feature
Expand Up @@ -34,6 +34,16 @@ Feature: Project Browse files
Then I am redirected to the new file
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
Scenario: I can edit file
Given I click on ".gitignore" file in repo
Expand All @@ -50,6 +60,16 @@ Feature: Project Browse files
Then I am redirected to the ".gitignore"
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
Scenario: I can see editing preview
Given I click on ".gitignore" file in repo
Expand Down
8 changes: 8 additions & 0 deletions features/steps/project/browse_files.rb
Expand Up @@ -61,6 +61,10 @@ class Spinach::Features::ProjectBrowseFiles < Spinach::FeatureSteps
fill_in :file_name, with: new_file_name
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
fill_in :commit_message, with: 'Not yet a commit message.'
end
Expand Down Expand Up @@ -151,6 +155,10 @@ class Spinach::Features::ProjectBrowseFiles < Spinach::FeatureSteps
expect(page).not_to have_link('permalink')
end

step 'I see a commit error message' do
expect(page).to have_content('Your changes could not be committed')
end

private

def set_new_content
Expand Down
9 changes: 9 additions & 0 deletions features/steps/shared/paths.rb
Expand Up @@ -265,6 +265,15 @@ module SharedPaths
visit project_blob_path(@project, File.join(root_ref, '.gitignore'))
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
visit project_tree_path(@project, "6d39438")
end
Expand Down
6 changes: 3 additions & 3 deletions lib/api/files.rb
Expand Up @@ -85,7 +85,7 @@ class Files < Grape::API
branch_name: branch_name
}
else
render_api_error!(result[:error], 400)
render_api_error!(result[:message], 400)
end
end

Expand Down Expand Up @@ -117,7 +117,7 @@ class Files < Grape::API
branch_name: branch_name
}
else
render_api_error!(result[:error], 400)
render_api_error!(result[:message], 400)
end
end

Expand Down Expand Up @@ -149,7 +149,7 @@ class Files < Grape::API
branch_name: branch_name
}
else
render_api_error!(result[:error], 400)
render_api_error!(result[:message], 400)
end
end
end
Expand Down

0 comments on commit 1af0c64

Please sign in to comment.