Permalink
Browse files

Timeline and cucumber feature.

  • Loading branch information...
halogenandtoast committed Apr 3, 2012
1 parent ef4e837 commit c6e7e234024e592e0fdd667162a6a32accf280a3
View
@@ -13,6 +13,8 @@ group :test do
gem 'factory_girl_rails'
gem 'cucumber-rails'
gem 'database_cleaner'
+ gem 'launchy'
+ gem 'ruby-debug19', require: "ruby-debug"
end
View
@@ -28,6 +28,8 @@ GEM
activesupport (3.2.2)
i18n (~> 0.6)
multi_json (~> 1.0)
+ addressable (2.2.7)
+ archive-tar-minitar (0.5.2)
arel (3.0.2)
builder (3.0.0)
capybara (1.1.2)
@@ -49,6 +51,7 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.2.0)
+ columnize (0.3.6)
cucumber (1.1.4)
builder (>= 2.1.2)
diff-lcs (>= 1.1.2)
@@ -82,6 +85,10 @@ GEM
thor (~> 0.14)
json (1.6.6)
json_pure (1.6.5)
+ launchy (2.1.0)
+ addressable (~> 2.2.6)
+ linecache19 (0.5.12)
+ ruby_core_source (>= 0.1.4)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
@@ -128,6 +135,16 @@ GEM
activesupport (>= 3.0)
railties (>= 3.0)
rspec (~> 2.8.0)
+ ruby-debug-base19 (0.11.25)
+ columnize (>= 0.3.1)
+ linecache19 (>= 0.5.11)
+ ruby_core_source (>= 0.1.4)
+ ruby-debug19 (0.11.6)
+ columnize (>= 0.3.1)
+ linecache19 (>= 0.5.11)
+ ruby-debug-base19 (>= 0.11.19)
+ ruby_core_source (0.1.5)
+ archive-tar-minitar (>= 0.5.2)
rubyzip (0.9.6.1)
sass (3.1.15)
sass-rails (3.2.5)
@@ -167,8 +184,10 @@ DEPENDENCIES
database_cleaner
factory_girl_rails
jquery-rails
+ launchy
rails (= 3.2.2)
rspec-rails
+ ruby-debug19
sass-rails (~> 3.2.3)
sqlite3
uglifier (>= 1.0.3)
@@ -2,6 +2,6 @@ class DashboardsController < ApplicationController
before_filter :authorize
def show
@shout = Shout.new
- @shouts = current_user.current_shouts
+ @shouts = current_user.timeline_shouts
end
end
@@ -0,0 +1,11 @@
+class ShoutTimeline
+ extend ActiveModel::Naming
+
+ def initialize(user_ids)
+ @user_ids = user_ids
+ end
+
+ def shouts
+ Shout.where(:user_id => @user_ids).current
+ end
+end
View
@@ -8,7 +8,11 @@ class User < ActiveRecord::Base
has_many :following_users, through: :following_user_relationships, source: :follower
def current_shouts
- shouts.current
+ ShoutTimeline.new([id])
+ end
+
+ def timeline_shouts
+ ShoutTimeline.new(self_and_followed_user_ids)
end
def follow(followed_user)
@@ -0,0 +1,3 @@
+<div id="shout_timeline">
+ <%= render shout_timeline.shouts %>
+</div>
@@ -0,0 +1,19 @@
+module DebugHelpers
+ def pause_page
+ puts
+ puts "Press enter to continue"
+ $stdin.gets
+ end
+end
+
+When /^I pause the page$/ do
+ pause_page
+end
+
+After do |scenario|
+ if scenario.failed? && ENV["PAUSE"]
+ pause_page
+ end
+end
+
+World(DebugHelpers)
@@ -0,0 +1,6 @@
+Given /^I am signed in as "([^"]*)"$/ do |user_email|
+ visit "/sign_in"
+ fill_in "Email", with: user_email
+ fill_in "Password", with: "password"
+ click_button "Sign in"
+end
@@ -0,0 +1,4 @@
+When /^I am on the dashboard$/ do
+ visit "/dashboard"
+end
+
@@ -0,0 +1,7 @@
+Then /^I can see the following timeline:$/ do |table|
+ shouts = all(".shout")
+ table.raw.each_with_index do |row, i|
+ shout_text = row[0]
+ shouts[i].should have_content(shout_text)
+ end
+end
@@ -0,0 +1,5 @@
+Given /^"([^"]*)" is following "([^"]*)"$/ do |follower_email, followed_user_email|
+ follower = User.find_by_email(follower_email)
+ followed_user = User.find_by_email(followed_user_email)
+ follower.follow(followed_user)
+end

0 comments on commit c6e7e23

Please sign in to comment.