aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorMarc Florisson2012-12-13 19:14:45 +0100
committerMarc Florisson2012-12-13 19:14:45 +0100
commit988800310d2e6ae3dfc0935506eeae12f21c9ed6 (patch)
treed1bae0fe02f052006309755347a48f9f48537235 /spec
parent3a4ee94cd91de749521ac190656c65266861270f (diff)
downloadchouette-core-988800310d2e6ae3dfc0935506eeae12f21c9ed6.tar.bz2
refactor api/v1
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/api/v1/lines_controller_spec.rb1
-rw-r--r--spec/controllers/api/v1/stop_area_controller_spec.rb21
-rw-r--r--spec/support/api_key_protected.rb7
3 files changed, 23 insertions, 6 deletions
diff --git a/spec/controllers/api/v1/lines_controller_spec.rb b/spec/controllers/api/v1/lines_controller_spec.rb
index 2bf7515b9..5bd8cac57 100644
--- a/spec/controllers/api/v1/lines_controller_spec.rb
+++ b/spec/controllers/api/v1/lines_controller_spec.rb
@@ -5,7 +5,6 @@ describe Api::V1::LinesController do
it_behaves_like "api key protected controller" do
let(:data){line}
- let(:provided_referential){referential}
end
describe "GET #index" do
it "test" do
diff --git a/spec/controllers/api/v1/stop_area_controller_spec.rb b/spec/controllers/api/v1/stop_area_controller_spec.rb
new file mode 100644
index 000000000..cd1c2020b
--- /dev/null
+++ b/spec/controllers/api/v1/stop_area_controller_spec.rb
@@ -0,0 +1,21 @@
+require 'spec_helper'
+
+describe Api::V1::StopAreasController do
+ let!(:stop_area) { referential.stop_areas.first || create(:stop_area) }
+
+ it_behaves_like "api key protected controller" do
+ let(:data){stop_area}
+ end
+ describe "GET #index, route_id, line_id" do
+ let!(:line) { referential.lines.first || create(:line) }
+ let!(:route) { line.routes.first || create(:route, :line => line) }
+ before :each do
+ config_formatted_request_with_authorization( "application/json")
+ get :index, :route_id => route.objectid, :line_id => route.line.objectid
+ end
+ it "test" do
+ assigns[:stop_areas].should == route.stop_areas
+ end
+ end
+end
+
diff --git a/spec/support/api_key_protected.rb b/spec/support/api_key_protected.rb
index 9f3544afb..43256716d 100644
--- a/spec/support/api_key_protected.rb
+++ b/spec/support/api_key_protected.rb
@@ -1,14 +1,13 @@
shared_examples "api key protected controller" do
- let(:h) { { :index => (Proc.new { get :index, :referential_id => provided_referential.id }),
- :show => (Proc.new { get :show, :referential_id => provided_referential.id, :id => data.objectid })}}
+ let(:h) { { :index => (Proc.new { get :index }),
+ :show => (Proc.new { get :show, :id => data.objectid })}}
[:index, :show].each do |http_verb|
describe "GET ##{http_verb}" do
["application/json","application/xml","application/html"].each do |format|
context "when an invalid authorization is provided" do
before :each do
- puts "when an invalid authorization is provided"
config_formatted_request_with_dummy_authorization( format)
h[http_verb].call
end
@@ -18,7 +17,6 @@ shared_examples "api key protected controller" do
end
context "when no authorization is provided" do
before :each do
- puts "when no authorization is provided"
config_formatted_request_without_authorization( format)
h[http_verb].call
end
@@ -28,7 +26,6 @@ shared_examples "api key protected controller" do
end
context "when authorization provided and request.accept is #{format}," do
before :each do
- puts "when authorization provided and request.accept is #{format},"
config_formatted_request_with_authorization( format)
h[http_verb].call
end