Skip to content
Extraits de code Groupes Projets
Valider fdc0b681 rédigé par danielgrippi's avatar danielgrippi
Parcourir les fichiers

remove unused api serializers (cruft)

parent b7ac77da
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
# Copyright (c) 2010-2011, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
class Api::V0::TagsController < ApplicationController
def show
render :json => Api::V0::Serializers::Tag.new(params[:name])
end
end
# Copyright (c) 2010-2011, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
class Api::V0::UsersController < ApplicationController
def show
if user = User.find_by_username(params[:username])
render :json => Api::V0::Serializers::User.new(user)
else
head :not_found
end
end
end
# Copyright (c) 2010-2011, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
class Api::V0::Serializers::Tag
def initialize(tag)
@stream = Stream::Tag.new(nil, tag)
end
def as_json(opts={})
{
"name" => @stream.tag_name,
"person_count" => @stream.tagged_people_count,
"followed_count" => @stream.tag_follow_count,
"posts" => []
}
end
end
# Copyright (c) 2010-2011, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
class Api::V0::Serializers::User
def initialize(user)
@person = user.person
@profile = @person.profile
end
def as_json(opts={})
{
"diaspora_id" => @person.diaspora_handle,
"first_name" => @profile.first_name,
"last_name" => @profile.last_name,
"image_url" => @profile.image_url,
"searchable" => @profile.searchable
}
end
end
# Copyright (c) 2010-2011, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
require 'spec_helper'
describe Api::V0::TagsController do
describe '#show' do
it 'succeeds' do
get :show, :name => 'alice'
response.should be_success
end
it "returns the basic tag data" do
get :show, :name => 'alice'
parsed_json = JSON.parse(response.body)
parsed_json.keys.should =~ %w(name person_count followed_count posts)
end
end
end
# Copyright (c) 2010-2011, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
require 'spec_helper'
describe Api::V0::UsersController do
describe '#show' do
it 'succeeds' do
get :show, :username => 'alice'
response.should be_success
end
it "404s if there's no such user" do
get :show, :username => "*****"
response.should be_not_found
end
it "returns the public profile data" do
get :show, :username => 'alice'
parsed_json = JSON.parse(response.body)
parsed_json.keys.should =~ %w( diaspora_id first_name last_name image_url searchable )
end
end
end
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter