Skip to content

Commit

Permalink
Return a status in JSON format by the id parameter. The author is ret…
Browse files Browse the repository at this point in the history
…urned inline.
  • Loading branch information
Nakort authored and carols10cents committed Oct 13, 2012
1 parent ebca9fc commit 3ed4e34
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
8 changes: 8 additions & 0 deletions app/controllers/api/statuses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ class StatusesController < ApplicationController
#
before_filter :require_user

def show
@update = Update.first(:id => params[:id])
respond_to do |format|
format.json do
render :json => UpdateJsonDecorator.decorate(@update)
end
end
end
#
# POST /api/statuses/update.json
#
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
resources :updates, :only => [:index, :show, :create, :destroy]
match "/timeline", :to => "updates#timeline"
match "/replies", :to => "updates#replies"

# Search
resource :search, :only => :show

Expand Down Expand Up @@ -77,5 +76,6 @@
match 'statuses/home_timeline.:format', :to => "statuses#home_timeline", :via => :get, :constraints => { :format => "json" }
match 'statuses/user_timeline.:format', :to => "statuses#user_timeline", :via => :get, :constraints => { :format => "json" }
match 'statuses/mention.:format', :to => "statuses#mention", :via => :get, :constraints => { :format => "json" }
match "statuses/show/:id", :to => "statuses#show"
end
end
14 changes: 14 additions & 0 deletions test/acceptance/json_api/statuses_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require 'require_relative' if RUBY_VERSION[0,3] == '1.8'
require_relative '../acceptance_helper'

describe "JSON get statos" do
include AcceptanceHelper

it "returns the update" do
log_in_as_some_user
status = Fabricate(:update)
visit "/api/statuses/show/#{status.id}.json"
parsed_json = JSON.parse(source)
parsed_json["text"].must_equal(status.text)
end
end

0 comments on commit 3ed4e34

Please sign in to comment.