From 0b1fa4d014ac190915e6efa39958a3d72defcf9d Mon Sep 17 00:00:00 2001 From: Sarah Mei Date: Sat, 19 Mar 2011 20:53:55 -0700 Subject: [PATCH] You can now add contacts from tags#show. Also, a CSS change to help us start refactoring: there's now a class to the body that you can set with content_for :body_class. This lets you scope CSS to a particular page. Started breaking out smaller CSS files. --- app/views/layouts/application.html.haml | 2 +- app/views/tags/show.html.haml | 9 +++- config/assets.yml | 1 + features/connects_users.feature | 5 +-- features/step_definitions/custom_web_steps.rb | 18 +++++++- features/step_definitions/user_steps.rb | 9 ++++ features/tags.feature | 27 ++++++++++-- public/stylesheets/sass/sessions.sass | 2 - public/stylesheets/sass/tags.sass | 12 ++++++ spec/controllers/tags_controller_spec.rb | 42 +++++++++++++------ spec/support/fixture_builder.rb | 4 -- 11 files changed, 101 insertions(+), 30 deletions(-) create mode 100644 public/stylesheets/sass/tags.sass diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 3721ca088..2c893fe8f 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -75,7 +75,7 @@ - elsif current_user %link{:rel => "alternate", :href => "#{current_user.public_url}", :type => "application/atom+xml", :title => "#{t('.public_feed', :name => current_user.name)}"} - %body + %body{:class => "#{yield(:body_class)}"} - unless @landing_page #notification diff --git a/app/views/tags/show.html.haml b/app/views/tags/show.html.haml index c2749bf5b..50970b15b 100644 --- a/app/views/tags/show.html.haml +++ b/app/views/tags/show.html.haml @@ -2,17 +2,18 @@ -# licensed under the Affero General Public License version 3 or later. See -# the COPYRIGHT file. - - content_for :page_title do - if params[:name] = "##{params[:name]}" - - else = t('.whatup', :pod => @pod_url) - content_for :head do = include_javascripts :home +- content_for :body_class do + = "tags_show" + .span-24.last %h1.tag = "##{params[:name]}" @@ -35,6 +36,10 @@ - for person in @people .stream_element{:id => person.id} = person_image_link(person) + - if current_user + .right + = render :partial => 'people/relationship_action', + :locals => { :person => person, :contact => current_user.contact_for(person), :request => nil} .content %span.from =person_link(person) diff --git a/config/assets.yml b/config/assets.yml index 0223684bc..0425d1d04 100644 --- a/config/assets.yml +++ b/config/assets.yml @@ -68,6 +68,7 @@ stylesheets: - public/stylesheets/application.css - public/stylesheets/ui.css - public/stylesheets/autocomplete.css + - public/stylesheets/tags.css - public/stylesheets/vendor/facebox.css - public/stylesheets/vendor/fileuploader.css - public/stylesheets/vendor/tipsy.css diff --git a/features/connects_users.feature b/features/connects_users.feature index c0ee19a44..596fccc26 100644 --- a/features/connects_users.feature +++ b/features/connects_users.feature @@ -7,10 +7,7 @@ Feature: sending and receiving requests When I sign in as "bob@bob.bob" And I am on "alice@alice.alice"'s page And I press the first ".share_with.button" within "#author_info" - And I press the first ".add.button" within "#facebox #aspects_list ul > li:first-child" - #And I debug - And I wait for the ajax to finish - Then I should see a ".added.button" within "#facebox #aspects_list ul > li:first-child" + And I add the person to my first aspect Then I go to the destroy user session page Scenario: accepting a contact request diff --git a/features/step_definitions/custom_web_steps.rb b/features/step_definitions/custom_web_steps.rb index ba8146848..613351df0 100644 --- a/features/step_definitions/custom_web_steps.rb +++ b/features/step_definitions/custom_web_steps.rb @@ -139,5 +139,21 @@ When /^I search for "([^\"]*)"$/ do |search_term| var e = jQuery.Event("keypress"); e.keyCode = 13; $("#q").trigger(e); -JS + JS +end + +Then /^I should( not)? see the contact dialog$/ do |not_see| + if not_see + wait_until { !page.find("#facebox").visible? } + else + wait_until { page.find("#facebox .share_with") && page.find("#facebox .share_with").visible? } + end +end + +When /^I add the person to my first aspect$/ do + steps %Q{ + And I press the first ".add.button" within "#facebox #aspects_list ul > li:first-child" + And I wait for the ajax to finish + Then I should see a ".added.button" within "#facebox #aspects_list ul > li:first-child" + } end \ No newline at end of file diff --git a/features/step_definitions/user_steps.rb b/features/step_definitions/user_steps.rb index 353aaeb6d..d193cbf75 100644 --- a/features/step_definitions/user_steps.rb +++ b/features/step_definitions/user_steps.rb @@ -149,3 +149,12 @@ When /^I log out$/ do When "I click on my name in the header" When "I follow \"logout\"" end + +Given /^there is a user "([^\"]*)" who's tagged "([^\"]*)"$/ do |full_name, tag| + username = full_name.gsub(/\W/,"").underscore + Given "a user named \"#{full_name}\" with email \"#{username}@example.com\"" + user = User.find_by_username(username) + user.profile.tag_string = tag + user.profile.build_tags + user.profile.save! +end \ No newline at end of file diff --git a/features/tags.feature b/features/tags.feature index cf175b67e..93b118134 100644 --- a/features/tags.feature +++ b/features/tags.feature @@ -1,8 +1,27 @@ @javascript Feature: Interacting with tags - Scenario: Searching for a tag - Given I am signed in + Background: + Given there is a user "Samuel Beckett" who's tagged "#rockstar" + And I am signed in And I am on the homepage - And I search for "#rockstar" - Then I should be on the tag page for "rockstar" \ No newline at end of file + + Scenario: Searching for a tag + When I search for "#rockstar" + Then I should be on the tag page for "rockstar" + And I should see "Samuel Beckett" + + Scenario: adding a contact from a tag page + When I search for "#rockstar" + Then I should see "start sharing" + But I should not see "Pending request" + + When I follow "start sharing" + Then I should see the contact dialog + When I add the person to my first aspect + And I follow "done editing" + Then I should not see the contact dialog + + When I search for "#rockstar" + Then I should not see "start sharing" + But I should see "Pending request" \ No newline at end of file diff --git a/public/stylesheets/sass/sessions.sass b/public/stylesheets/sass/sessions.sass index c785b8396..147023362 100644 --- a/public/stylesheets/sass/sessions.sass +++ b/public/stylesheets/sass/sessions.sass @@ -2,8 +2,6 @@ // licensed under the Affero General Public License version 3 or later. See // the COPYRIGHT file. - - @font-face :font-family 'BrandonGrotesqueLightRegular' :src url('brandongrotesque_light/Brandon_light-webfont.eot') diff --git a/public/stylesheets/sass/tags.sass b/public/stylesheets/sass/tags.sass new file mode 100644 index 000000000..b755f2a08 --- /dev/null +++ b/public/stylesheets/sass/tags.sass @@ -0,0 +1,12 @@ +// Copyright (c) 2010, Diaspora Inc. This file is +// licensed under the Affero General Public License version 3 or later. See +// the COPYRIGHT file. + +.tags_show + .side_stream + .stream_element + .right + :display inline + :font-size 10px + .button + :font-size 10px diff --git a/spec/controllers/tags_controller_spec.rb b/spec/controllers/tags_controller_spec.rb index 93290d0ed..46d8aa965 100644 --- a/spec/controllers/tags_controller_spec.rb +++ b/spec/controllers/tags_controller_spec.rb @@ -7,10 +7,11 @@ require 'spec_helper' describe TagsController do render_views - before do - @user = alice - end describe '#show' do + before do + @user = alice + end + context 'signed in' do before do sign_in :user, @user @@ -21,17 +22,34 @@ describe TagsController do end end - it 'restricts the posts by tag' do - posts = [] - 2.times do - posts << @user.post(:status_message, :text => "#what", :public => true, :to => 'all') + context "not signed in" do + context "when there are people to display" do + before do + @user.profile.tag_string = "#whatevs" + @user.profile.build_tags + @user.profile.save! + get :show, :name => "whatevs" + end + it "succeeds" do + response.should be_success + end + it "assigns the right set of people" do + assigns(:people).should == [@user.person] + end end - 2.times do - @user.post(:status_message, :text => "#hello", :public => true, :to => 'all') + context "when there are posts to display" do + before do + @post = @user.post(:status_message, :text => "#what", :public => true, :to => 'all') + @user.post(:status_message, :text => "#hello", :public => true, :to => 'all') + get :show, :name => 'what' + end + it "succeeds" do + response.should be_success + end + it "assigns the right set of posts" do + assigns[:posts].should == [@post] + end end - - get :show, :name => 'what' - assigns[:posts].should =~ posts end end end diff --git a/spec/support/fixture_builder.rb b/spec/support/fixture_builder.rb index 7e38b90b3..52dbf2945 100644 --- a/spec/support/fixture_builder.rb +++ b/spec/support/fixture_builder.rb @@ -12,10 +12,6 @@ FixtureBuilder.configure do |fbuilder| bob = Factory(:user_with_aspect, :username => "bob") Factory(:aspect, :name => "empty", :user => bob) - alice.profile.tag_string = '#rockstar' - alice.profile.build_tags - alice.profile.save! - connect_users(bob, bob.aspects.first, alice, alice.aspects.first) connect_users(bob, bob.aspects.first, eve, eve.aspects.first) end