Added an error message when a locked rate is tried to be deleted. #1919
This commit is contained in:
@@ -109,6 +109,7 @@ class RatesController < ApplicationController
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
flash[:error] = "Rate is locked and cannot be deleted" if @rate.locked?
|
||||
if params[:back_url] && !params[:back_url].blank?
|
||||
redirect_to(params[:back_url])
|
||||
else
|
||||
|
||||
@@ -433,6 +433,14 @@ describe RatesController, "as an administrator" do
|
||||
delete :destroy, :id => "1", :back_url => back_url
|
||||
response.should redirect_to(back_url)
|
||||
end
|
||||
|
||||
describe "on a locked rate" do
|
||||
it "should display an error message" do
|
||||
Rate.stub!(:find).and_return(mock_rate(:destroy => false, :locked? => true))
|
||||
delete :destroy, :id => "1"
|
||||
flash[:error].should match(/locked/)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user