diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb index de8c5c6f9..0398931c8 100644 --- a/app/controllers/status_messages_controller.rb +++ b/app/controllers/status_messages_controller.rb @@ -20,13 +20,13 @@ class StatusMessagesController < ApplicationController end def destroy - @status_message = StatusMessage.find(params[:id]) + @status_message = StatusMessage.first(:conditions => {:id => params[:id]}) @status_message.destroy flash[:notice] = "Successfully destroyed status message." redirect_to status_messages_url end def show - @status_message = StatusMessage.find(params[:id]) + @status_message = StatusMessage.first(:conditions => {:id => params[:id]}) end end diff --git a/app/models/status_message.rb b/app/models/status_message.rb index aae0e58d6..ce937c202 100644 --- a/app/models/status_message.rb +++ b/app/models/status_message.rb @@ -6,4 +6,4 @@ class StatusMessage validates_presence_of :message -end \ No newline at end of file +end diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index bbbcf7625..b2bad6ce9 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -12,10 +12,10 @@ %body #container - / - if user_signed_in? - / = link_to "log out", destroy_user_session_path - / - else - / = link_to "login", new_user_session_path + - if user_signed_in? + = link_to "log out", destroy_user_session_path + - else + = link_to "login", new_user_session_path - flash.each do |name, msg| = content_tag :div, msg, :id => "flash_#{name}" diff --git a/config/routes.rb b/config/routes.rb index 80c679be6..552d540cb 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -10,6 +10,8 @@ Diaspora::Application.routes.draw do |map| resources :users + resources :status_messages + match 'dashboard', :to => 'status_messages#index' # 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. # match ':controller(/:action(/:id(.:format)))' - root :to => "users#index" + root :to => 'status_messages#index' end diff --git a/spec/controllers/status_messages_controller_spec.rb b/spec/controllers/status_messages_controller_spec.rb index c53d5a631..00c920a88 100644 --- a/spec/controllers/status_messages_controller_spec.rb +++ b/spec/controllers/status_messages_controller_spec.rb @@ -1,7 +1,13 @@ require File.dirname(__FILE__) + '/../spec_helper' 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 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 status_message = StatusMessage.first - delete :destroy, :id => status_message + delete :destroy, :id => status_message.id 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 it "show action should render show template" do - get :show, :id => StatusMessage.first + get :show, :id => StatusMessage.first.id response.should render_template(:show) end end diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index 1718c345a..6805b99d6 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -1,8 +1,12 @@ require File.dirname(__FILE__) + '/../spec_helper' describe UsersController do - #render_views - #fixtures here? + 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 it 'should, after logging in redirect to the dashboard page' do pending diff --git a/spec/models/status_message_spec.rb b/spec/models/status_message_spec.rb index 621f49d27..87f7455ba 100644 --- a/spec/models/status_message_spec.rb +++ b/spec/models/status_message_spec.rb @@ -1,10 +1,10 @@ require File.dirname(__FILE__) + '/../spec_helper' describe StatusMessage do - it "should have a message and an owner" do + it "should have a message" do n = StatusMessage.new n.valid?.should be false n.message = "wales" n.valid?.should be true end -end \ No newline at end of file +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 341d78949..c45a3abfd 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -21,11 +21,12 @@ Rspec.configure do |config| config.fixture_path = "#{::Rails.root}/spec/fixtures" config.before(:each) do Mongoid.master.collections.select { |c| c.name != 'system.indexes' }.each(&:drop) + end # 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 # instead of true. - config.use_transactional_fixtures = true + config.use_transactional_fixtures = false end