Permalink
Browse files

Rename index action to build

There's really no *good* name for this action, but `index` was definitely bad.

`build` is actually what's happening at least. A Validation object is built from
the given params and a JSON error message array is the response.
  • Loading branch information...
1 parent 2d04277 commit 1f5cada468525bea913bbfe6bdba4981d7f5a7fc @joecorcoran committed Feb 26, 2013
@@ -2,7 +2,7 @@ module Judge
class ValidationsController < ::ApplicationController
include Judge::Controller
- def index
+ def build
respond_with(validation(params))
end
end
@@ -26,23 +26,23 @@
}
end
- describe "GET 'index'" do
+ describe "GET 'build'" do
describe "when allowed" do
before(:each) { Judge.config.stub(:exposed?).and_return(true) }
it "responds with empty JSON array if valid" do
- xhr :get, :index, valid_params, headers
+ xhr :get, :build, valid_params, headers
response.should be_success
response.body.should eql "[]"
end
it "responds with JSON array of error messages if invalid" do
- xhr :get, :index, invalid_params, headers
+ xhr :get, :build, invalid_params, headers
response.should be_success
response.body.should eql "[\"City must be an approved city\"]"
end
end
describe "when not allowed" do
it "responds with JSON array of error messages if class and attribute are not allowed in Judge config" do
- xhr :get, :index, valid_params, headers
+ xhr :get, :build, valid_params, headers
response.should be_success
response.body.should eql "[\"Judge validation for User#username not allowed\"]"
end

0 comments on commit 1f5cada

Please sign in to comment.