0

Rails3でrack/testとrspecを使用して、deviseを介してユーザーのAPIキーを認証しています。私が行うリクエストはすべて、ステータス302と「リダイレクトされています」という応答を返します。認証方法がわからないようです。

require 'spec_helper'

describe Api::V1::CollectController do
  def app
    Rails.application
  end 

  context 'user' do
    subject do
      FactoryGirl.create :user
    end

    it 'allow valid api credentials' do
      post '/api/collect', {}, { 'Authentication' => subject.authentication_token }
      p last_response.body
    end
  end
end    
4

1 に答える 1

0

私は実用的な解決策を見つけました。しかし、元のアプローチがうまくいかなかった理由には満足していません。ラック/テストを排除し、コントローラーとのインターフェース方法を変更しました。以下が機能しました。私は今、ほとんどただ興味があります...

require 'spec_helper'

describe Api::V1::CollectController do
  context 'user' do
    subject do
      FactoryGirl.create :user
    end

    it 'allow valid api credentials' do
      post :create, {}, { 'Authentication' => subject.authentication_token }
      p response.body
    end
  end
end  
于 2012-10-04T05:41:22.323 に答える