Permalink
Browse files

WIP

  • Loading branch information...
1 parent 890d442 commit 0d8f07f42130ac190e3aede7ad4cdabf800aff36 @jcasimir jcasimir committed Jun 21, 2012
View
3 Gemfile
@@ -26,9 +26,12 @@ end
group :development, :test do
gem 'sqlite3'
gem 'rspec-rails'
+ gem 'capybara'
+ gem 'launchy'
gem 'guard'
gem 'guard-rspec'
gem 'growl'
+ gem 'factory_girl'
end
group :production do
View
28 Gemfile.lock
@@ -34,10 +34,20 @@ GEM
activesupport (3.2.3)
i18n (~> 0.6)
multi_json (~> 1.0)
+ addressable (2.2.8)
arel (3.0.2)
bcrypt-ruby (3.0.1)
blankslate (2.1.2.4)
builder (3.0.0)
+ capybara (1.1.2)
+ mime-types (>= 1.16)
+ nokogiri (>= 1.3.3)
+ rack (>= 1.0.0)
+ rack-test (>= 0.5.4)
+ selenium-webdriver (~> 2.0)
+ xpath (~> 0.1.4)
+ childprocess (0.3.2)
+ ffi (~> 1.0.6)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
railties (~> 3.2.0)
@@ -50,6 +60,8 @@ GEM
erubis (2.7.0)
execjs (1.3.2)
multi_json (~> 1.0)
+ factory_girl (3.4.2)
+ activesupport (>= 3.0.0)
faraday (0.8.0)
multipart-post (~> 1.1)
ffi (1.0.11)
@@ -80,6 +92,8 @@ GEM
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
railties (>= 3.0.0)
+ launchy (2.0.5)
+ addressable (~> 2.2.6)
less (2.2.1)
commonjs (~> 0.2.6)
less-rails (2.2.2)
@@ -88,13 +102,16 @@ GEM
less-rails-bootstrap (2.0.12)
less-rails (~> 2.2.0)
libv8 (3.3.10.4)
+ libwebsocket (0.1.3)
+ addressable
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.18)
multi_json (1.3.5)
multipart-post (1.1.5)
+ nokogiri (1.5.4)
oauth (0.4.6)
oauth2 (0.5.2)
faraday (~> 0.7)
@@ -167,11 +184,17 @@ GEM
activesupport (>= 3.0)
railties (>= 3.0)
rspec (~> 2.10.0)
+ rubyzip (0.9.9)
sass (3.1.18)
sass-rails (3.2.5)
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
+ selenium-webdriver (2.24.0)
+ childprocess (>= 0.2.5)
+ libwebsocket (~> 0.1.3)
+ multi_json (~> 1.0)
+ rubyzip
simple_form (2.0.2)
actionpack (~> 3.0)
activemodel (~> 3.0)
@@ -201,19 +224,24 @@ GEM
multi_json (>= 1.0.2)
vegas (0.1.11)
rack (>= 1.0.0)
+ xpath (0.1.4)
+ nokogiri (~> 1.3)
PLATFORMS
ruby
DEPENDENCIES
+ capybara
coffee-rails (~> 3.2.1)
+ factory_girl
growl
guard
guard-rspec
haml-rails
jbuilder
jquery-rails
kaminari
+ launchy
less-rails-bootstrap
omniauth
omniauth-github
View
11 app/controllers/refeeds_controller.rb
@@ -0,0 +1,11 @@
+class RefeedsController < ApplicationController
+
+ def create
+ feed_item = FeedItem.find(params[:feed_item_id])
+ feed = current_user.feed
+ feed.refeed(feed_item)
+
+ redirect_to feed_path(feed)
+ end
+
+end
View
12 app/views/feeds/show.html.haml
@@ -7,10 +7,14 @@
%img{src: feed_item.feed.gravatar}
%strong= link_to(feed_item.username, feed_item.feed)
= distance_of_time_in_words_to_now(feed_item.created_at) + " ago"
- %div.feed-item= render partial: feed_item, as: :feed_item
- - if logged_in? && current_user.created?(feed_item)
- = link_to 'Edit', edit_feed_item_path(feed_item), class: "btn"
- = link_to 'Destroy', feed_item_path(feed_item), :confirm => 'Are you sure?', :method => :delete, class: "btn btn-danger"
+ %div.feed-item
+ = render partial: feed_item, as: :feed_item
+ %br
+ - if logged_in? && current_user.created?(feed_item)
+ = link_to 'Edit', edit_feed_item_path(feed_item), class: "btn"
+ = link_to 'Destroy', feed_item_path(feed_item), :confirm => 'Are you sure?', :method => :delete, class: "btn btn-danger"
+ - elsif logged_in?
+ = link_to 'Refeed', '#', class: "btn"
= paginate @feed_items
View
4 config/routes.rb
@@ -4,7 +4,9 @@
resources :sessions, only: [:create, :destroy, :new]
resources :feeds, only: [:index, :show]
- resources :feed_items, except: [:index, :show], path: 'items'
+ resources :feed_items, except: [:index, :show], path: 'items' do
+ resources :refeeds, only: :create
+ end
resources :users, only: [:create, :new]
match 'signup' => 'users#new', :as => :signup
View
0 spec/controllers/refeeds_controller_spec.rb
No changes.
View
60 spec/requests/refeed_item_spec.rb
@@ -0,0 +1,60 @@
+require 'spec_helper'
+
+describe "Refeeding an item" do
+ let!(:jeff) do
+ if jeff = User.find_by_username('j3')
+ jeff
+ else
+ User.create(:username => 'j3', :email => 'jeff@jumpstartlab.com')
+ end
+ end
+ let!(:matt) do
+ if matt = User.find_by_username('mattyoho')
+ matt
+ else
+ User.create(:username => 'mattyoho', :email => 'matt@jumpstartlab.com', :password => 'hungry', :password_confirmation => 'hungry')
+ end
+ end
+
+ context "when I am logged in" do
+ before do
+ visit login_path
+ fill_in 'username', :with => 'mattyoho'
+ fill_in 'password', :with => 'hungry'
+ click_button 'Login'
+ end
+
+ context "when there is an item belonging to another user" do
+ before do
+ jeff.feed.feed_items << TextItem.new(:body => 'This is an item')
+ jeff.save
+ end
+
+ context "when I view that user's feed" do
+ before do
+ visit feed_path('j3')
+ end
+
+ it "I see a refeed button" do
+ within(".feed-item") do
+ page.should have_link('Refeed')
+ end
+ end
+
+ context "when I click to refeed" do
+ before do
+ within(".feed-item") do
+ click_link('Refeed')
+ end
+ end
+
+ it "shows up in my feed" do
+ visit feed_path('mattyoho')
+ page.should have_content "This is an item"
+ end
+ end
+ end
+ end
+ end
+end
+
View
9 spec/spec_helper.rb
@@ -8,6 +8,14 @@
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
+module Sorcery
+ module TestHelpers
+ def login_user(username, password)
+ page.driver.post(sessions_url, { username: username, password: password, remember_me: false})
+ end
+ end
+end
+
RSpec.configure do |config|
# ## Mock Framework
#
@@ -29,4 +37,5 @@
# automatically. This will be the default behavior in future versions of
# rspec-rails.
config.infer_base_class_for_anonymous_controllers = false
+ config.include Sorcery::TestHelpers
end

0 comments on commit 0d8f07f

Please sign in to comment.