DG, MS, IZ; status messages now functional

This commit is contained in:
maxwell 2010-06-13 22:11:16 -07:00
parent 85e6eb2132
commit 29c6f9fa0f
8 changed files with 30 additions and 17 deletions

View file

@ -20,13 +20,13 @@ class StatusMessagesController < ApplicationController
end end
def destroy def destroy
@status_message = StatusMessage.find(params[:id]) @status_message = StatusMessage.first(:conditions => {:id => params[:id]})
@status_message.destroy @status_message.destroy
flash[:notice] = "Successfully destroyed status message." flash[:notice] = "Successfully destroyed status message."
redirect_to status_messages_url redirect_to status_messages_url
end end
def show def show
@status_message = StatusMessage.find(params[:id]) @status_message = StatusMessage.first(:conditions => {:id => params[:id]})
end end
end end

View file

@ -12,10 +12,10 @@
%body %body
#container #container
/ - if user_signed_in? - if user_signed_in?
/ = link_to "log out", destroy_user_session_path = link_to "log out", destroy_user_session_path
/ - else - else
/ = link_to "login", new_user_session_path = link_to "login", new_user_session_path
- flash.each do |name, msg| - flash.each do |name, msg|
= content_tag :div, msg, :id => "flash_#{name}" = content_tag :div, msg, :id => "flash_#{name}"

View file

@ -10,6 +10,8 @@ Diaspora::Application.routes.draw do |map|
resources :users resources :users
resources :status_messages
match 'dashboard', :to => 'status_messages#index'
# The priority is based upon order of creation: # The priority is based upon order of creation:
@ -69,6 +71,6 @@ Diaspora::Application.routes.draw do |map|
# Note: This route will make all actions in every controller accessible via GET requests. # Note: This route will make all actions in every controller accessible via GET requests.
# match ':controller(/:action(/:id(.:format)))' # match ':controller(/:action(/:id(.:format)))'
root :to => "users#index" root :to => 'status_messages#index'
end end

View file

@ -1,7 +1,13 @@
require File.dirname(__FILE__) + '/../spec_helper' require File.dirname(__FILE__) + '/../spec_helper'
describe StatusMessagesController do describe StatusMessagesController do
fixtures :all before do
#TODO(dan) Mocking Warden; this is a temp fix
request.env['warden'] = mock_model(Warden, :authenticate => @user, :authenticate! => @user)
StatusMessage.create(:message => "yodels.")
end
#fixtures :all
render_views render_views
it "index action should render index template" do it "index action should render index template" do
@ -28,13 +34,13 @@ describe StatusMessagesController do
it "destroy action should destroy model and redirect to index action" do it "destroy action should destroy model and redirect to index action" do
status_message = StatusMessage.first status_message = StatusMessage.first
delete :destroy, :id => status_message delete :destroy, :id => status_message.id
response.should redirect_to(status_messages_url) response.should redirect_to(status_messages_url)
StatusMessage.exists?(status_message.id).should be_false StatusMessage.first(:conditions => {:id => status_message.id }).nil?.should be true
end end
it "show action should render show template" do it "show action should render show template" do
get :show, :id => StatusMessage.first get :show, :id => StatusMessage.first.id
response.should render_template(:show) response.should render_template(:show)
end end
end end

View file

@ -1,8 +1,12 @@
require File.dirname(__FILE__) + '/../spec_helper' require File.dirname(__FILE__) + '/../spec_helper'
describe UsersController do describe UsersController do
#render_views before do
#fixtures here? #TODO(dan) Mocking Warden; this is a temp fix
request.env['warden'] = mock_model(Warden, :authenticate => @user, :authenticate! => @user)
end
render_views
#fixtures :all
it 'should, after logging in redirect to the dashboard page' do it 'should, after logging in redirect to the dashboard page' do
pending pending

View file

@ -1,7 +1,7 @@
require File.dirname(__FILE__) + '/../spec_helper' require File.dirname(__FILE__) + '/../spec_helper'
describe StatusMessage do describe StatusMessage do
it "should have a message and an owner" do it "should have a message" do
n = StatusMessage.new n = StatusMessage.new
n.valid?.should be false n.valid?.should be false
n.message = "wales" n.message = "wales"

View file

@ -21,11 +21,12 @@ Rspec.configure do |config|
config.fixture_path = "#{::Rails.root}/spec/fixtures" config.fixture_path = "#{::Rails.root}/spec/fixtures"
config.before(:each) do config.before(:each) do
Mongoid.master.collections.select { |c| c.name != 'system.indexes' }.each(&:drop) Mongoid.master.collections.select { |c| c.name != 'system.indexes' }.each(&:drop)
end end
# If you're not using ActiveRecord, or you'd prefer not to run each of your # If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, comment the following line or assign false # examples within a transaction, comment the following line or assign false
# instead of true. # instead of true.
config.use_transactional_fixtures = true config.use_transactional_fixtures = false
end end