次の形式で API にリクエストを送信しています
http://server/url?v=HEAD&access_token=TOKEN
私の質問は、コントローラー仕様内のリクエストにvパラメーターとaccess_tokenパラメーターを追加するにはどうすればよいですか?
以下は、私がこれまでに持っているもののサンプルです。どれも機能しません:
describe Api::ShopsController do
let(:application) { Doorkeeper::Application.create(:name => "MyApp", :redirect_uri => "http://app.com") }
let(:user) { FactoryGirl.create(:user) }
let(:token) { Doorkeeper::AccessToken.create! :application_id => application.id, :resource_owner_id => user.id }
describe "GET #index" do
it "should respond with 200" do
get :index, :format => :json, :access_token => token.token
response.status.should eq(200)
end
it "should list all shops" do
Shop.should_receive(:all) { [] }
get :index, :format => :json, :access_token => token.token
response.body.should == [].to_json
end
end
# Example url: localhost:3000/shops/1?v=HEAD&access_token=TOKEN
describe "GET show" do
it 'responds with 200' do
shop = Shop.create! FactoryGirl.attributes_for :shop
get :show, {id: shop.id, :access_token => access_token.token, v: "HEAD"}, :format => :json
response.status.should eq(200)
end
it "returns the requested shop" do
shop = Shop.create! FactoryGirl.attributes_for :shop
get :show, {:id => user.to_param}, :format => :json, :access_token => token.token
assigns(:user).should eq(user)
end
end