DG MS IZ; Status message renders to and from xml; Friend model in place

This commit is contained in:
maxwell 2010-06-14 16:20:57 -07:00
parent db44081186
commit 1f73c2351e
10 changed files with 49 additions and 44 deletions

16
Gemfile
View file

@ -1,22 +1,13 @@
source 'http://rubygems.org'
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 "bson_ext", "1.0.1"
gem "nifty-generators"
gem "haml"
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
gem 'rspec', '>= 2.0.0.beta.10'
@ -27,3 +18,8 @@ group :test do
gem 'autotest'
end
group :development do
gem "nifty-generators"
gem 'ruby-debug'
end

View file

@ -29,5 +29,11 @@ class StatusMessagesController < ApplicationController
def show
@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

View file

@ -1,6 +1,5 @@
class Friend
include Mongoid::Document
include Mongoid::Timestamps
field :username
field :url

View file

@ -1,9 +1,13 @@
class StatusMessage
include Mongoid::Document
include Mongoid::Timestamps
include ROXML
xml_accessor :message
field :message
validates_presence_of :message
end

View file

@ -8,10 +8,8 @@ describe FriendsController do
Friend.create(:username => "max", :url => "http://max.com/")
end
it "index action should render index template" do
request.env['warden'].should_receive(:authenticate?).at_least(:once)
get :index
response.should render_template(:index)
end
@ -47,4 +45,11 @@ describe FriendsController do
post :create
response.should redirect_to(friend_url(assigns[:friend]))
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

View file

@ -50,4 +50,11 @@ describe StatusMessagesController do
get :show, :id => StatusMessage.first.id
response.should render_template(:show)
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

View file

@ -1,28 +1,4 @@
require File.dirname(__FILE__) + '/../spec_helper'
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
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

View file

@ -1,12 +1,10 @@
require File.dirname(__FILE__) + '/../spec_helper'
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.valid?.should == false
n.valid?.should be false
n.url = "http://max.com/"
n.valid?.should == true
n.valid?.should be true
end
end

View file

@ -7,4 +7,19 @@ describe StatusMessage do
n.message = "wales"
n.valid?.should be true
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

View file

@ -1,5 +1,4 @@
require 'spec_helper'
#this is implementation is done by devise
describe User do
end