DG MS IZ; Status message renders to and from xml; Friend model in place
This commit is contained in:
parent
db44081186
commit
1f73c2351e
10 changed files with 49 additions and 44 deletions
16
Gemfile
16
Gemfile
|
|
@ -1,22 +1,13 @@
|
||||||
source 'http://rubygems.org'
|
source 'http://rubygems.org'
|
||||||
|
|
||||||
gem 'rails', '3.0.0.beta4'
|
gem 'rails', '3.0.0.beta4'
|
||||||
# gem 'rails', :git => 'git://github.com/rails/rails.git'
|
|
||||||
|
|
||||||
gem "mongoid", :git => "http://github.com/durran/mongoid.git"
|
gem "mongoid", :git => "http://github.com/durran/mongoid.git"
|
||||||
gem "bson_ext", "1.0.1"
|
gem "bson_ext", "1.0.1"
|
||||||
gem "nifty-generators"
|
|
||||||
gem "haml"
|
gem "haml"
|
||||||
gem "devise", :git => "git://github.com/plataformatec/devise.git"
|
gem "devise", :git => "git://github.com/plataformatec/devise.git"
|
||||||
|
gem 'roxml', :git => "git://github.com/Empact/roxml.git"
|
||||||
|
|
||||||
# Use unicorn as the web server
|
|
||||||
# gem 'unicorn'
|
|
||||||
|
|
||||||
# Deploy with Capistrano
|
|
||||||
# gem 'capistrano'
|
|
||||||
|
|
||||||
# To use debugger
|
|
||||||
gem 'ruby-debug'
|
|
||||||
|
|
||||||
group :test do
|
group :test do
|
||||||
gem 'rspec', '>= 2.0.0.beta.10'
|
gem 'rspec', '>= 2.0.0.beta.10'
|
||||||
|
|
@ -27,3 +18,8 @@ group :test do
|
||||||
gem 'autotest'
|
gem 'autotest'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
group :development do
|
||||||
|
gem "nifty-generators"
|
||||||
|
gem 'ruby-debug'
|
||||||
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,5 +29,11 @@ class StatusMessagesController < ApplicationController
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@status_message = StatusMessage.first(:conditions => {:id => params[:id]})
|
@status_message = StatusMessage.first(:conditions => {:id => params[:id]})
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html
|
||||||
|
format.xml { render :xml => @status_message }
|
||||||
|
format.json { render :json => @status_message }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
class Friend
|
class Friend
|
||||||
include Mongoid::Document
|
include Mongoid::Document
|
||||||
include Mongoid::Timestamps
|
|
||||||
|
|
||||||
field :username
|
field :username
|
||||||
field :url
|
field :url
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,13 @@
|
||||||
class StatusMessage
|
class StatusMessage
|
||||||
include Mongoid::Document
|
include Mongoid::Document
|
||||||
include Mongoid::Timestamps
|
include Mongoid::Timestamps
|
||||||
|
include ROXML
|
||||||
|
|
||||||
|
xml_accessor :message
|
||||||
|
|
||||||
|
|
||||||
field :message
|
field :message
|
||||||
|
|
||||||
|
|
||||||
validates_presence_of :message
|
validates_presence_of :message
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,8 @@ describe FriendsController do
|
||||||
Friend.create(:username => "max", :url => "http://max.com/")
|
Friend.create(:username => "max", :url => "http://max.com/")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
it "index action should render index template" do
|
it "index action should render index template" do
|
||||||
request.env['warden'].should_receive(:authenticate?).at_least(:once)
|
request.env['warden'].should_receive(:authenticate?).at_least(:once)
|
||||||
|
|
||||||
get :index
|
get :index
|
||||||
response.should render_template(:index)
|
response.should render_template(:index)
|
||||||
end
|
end
|
||||||
|
|
@ -47,4 +45,11 @@ describe FriendsController do
|
||||||
post :create
|
post :create
|
||||||
response.should redirect_to(friend_url(assigns[:friend]))
|
response.should redirect_to(friend_url(assigns[:friend]))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should test that a real creation adds to the database' do
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should have test that a delete removes a friend from the database' do
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -50,4 +50,11 @@ describe StatusMessagesController do
|
||||||
get :show, :id => StatusMessage.first.id
|
get :show, :id => StatusMessage.first.id
|
||||||
response.should render_template(:show)
|
response.should render_template(:show)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should return xml on the show type if the meme type exsits" do
|
||||||
|
request.env["HTTP_ACCEPT"] = "application/xml"
|
||||||
|
message = StatusMessage.first
|
||||||
|
get :show, :id => message.id
|
||||||
|
response.body.include?(message.to_xml.to_s).should be true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1,4 @@
|
||||||
require File.dirname(__FILE__) + '/../spec_helper'
|
require File.dirname(__FILE__) + '/../spec_helper'
|
||||||
|
|
||||||
describe UsersController do
|
describe UsersController do
|
||||||
before do
|
|
||||||
#TODO(dan) Mocking Warden; this is a temp fix
|
|
||||||
request.env['warden'] = mock_model(Warden, :authenticate => @user, :authenticate! => @user)
|
|
||||||
end
|
end
|
||||||
render_views
|
|
||||||
#fixtures :all
|
|
||||||
end
|
|
||||||
describe Devise::SessionsController do
|
|
||||||
before do
|
|
||||||
#TODO(dan) Mocking Warden; this is a temp fix
|
|
||||||
request.env['warden'] = mock_model(Warden, :authenticate => @user, :authenticate! => @user)
|
|
||||||
@user = User.create(:email => "bob@rob.com", :password => "lala")
|
|
||||||
end
|
|
||||||
it 'should, after logging in redirect to the dashboard page' do
|
|
||||||
pending "probs should be in cucumber"
|
|
||||||
sign_in :user, @user
|
|
||||||
# request.env['warden'].should_receive(:authenticated?).at_least(:once)
|
|
||||||
# request.env['warden'].should_receive(:user).at_least(:once)
|
|
||||||
|
|
||||||
#User.any_instance.stubs(:valid?).returns(true)
|
|
||||||
#post :create
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,10 @@
|
||||||
require File.dirname(__FILE__) + '/../spec_helper'
|
require File.dirname(__FILE__) + '/../spec_helper'
|
||||||
|
|
||||||
describe Friend do
|
describe Friend do
|
||||||
it 'should have a diaspora username + diaspora url' do
|
it 'should have a diaspora username and diaspora url' do
|
||||||
n = Friend.new(:username => 'max')
|
n = Friend.new(:username => 'max')
|
||||||
n.valid?.should == false
|
n.valid?.should be false
|
||||||
n.url = "http://max.com/"
|
n.url = "http://max.com/"
|
||||||
n.valid?.should == true
|
n.valid?.should be true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
@ -7,4 +7,19 @@ describe StatusMessage do
|
||||||
n.message = "wales"
|
n.message = "wales"
|
||||||
n.valid?.should be true
|
n.valid?.should be true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "XML" do
|
||||||
|
before do
|
||||||
|
@xml = "<statusmessage>\n <message>I hate WALRUSES!</message>\n</statusmessage>"
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should serialize to XML' do
|
||||||
|
message = StatusMessage.new(:message => "I hate WALRUSES!")
|
||||||
|
message.to_xml.to_s.should == @xml
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should marshal serialized XML to object' do
|
||||||
|
StatusMessage.from_xml(@xml).message.should == "I hate WALRUSES!"
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
#this is implementation is done by devise
|
|
||||||
describe User do
|
describe User do
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue