2014-04-16 21:12:06 +08:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe BadgesController do
|
|
|
|
let!(:badge) { Fabricate(:badge) }
|
|
|
|
|
|
|
|
context 'index' do
|
|
|
|
it 'should return a list of all badges' do
|
2014-04-26 02:25:29 +08:00
|
|
|
get :index, format: :json
|
2014-04-16 21:12:06 +08:00
|
|
|
|
|
|
|
response.status.should == 200
|
|
|
|
parsed = JSON.parse(response.body)
|
2014-05-05 02:15:38 +08:00
|
|
|
parsed["badges"].length.should == Badge.count
|
2014-04-16 21:12:06 +08:00
|
|
|
end
|
|
|
|
end
|
2014-04-16 22:56:11 +08:00
|
|
|
|
|
|
|
context 'show' do
|
|
|
|
it "should return a badge" do
|
2014-04-26 02:25:29 +08:00
|
|
|
get :show, id: badge.id, format: :json
|
2014-04-16 22:56:11 +08:00
|
|
|
response.status.should == 200
|
|
|
|
parsed = JSON.parse(response.body)
|
|
|
|
parsed["badge"].should be_present
|
|
|
|
end
|
|
|
|
end
|
2014-04-16 21:12:06 +08:00
|
|
|
end
|