Explorar el Código

add controller.

saberma hace 10 años
padre
commit
28fb68fb59

+ 11 - 0
app/controllers/china_city/data_controller.rb

@@ -0,0 +1,11 @@
+require_dependency "china_city/application_controller"
+
+module ChinaCity
+  class DataController < ApplicationController
+    layout nil
+    def show
+      data = ChinaCity.list(params[:id])
+      render json: data
+    end
+  end
+end

+ 2 - 0
config/routes.rb

@@ -1,2 +1,4 @@
 ChinaCity::Engine.routes.draw do
+  root to: 'data#show'
+  get ':id', to: 'data#show'
 end

+ 1 - 0
lib/china_city/engine.rb

@@ -7,6 +7,7 @@ module ChinaCity
       # g.fixture_replacement :factory_girl, dir: 'spec/factories'
       g.assets false
       g.helper false
+      g.view_specs false
     end
   end
 end

+ 12 - 0
spec/controllers/china_city/data_controller_spec.rb

@@ -0,0 +1,12 @@
+require 'spec_helper'
+
+describe ChinaCity::DataController do
+
+  describe "GET 'show'" do
+    it "returns http success" do
+      get 'show', id: '000000', use_route: 'china_city'
+      response.should be_success
+    end
+  end
+
+end