Permalink
Browse files

Made display of opted-in users more visible.

  • Loading branch information...
Jim Kingdon & William Pietri
Jim Kingdon & William Pietri committed Nov 12, 2011
1 parent d6bf15f commit 53678b78102eb4b233cc0b2b682e3b5cb6b0c6e1
@@ -1,10 +1,9 @@
class PeopleController < ApplicationController
before_filter :load_location, :only => [:index, :create]
-
+
def index
@person = Person.new
- @people = @location.people
- @people_count = @people.count
+ load_people()
end
def welcome
@@ -16,8 +15,7 @@ def create
flash[:message] = "Cool, you're signed up!"
redirect_to location_path(@location)
else
- @people = @location.people
- @people_count = @people.count
+ load_people()
render :template => "people/index"
end
end
@@ -38,11 +36,21 @@ def update
render :edit
end
+ private
+
def load_location
@location = Location.find_by_name(params[:location])
if @location.nil?
redirect_to root_path
return
end
end
+
+ def load_people
+ people = @location.people
+ @opted_in_people = people.opted_in
+ @non_opted_in_people = people - @opted_in_people
+ @people_count = people.count
+ end
+
end
@@ -24,14 +24,19 @@
%h3 People at #{@location.name}
-%div#people_at_location
- - @people.each do |person|
- %img{ :src => person.gravatar_url, :class => "gravatar #{person.going? ? 'in' : 'out' }" }
+.opted_in
+ %h4 People who are going
+ - @opted_in_people.each do |person|
+ %img{ :src => person.gravatar_url, :class => "gravatar in" }
+.non_opted_in
+ %h4 People who are not (yet) going
+ - @non_opted_in_people.each do |person|
+ %img{ :src => person.gravatar_url, :class => "gravatar out" }
%div
%small
- Sign up with
- %a{:href=>"http://en.gravatar.com/site/signup/"} gravatar
- to set up your profile picture if you haven't already.
+ If your profile picture doesn't show up here, sign up with
+ = succeed "." do
+ %a{:href=>"http://en.gravatar.com/site/signup/"} gravatar
%h3 Favorite Restaurants for #{@location.name}
View
@@ -10,6 +10,6 @@
get ":location" => "people#index", :as => :location
post "people" => "people#create"
- match ':controller(/:action(/:id(.:format)))'
+ match ':controller(/:action(/:id(.:format)))' # TODO:KILL ME
end
@@ -57,12 +57,12 @@ li {
}
.in {
- border: 2px solid green;
+ border: 3px solid green;
padding: 1px;
}
.out {
- border: 2px solid gray;
+ border: 1px solid gray;
padding: 1px;
}
@@ -27,6 +27,20 @@
get :index, :location => "mylocation"
Nokogiri::HTML(response.body).css("img.gravatar").map { |node| node.attr("src") }.should =~ people.map(&:gravatar_url)
end
+
+ it "should show people who are opted in above others" do
+ location = Location.create!(:name => "mylocation", :address => "149 9th Street San Francisco, CA")
+ opted_in_person = create_person(:email => "in@example.com", :opt_in_datetime => DateTime.parse("9999-11-11 11:11:11 UTC"), :location => location)
+ non_opted_in_person = create_person(:email => "not_in@example.com", :opt_in_datetime => nil, :location => location)
+
+ get :index, :location => "mylocation"
+
+ assigns(:opted_in_people).map(&:gravatar_url).should == [opted_in_person.gravatar_url]
+ assigns(:non_opted_in_people).map(&:gravatar_url).should == [non_opted_in_person.gravatar_url]
+
+ Nokogiri::HTML(response.body).css(".opted_in img.gravatar").map { |node| node.attr("src") }.should =~ [opted_in_person.gravatar_url]
+ Nokogiri::HTML(response.body).css(".non_opted_in img.gravatar").map { |node| node.attr("src") }.should =~ [non_opted_in_person.gravatar_url]
+ end
end
describe "#welcome" do
@@ -132,7 +146,7 @@
get :update, :token => person.authentication_token, :person => { :opt_in_datetime => future }
end
- it "should renders a button to not go" do
+ it "should render a button to not go" do
person.reload.should be_going
response.should have_selector("input", :type => 'submit', :value => "Actually, I don't want to go")
end
@@ -144,7 +158,7 @@
it "should render the actual gravatars of people opted-in" do
Nokogiri::HTML(response.body).css("img.gravatar").map { |node| node.attr("src") }.should =~ assigns(:people).map(&:gravatar_url)
end
-
+
end
context "with an invalid token" do

0 comments on commit 53678b7

Please sign in to comment.