Commit 8386179f authored by Dennis Collinson's avatar Dennis Collinson

max, you're a princess, WIP

parent 9f1713b8
......@@ -25,7 +25,7 @@ gem 'omniauth-tumblr'
gem 'omniauth-twitter'
gem 'twitter', '2.0.2'
gem 'rails_admin'
gem 'rails_admin', :require => false
# mail
......@@ -139,8 +139,6 @@ gem 'jasmine', :git => 'git://github.com/pivotal/jasmine-gem.git'
### GROUPS ####
group :test do
gem 'capybara', '~> 1.1.2'
gem 'cucumber-rails', '1.3.0', :require => false
gem 'database_cleaner', '0.7.1'
......@@ -162,7 +160,7 @@ group :test do
gem 'sqlite3'
gem 'mock_redis'
gem 'spork', '~> 1.0rc2'
gem 'spork', '~> 1.0rc3'
gem 'guard-rspec'
gem 'guard-spork'
gem 'guard-cucumber'
......
......@@ -584,7 +584,7 @@ DEPENDENCIES
sass-rails (= 3.1.4)
selenium-webdriver
settingslogic!
spork (~> 1.0rc2)
spork (~> 1.0rc3)
sqlite3
thin (~> 1.3.1)
timecop
......
......@@ -71,11 +71,11 @@ class Post < ActiveRecord::Base
joins(:likes).where(:likes => {:author_id => person.id})
}
def self.next(post)
def self.newer(post)
where("posts.created_at > ?", post.created_at).order('posts.created_at ASC').first
end
def self.previous(post)
def self.older(post)
where("posts.created_at < ?", post.created_at).order('posts.created_at DESC').first
end
......@@ -86,6 +86,7 @@ class Post < ActiveRecord::Base
author.posts.all_public
end
end
def post_type
self.class.name
end
......
......@@ -91,11 +91,11 @@ class PostPresenter
protected
def next_post
post_base.next(post)
post_base.newer(post)
end
def previous_post
post_base.previous(post)
post_base.older(post)
end
def as_api(collection)
......
......@@ -9,7 +9,7 @@ Diaspora::Application.configure do
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
config.cache_classes = true
config.cache_classes = false
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
......
This diff is collapsed.
......@@ -3,7 +3,10 @@
# the COPYRIGHT file.
Diaspora::Application.routes.draw do
mount RailsAdmin::Engine => '/admin_panel', :as => 'rails_admin'
begin
mount RailsAdmin::Engine => '/admin_panel', :as => 'rails_admin'
rescue
end
get 'oembed' => 'posts#oembed', :as => 'oembed'
# Posting and Reading
......
......@@ -47,6 +47,7 @@ describe Post do
end
end
describe '.for_a_stream' do
it 'calls #for_visible_shareable_sql' do
time, order = stub, stub
......@@ -112,7 +113,7 @@ describe Post do
before do
time_interval = 1000
time_past = 1000000
@posts = (1..3).map do |n|
@posts = (1..5).map do |n|
aspect_to_post = alice.aspects.where(:name => "generic").first
post = alice.post :status_message, :text => "#{alice.username} - #{n}", :to => aspect_to_post.id
post.created_at = (post.created_at-time_past) - time_interval
......@@ -124,8 +125,6 @@ describe Post do
end
describe '.by_max_time' do
it 'respects time and order' do
end
it 'returns the posts ordered and limited by unix time' do
Post.for_a_stream(Time.now + 1, "created_at").should == @posts
......@@ -150,6 +149,22 @@ describe Post do
end
end
# @posts[0] is the newest, @posts[5] is the oldest
describe ".newer" do
it 'returns the next post in the array' do
@posts.each_with_index {|p, i| p p.created_at, i }
@posts[3].created_at.should < @posts[2].created_at #post 2 is newer
Post.newer(@posts[3]).created_at.to_s.should == @posts[2].created_at.to_s #its the newer post, not the newest
end
end
describe ".older" do
it 'returns the previous post in the array' do
Post.older(@posts[3]).created_at.to_s.should == @posts[4].created_at.to_s #its the older post, not the oldest
@post[3].created_at.should > @post[4].created_at #post 4 is older
end
end
end
end
......
......@@ -12,6 +12,9 @@ Spork.prefork do
# if you change any configuration or code from libraries loaded here, you'll
# need to restart spork for it take effect.
#require "rails/application"
#Spork.trap_method(Rails::Application::RoutesReloader, :reload!)
ENV["RAILS_ENV"] ||= 'test'
require File.join(File.dirname(__FILE__), '..', 'config', 'environment') unless defined?(Rails)
require 'helper_methods'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment