From 956a86b4011614955b92b7654880b7aee1e5e75b Mon Sep 17 00:00:00 2001 From: danielgrippi Date: Fri, 1 Jul 2011 09:03:18 -0700 Subject: [PATCH 01/11] publisher rework --- features/follows_tags.feature | 37 +++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 features/follows_tags.feature diff --git a/features/follows_tags.feature b/features/follows_tags.feature new file mode 100644 index 000000000..07e7ae9b3 --- /dev/null +++ b/features/follows_tags.feature @@ -0,0 +1,37 @@ +@javascript +Feature: posting + In order to takeover humanity for the good of society + As a rock star + I want to see what humanity is saying about particular tags + + Background: + Given a user with username "bob" + And a user with username "alice" + When I sign in as "bob@bob.bob" + And I have an aspect called "PostTo" + And I have an aspect called "DidntPostTo" + And I have user with username "alice" in an aspect called "PostTo" + And I have user with username "alice" in an aspect called "DidntPostTo" + + And I am on the home page + + + Scenario: see a tag that I am following + Given I am on the home page + And I expand the publisher + And I fill in "status_message_fake_text" with "I am #bob" + And I press the first ".public_icon" within "#publisher" + And I press "Share" + And I go to the destroy user session page + + And I sign in as "alice@alice.alice" + And I search for "#alice" + And I press "Follow #alice" + And I go to the home page + And I press on "#alice" + Then I should see "I am #alice" + + + + + From 77d28b411706a8590accf8a4b33cfe5c422117d6 Mon Sep 17 00:00:00 2001 From: Ilyaaaaaaaaaaaaa Zhitomirskiy Date: Fri, 1 Jul 2011 13:13:59 -0700 Subject: [PATCH 02/11] wip following tags --- app/views/tags/show.haml | 27 +++++++++++++++++---------- features/follows_tags.feature | 12 +++--------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/app/views/tags/show.haml b/app/views/tags/show.haml index ee681076c..2ff385006 100644 --- a/app/views/tags/show.haml +++ b/app/views/tags/show.haml @@ -18,11 +18,24 @@ - content_for :body_class do = "tags_show" -.span-24.last - %h1.tag - = "##{params[:name]}" +.span-6 + %h3 + = t('people', :count => @people_count) + + .side_stream.stream + = render :partial => 'people/index', :locals => {:people => @people} + +.span-15.last + .stream_container + #author_info + - if user_signed_in? && current_user.person != @person + .right + = button_to "Follow ##{params[:name]}", :class => "button" + %h2 + = "##{params[:name]}" + + %hr -.span-13 #main_stream.stream - if @posts.length > 0 = render 'shared/stream', :posts => @posts @@ -31,9 +44,3 @@ - else = t('.nobody_talking', :tag => "##{params[:name]}") -.prepend-2.span-9.last - %h3 - = t('people', :count => @people_count) - - .side_stream.stream - = render :partial => 'people/index', :locals => {:people => @people} diff --git a/features/follows_tags.feature b/features/follows_tags.feature index 07e7ae9b3..9e95fa482 100644 --- a/features/follows_tags.feature +++ b/features/follows_tags.feature @@ -8,18 +8,12 @@ Feature: posting Given a user with username "bob" And a user with username "alice" When I sign in as "bob@bob.bob" - And I have an aspect called "PostTo" - And I have an aspect called "DidntPostTo" - And I have user with username "alice" in an aspect called "PostTo" - And I have user with username "alice" in an aspect called "DidntPostTo" - And I am on the home page Scenario: see a tag that I am following - Given I am on the home page - And I expand the publisher - And I fill in "status_message_fake_text" with "I am #bob" + Given I expand the publisher + And I fill in "status_message_fake_text" with "I am ALICE" And I press the first ".public_icon" within "#publisher" And I press "Share" And I go to the destroy user session page @@ -28,7 +22,7 @@ Feature: posting And I search for "#alice" And I press "Follow #alice" And I go to the home page - And I press on "#alice" + And I press "#alice" Then I should see "I am #alice" From 1e4ee472b70ca0899795c3582f79b796dc8f1c20 Mon Sep 17 00:00:00 2001 From: Ilyaaaaaaaaaaaaa Zhitomirskiy Date: Fri, 1 Jul 2011 22:32:23 -0700 Subject: [PATCH 03/11] WIP you can now follow a tag, needs a clean up, and ajax love --- app/controllers/aspects_controller.rb | 21 ++++- app/controllers/tag_followings_controller.rb | 31 ++++++++ app/controllers/tags_controller.rb | 4 + app/helpers/tag_followings_helper.rb | 2 + app/models/tag_following.rb | 6 ++ app/models/user.rb | 1 + app/views/aspect_memberships/create.js.erb | 14 +--- app/views/aspects/index.html.haml | 9 +++ app/views/tags/show.haml | 19 +++-- config/locales/diaspora/en.yml | 3 + config/routes.rb | 4 + .../20110701215925_create_tag_followings.rb | 14 ++++ db/schema.rb | 7 ++ features/follows_tags.feature | 37 ++++++--- spec/controllers/aspects_controller_spec.rb | 62 +++++++++++++++ .../tag_followings_controller_spec.rb | 76 +++++++++++++++++++ spec/controllers/tags_controller_spec.rb | 21 ++++- spec/models/tag_following_spec.rb | 16 ++++ 18 files changed, 314 insertions(+), 33 deletions(-) create mode 100644 app/controllers/tag_followings_controller.rb create mode 100644 app/helpers/tag_followings_helper.rb create mode 100644 app/models/tag_following.rb create mode 100644 db/migrate/20110701215925_create_tag_followings.rb create mode 100644 spec/controllers/tag_followings_controller_spec.rb create mode 100644 spec/models/tag_following_spec.rb diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index ec8af115d..7264d87d0 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -9,6 +9,9 @@ class AspectsController < ApplicationController respond_to :html, :js respond_to :json, :only => [:show, :create] + + helper_method :tags, :tag_followings + helper_method :all_aspects_selected? def index if params[:a_ids] @@ -158,11 +161,27 @@ class AspectsController < ApplicationController params[:max_time] ||= Time.now + 1 end - helper_method :all_aspects_selected? def all_aspects_selected? @aspect == :all end + def tag_followings + if current_user + if @tag_followings == nil + @tag_followings = current_user.tag_followings + end + @tag_followings + end + end + + def tags + if tag_followings != [] && @tags != [] + @tags ||= ActsAsTaggableOn::Tag.where(:id => tag_followings.map(&:id)).all + else + @tags ||= [] + end + end + private def save_sort_order if params[:sort_order].present? diff --git a/app/controllers/tag_followings_controller.rb b/app/controllers/tag_followings_controller.rb new file mode 100644 index 000000000..d8584ce54 --- /dev/null +++ b/app/controllers/tag_followings_controller.rb @@ -0,0 +1,31 @@ +class TagFollowingsController < ApplicationController + before_filter :authenticate_user! + + # POST /tag_followings + # POST /tag_followings.xml + def create + @tag = ActsAsTaggableOn::Tag.find_or_create_by_name(params[:name]) + @tag_following = current_user.tag_followings.new(:tag_id => @tag_id) + + respond_to do |format| + if @tag_following.save + format.html { redirect_to(tag_path(:name => params[:name]), :notice => "Successfully following: #{params[:name]}" ) } + format.xml { render :xml => @tag_following, :status => :created, :location => @tag_following } + else + render :nothing => true, :status => :unprocessable_entity + end + end + end + + # DELETE /tag_followings/1 + # DELETE /tag_followings/1.xml + def destroy + @tag = ActsAsTaggableOn::Tag.find_by_name(params[:name]) + @tag_following = current_user.tag_followings.where(:tag_id => @tag.id).first + if @tag_following && @tag_following.destroy + render :nothing => true, :status => 200 + else + render :nothing => true, :status => 410 + end + end +end diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index 145914856..d8b31df5f 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -69,4 +69,8 @@ class TagsController < ApplicationController @people_count = Person.where(:id => profiles.map{|p| p.person_id}).count end end + +# def tag_following? +# TagFollowings.join(:tags) +# end end diff --git a/app/helpers/tag_followings_helper.rb b/app/helpers/tag_followings_helper.rb new file mode 100644 index 000000000..03bd57800 --- /dev/null +++ b/app/helpers/tag_followings_helper.rb @@ -0,0 +1,2 @@ +module TagFollowingsHelper +end diff --git a/app/models/tag_following.rb b/app/models/tag_following.rb new file mode 100644 index 000000000..6fd07c0ef --- /dev/null +++ b/app/models/tag_following.rb @@ -0,0 +1,6 @@ +class TagFollowing < ActiveRecord::Base + belongs_to :user + belongs_to :tag, :class_name => "ActsAsTaggableOn::Tag" + + validates_uniqueness_of :tag_id, :scope => :user_id +end diff --git a/app/models/user.rb b/app/models/user.rb index 0bab1c58e..7450ee427 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -39,6 +39,7 @@ class User < ActiveRecord::Base has_many :contact_people, :through => :contacts, :source => :person has_many :services, :dependent => :destroy has_many :user_preferences, :dependent => :destroy + has_many :tag_followings, :dependent => :destroy has_many :authorizations, :class_name => 'OAuth2::Provider::Models::ActiveRecord::Authorization', :foreign_key => :resource_owner_id has_many :applications, :through => :authorizations, :source => :client diff --git a/app/views/aspect_memberships/create.js.erb b/app/views/aspect_memberships/create.js.erb index 595304cf6..f70e7cc7c 100644 --- a/app/views/aspect_memberships/create.js.erb +++ b/app/views/aspect_memberships/create.js.erb @@ -4,19 +4,9 @@ ContactEdit.updateNumber("<%= @contact.person_id%>"); -var element = $(".add[data-aspect_id=<%= @aspect.id %>][data-person_id=<%= @contact.person_id%>]"); +var element = $(".stream_container"); -if( $("#no_contacts").is(':visible') ) { - $("#no_contacts").fadeOut(200); -} - -$(".badges").prepend("<%= escape_javascript( aspect_badge(@aspect).html_safe ) %>"); -element.parent().html("<%= escape_javascript(render('aspect_memberships/add_to_aspect', :aspect_id => @aspect.id, :person_id => @person.id)) %>"); - -if($('#aspects_list').length == 1) { - $('.aspect_list').attr('data-contact_id', "<%= @contact_id %>"); - $('.aspect_list ul').find('.add').each(function(a,b){$(b).attr('href', $(b).attr('href').replace('contacts','aspect_memberships'));}) -}; +element.html("<%= escape_javascript(render('aspect_memberships/add_to_aspect', :aspect_id => @aspect.id, :person_id => @person.id)) %>"); element.fadeTo(200,1); diff --git a/app/views/aspects/index.html.haml b/app/views/aspects/index.html.haml index 26824860d..d06ed3dee 100644 --- a/app/views/aspects/index.html.haml +++ b/app/views/aspects/index.html.haml @@ -15,6 +15,15 @@ .section = render 'aspects/aspect_listings' + %ul.left_nav + %li + = t('aspects.index.tags_following') + + %ul.sub_nav + - for tg in tags + %li + = link_to "##{tg.name}", tag_path(:name => tg.name) + .span-13.append-1.prepend-5 #aspect_stream_container.stream_container = render 'aspect_stream', diff --git a/app/views/tags/show.haml b/app/views/tags/show.haml index 2ff385006..f164ba59f 100644 --- a/app/views/tags/show.haml +++ b/app/views/tags/show.haml @@ -30,17 +30,20 @@ #author_info - if user_signed_in? && current_user.person != @person .right - = button_to "Follow ##{params[:name]}", :class => "button" + - unless true #tag_followed? + = button_to t('.follow', :tag => params[:name]), tag_tag_followings_path(:name => params[:name]), :method => :post, :class => 'button take_action' + - else + = button_to t('.stop_following', :tag => params[:name]), tag_tag_followings_path(:name => params[:name]), :method => :post, :class => 'button take_action' %h2 = "##{params[:name]}" %hr - #main_stream.stream - - if @posts.length > 0 - = render 'shared/stream', :posts => @posts - #pagination - =link_to(t('more'), next_page_path, :class => 'paginate') - - else - = t('.nobody_talking', :tag => "##{params[:name]}") + #main_stream.stream + - if @posts.length > 0 + = render 'shared/stream', :posts => @posts + #pagination + =link_to(t('more'), next_page_path, :class => 'paginate') + - else + = t('.nobody_talking', :tag => "##{params[:name]}") diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index dd352603b..4dc934cb9 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -146,6 +146,7 @@ en: work: "Work" index: your_aspects: "Your Aspects" + tags_following: "Followed Tags" handle_explanation: "This is your diaspora id. Like an email address, you can give this to people to reach you." no_contacts: "No contacts" post_a_message: "post a message >>" @@ -697,6 +698,8 @@ en: posts_tagged_with: "Posts tagged with #%{tag}" nobody_talking: "Nobody is talking about %{tag} yet." people_tagged_with: "People tagged with %{tag}" + follow: "Follow #%{tag}" + stop_following: "Stop Following #%{tag}" tokens: show: diff --git a/config/routes.rb b/config/routes.rb index 7627953bd..8207f9b3d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,6 +4,7 @@ Diaspora::Application.routes.draw do + # Posting and Reading resources :aspects do @@ -34,6 +35,9 @@ Diaspora::Application.routes.draw do end resources :tags, :only => [:index] + post "/tags/:name/tag_followings" => "tag_followings#create", :as => 'tag_tag_followings' + delete " /tags/:name/tag_followings" => "tag_followings#destroy" + get 'tags/:name' => 'tags#show', :as => 'tag' resources :apps, :only => [:show] diff --git a/db/migrate/20110701215925_create_tag_followings.rb b/db/migrate/20110701215925_create_tag_followings.rb new file mode 100644 index 000000000..c8bb4afbe --- /dev/null +++ b/db/migrate/20110701215925_create_tag_followings.rb @@ -0,0 +1,14 @@ +class CreateTagFollowings < ActiveRecord::Migration + def self.up + create_table :tag_followings do |t| + t.integer :tag_id + t.integer :user_id + + t.timestamps + end + end + + def self.down + drop_table :tag_followings + end +end diff --git a/db/schema.rb b/db/schema.rb index 085facef9..a702f0281 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -326,6 +326,13 @@ ActiveRecord::Schema.define(:version => 20110705003445) do add_index "services", ["user_id"], :name => "index_services_on_user_id" + create_table "tag_followings", :force => true do |t| + t.integer "tag_id" + t.integer "user_id" + t.datetime "created_at" + t.datetime "updated_at" + end + create_table "taggings", :force => true do |t| t.integer "tag_id" t.integer "taggable_id" diff --git a/features/follows_tags.feature b/features/follows_tags.feature index 9e95fa482..de38def37 100644 --- a/features/follows_tags.feature +++ b/features/follows_tags.feature @@ -10,22 +10,37 @@ Feature: posting When I sign in as "bob@bob.bob" And I am on the home page - - Scenario: see a tag that I am following - Given I expand the publisher - And I fill in "status_message_fake_text" with "I am ALICE" + And I expand the publisher + And I fill in "status_message_fake_text" with "I am da #boss" And I press the first ".public_icon" within "#publisher" And I press "Share" + And I wait for the ajax to finish + And I wait for the ajax to finish + + When I go to the home page + Then I should see "I am da #boss" + And I wait for 5 seconds + + And I follow "#boss" + And I wait for the ajax to finish + And I debug + Then I should see "I am da #boss" + + And I go to the destroy user session page And I sign in as "alice@alice.alice" - And I search for "#alice" - And I press "Follow #alice" - And I go to the home page - And I press "#alice" - Then I should see "I am #alice" - - + And I search for "#boss" + And I press "Follow #boss" + And I wait for the ajax to finish + + Scenario: see a tag that I am following + When I go to the home page + And I follow "#boss" + Then I should see "I am da #boss" + + Scenario: see that I'm following a particular tag + Then I should see "Following #boss" diff --git a/spec/controllers/aspects_controller_spec.rb b/spec/controllers/aspects_controller_spec.rb index 029c7ff08..5b51d8880 100644 --- a/spec/controllers/aspects_controller_spec.rb +++ b/spec/controllers/aspects_controller_spec.rb @@ -331,4 +331,66 @@ describe AspectsController do @alices_aspect_1.reload.contacts_visible.should be_false end end + + context 'helper methods' do + before do + @tag = ActsAsTaggableOn::Tag.create!(:name => "partytimeexcellent") + TagFollowing.create!(:tag => @tag, :user => bob ) + end + + describe 'tag_followings' do + it 'does nothing if no-one is signed in' do + @controller.stub!(:current_user).and_return(nil) + @controller.tag_followings.should be_nil + end + + it 'queries current_users tag_followings' do + alice.should_receive(:tag_followings).once.and_return([42]) + + @controller.stub(:current_user).and_return(alice) + @controller.tag_followings.should == [42] + end + + it 'does not query twice' do + alice.should_receive(:tag_followings).once.and_return([42]) + @controller.stub(:current_user).and_return(alice) + + @controller.tag_followings.should == [42] + @controller.tag_followings.should == [42] + end + end + + describe 'tags' do + it 'does nothing there are no tag_followings' do + @controller.stub!(:tag_followings).and_return([]) + @controller.tags.should == [] + end + + context "querying" do + before do + @ids = [1,2,3] + @tag_followings = @ids.map do |n| + tf = mock() + tf.should_receive(:id).and_return(n) + tf + end + + query = mock + query.should_receive(:all).and_return([42]) + + ActsAsTaggableOn::Tag.should_receive(:where).with(:id => @ids).once.and_return(query) + @controller.stub(:tag_followings).and_return(@tag_followings) + end + + it 'queries current_users tag if there are tag_followings' do + @controller.tags.should == [42] + end + + it 'does not query twice' do + @controller.tags.should == [42] + @controller.tags.should == [42] + end + end + end + end end diff --git a/spec/controllers/tag_followings_controller_spec.rb b/spec/controllers/tag_followings_controller_spec.rb new file mode 100644 index 000000000..2acae2a69 --- /dev/null +++ b/spec/controllers/tag_followings_controller_spec.rb @@ -0,0 +1,76 @@ +# Copyright (c) 2010, Diaspora Inc. This file is +# licensed under the Affero General Public License version 3 or later. See +# the COPYRIGHT file. + +require 'spec_helper' + +describe TagFollowingsController do + + def valid_attributes + {:name => "partytimeexcellent"} + end + + before do + @tag = ActsAsTaggableOn::Tag.create!(:name => "partytimeexcellent") + sign_in :user, bob + end + + describe "POST create" do + describe "with valid params" do + it "creates a new TagFollowing" do + expect { + post :create, valid_attributes + }.to change(TagFollowing, :count).by(1) + end + + it "assigns a newly created tag_following as @tag_following" do + post :create, valid_attributes + assigns(:tag_following).should be_a(TagFollowing) + assigns(:tag_following).should be_persisted + end + + it 'creates the tag if it does not already exist' do + expect { + post :create, :name => "tomcruisecontrol" + }.to change(ActsAsTaggableOn::Tag, :count).by(1) + end + + it 'does not create the tag following for non signed in user' do + expect { + post :create, valid_attributes.merge(:user_id => alice.id) + }.to_not change(alice.tag_followings, :count).by(1) + end + + it "redirects to the tag page" do + post :create, valid_attributes + response.should redirect_to(tag_path(:name => valid_attributes[:name])) + end + + it "returns a 406 if you already have a tag" do + TagFollowing.any_instance.stub(:save).and_return(false) + post :create, valid_attributes + response.code.should == "406" + end + end + end + + describe "DELETE destroy" do + before do + TagFollowing.create!(:tag => @tag, :user => bob ) + TagFollowing.create!(:tag => @tag, :user => alice ) + end + + it "destroys the requested tag_following" do + expect { + delete :destroy, valid_attributes + }.to change(TagFollowing, :count).by(-1) + end + + it "returns a 410 if you already have a tag" do + TagFollowing.any_instance.stub(:destroy).and_return(false) + delete :destroy, valid_attributes + response.code.should == "410" + end + end + +end diff --git a/spec/controllers/tags_controller_spec.rb b/spec/controllers/tags_controller_spec.rb index 492d66897..192d6f9bc 100644 --- a/spec/controllers/tags_controller_spec.rb +++ b/spec/controllers/tags_controller_spec.rb @@ -106,4 +106,23 @@ describe TagsController do end end end -end \ No newline at end of file + + context 'helper methods' do + describe 'tag_followed?' do + before do + sign_in alice + @tag = ActsAsTaggableOn::Tag.create!(:name => "partytimeexcellent") + @controller.stub(:current_user).and_return(bob) + end + + it 'returns true if the following already exists' do + TagFollowing.create!(:tag => @tag, :user => bob ) + @controller.tag_following?.should be_true + end + + it 'returns false if the following does not already exist' do + @controller.tag_following?.should be_false + end + end + end +end diff --git a/spec/models/tag_following_spec.rb b/spec/models/tag_following_spec.rb new file mode 100644 index 000000000..3b1614dfa --- /dev/null +++ b/spec/models/tag_following_spec.rb @@ -0,0 +1,16 @@ +require 'spec_helper' + +describe TagFollowing do + before do + @tag = ActsAsTaggableOn::Tag.create(:name => "partytimeexcellent") + TagFollowing.create!(:tag => @tag, :user => alice) + end + + it 'validates uniqueness of tag_following scoped through user' do + TagFollowing.new(:tag => @tag, :user => alice).valid?.should be_false + end + + it 'allows multiple tag followings for different users' do + TagFollowing.new(:tag => @tag, :user => bob).valid?.should be_true + end +end From 632eacc51f8f51769ffc555422ca7a0d5c6a802e Mon Sep 17 00:00:00 2001 From: danielgrippi Date: Sun, 3 Jul 2011 21:54:25 -0700 Subject: [PATCH 04/11] css fix on followed tags nav --- app/views/aspects/index.html.haml | 6 ++++-- public/stylesheets/sass/application.sass | 15 ++++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/app/views/aspects/index.html.haml b/app/views/aspects/index.html.haml index d06ed3dee..955be3176 100644 --- a/app/views/aspects/index.html.haml +++ b/app/views/aspects/index.html.haml @@ -15,14 +15,16 @@ .section = render 'aspects/aspect_listings' + .section %ul.left_nav %li - = t('aspects.index.tags_following') + %div.root_element + = t('aspects.index.tags_following') %ul.sub_nav - for tg in tags %li - = link_to "##{tg.name}", tag_path(:name => tg.name) + = link_to "##{tg.name}", tag_path(:name => tg.name), :class => "tag_selector" .span-13.append-1.prepend-5 #aspect_stream_container.stream_container diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 8077519ca..a555a3eaf 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -2786,6 +2786,7 @@ ul#requested-scopes ul.left_nav :margin 0 + :bottom 20px :padding 0 li @@ -2793,11 +2794,16 @@ ul.left_nav :width 100% a.aspect_selector, - a.home_selector + a.home_selector, + a.tag_selector, + .root_element :display block :width 100% :padding 3px 7px + a.aspect_selector, + a.home_selector, + a.tag_selector &:hover @include border-radius(2px) @@ -2841,8 +2847,10 @@ ul.left_nav :margin 0 li :width 155px + a.aspect_selector, - a.new_aspect + a.new_aspect, + a.tag_selector :padding :left 15px :width 182px @@ -2862,7 +2870,8 @@ ul.left_nav :width 140px a.aspect_selector, - a.new_aspect + a.new_aspect, + a.tag_selector :width 140px li:hover From f0d9d318e8462e1869e65ff4d6425d3a6ba7aa06 Mon Sep 17 00:00:00 2001 From: Ilyaaaaaaaaaaaaa Zhitomirskiy Date: Mon, 4 Jul 2011 00:20:05 -0700 Subject: [PATCH 05/11] a user can now follow and unfollow a tag --- app/controllers/aspects_controller.rb | 6 +-- app/controllers/tag_followings_controller.rb | 15 +++--- app/controllers/tags_controller.rb | 12 +++-- app/models/user.rb | 1 + app/views/tags/show.haml | 4 +- config/routes.rb | 2 +- features/follows_tags.feature | 8 +-- spec/controllers/aspects_controller_spec.rb | 57 +++----------------- spec/controllers/tags_controller_spec.rb | 7 +-- 9 files changed, 35 insertions(+), 77 deletions(-) diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index 7264d87d0..c47257a16 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -175,11 +175,7 @@ class AspectsController < ApplicationController end def tags - if tag_followings != [] && @tags != [] - @tags ||= ActsAsTaggableOn::Tag.where(:id => tag_followings.map(&:id)).all - else - @tags ||= [] - end + @tags ||= current_user.followed_tags end private diff --git a/app/controllers/tag_followings_controller.rb b/app/controllers/tag_followings_controller.rb index d8584ce54..f26c06442 100644 --- a/app/controllers/tag_followings_controller.rb +++ b/app/controllers/tag_followings_controller.rb @@ -5,15 +5,12 @@ class TagFollowingsController < ApplicationController # POST /tag_followings.xml def create @tag = ActsAsTaggableOn::Tag.find_or_create_by_name(params[:name]) - @tag_following = current_user.tag_followings.new(:tag_id => @tag_id) + @tag_following = current_user.tag_followings.new(:tag_id => @tag.id) - respond_to do |format| - if @tag_following.save - format.html { redirect_to(tag_path(:name => params[:name]), :notice => "Successfully following: #{params[:name]}" ) } - format.xml { render :xml => @tag_following, :status => :created, :location => @tag_following } - else - render :nothing => true, :status => :unprocessable_entity - end + if @tag_following.save + redirect_to(tag_path(:name => params[:name]), :notice => "Successfully following: #{params[:name]}" ) + else + render :nothing => true, :status => 406 end end @@ -23,7 +20,7 @@ class TagFollowingsController < ApplicationController @tag = ActsAsTaggableOn::Tag.find_by_name(params[:name]) @tag_following = current_user.tag_followings.where(:tag_id => @tag.id).first if @tag_following && @tag_following.destroy - render :nothing => true, :status => 200 + redirect_to(tag_path(:name => params[:name]), :notice => "Successfully stopped following: #{params[:name]}" ) else render :nothing => true, :status => 410 end diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index d8b31df5f..d4e6bdf04 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -8,6 +8,8 @@ class TagsController < ApplicationController skip_before_filter :set_grammatical_gender before_filter :ensure_page, :only => :show + helper_method :tag_followed? + respond_to :html, :only => [:show] respond_to :json, :only => [:index] @@ -55,7 +57,6 @@ class TagsController < ApplicationController max_time = params[:max_time] ? Time.at(params[:max_time].to_i) : Time.now @posts = @posts.where(StatusMessage.arel_table[:created_at].lt(max_time)) - @posts = @posts.includes(:comments, :photos).order('posts.created_at DESC').limit(15) @posts = PostsFake.new(@posts) @@ -70,7 +71,10 @@ class TagsController < ApplicationController end end -# def tag_following? -# TagFollowings.join(:tags) -# end + def tag_followed? + if @tf.nil? + @tf = TagFollowing.joins(:tag).where(:tags => {:name => params[:name]}, :user_id => current_user.id).exists? #, + end + @tf + end end diff --git a/app/models/user.rb b/app/models/user.rb index 7450ee427..d93087837 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -40,6 +40,7 @@ class User < ActiveRecord::Base has_many :services, :dependent => :destroy has_many :user_preferences, :dependent => :destroy has_many :tag_followings, :dependent => :destroy + has_many :followed_tags, :through => :tag_followings, :source => :tag has_many :authorizations, :class_name => 'OAuth2::Provider::Models::ActiveRecord::Authorization', :foreign_key => :resource_owner_id has_many :applications, :through => :authorizations, :source => :client diff --git a/app/views/tags/show.haml b/app/views/tags/show.haml index f164ba59f..da714f91b 100644 --- a/app/views/tags/show.haml +++ b/app/views/tags/show.haml @@ -30,10 +30,10 @@ #author_info - if user_signed_in? && current_user.person != @person .right - - unless true #tag_followed? + - unless tag_followed? = button_to t('.follow', :tag => params[:name]), tag_tag_followings_path(:name => params[:name]), :method => :post, :class => 'button take_action' - else - = button_to t('.stop_following', :tag => params[:name]), tag_tag_followings_path(:name => params[:name]), :method => :post, :class => 'button take_action' + = button_to t('.stop_following', :tag => params[:name]), tag_tag_followings_path(:name => params[:name]), :method => :delete, :class => 'button take_action' %h2 = "##{params[:name]}" diff --git a/config/routes.rb b/config/routes.rb index 8207f9b3d..1dd4938fa 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -36,7 +36,7 @@ Diaspora::Application.routes.draw do resources :tags, :only => [:index] post "/tags/:name/tag_followings" => "tag_followings#create", :as => 'tag_tag_followings' - delete " /tags/:name/tag_followings" => "tag_followings#destroy" + delete "/tags/:name/tag_followings" => "tag_followings#destroy" get 'tags/:name' => 'tags#show', :as => 'tag' diff --git a/features/follows_tags.feature b/features/follows_tags.feature index de38def37..f05339b5c 100644 --- a/features/follows_tags.feature +++ b/features/follows_tags.feature @@ -17,13 +17,13 @@ Feature: posting And I wait for the ajax to finish And I wait for the ajax to finish + #the following (3 lines) verbosity should not be needed When I go to the home page Then I should see "I am da #boss" And I wait for 5 seconds And I follow "#boss" And I wait for the ajax to finish - And I debug Then I should see "I am da #boss" @@ -39,8 +39,10 @@ Feature: posting And I follow "#boss" Then I should see "I am da #boss" - Scenario: see that I'm following a particular tag - Then I should see "Following #boss" + Scenario: can stop following a particular tag + Then I should see "Stop Following #boss" + When I go to the home page + And I should not see "#boss" in ".left_nav" diff --git a/spec/controllers/aspects_controller_spec.rb b/spec/controllers/aspects_controller_spec.rb index 5b51d8880..830873738 100644 --- a/spec/controllers/aspects_controller_spec.rb +++ b/spec/controllers/aspects_controller_spec.rb @@ -335,61 +335,18 @@ describe AspectsController do context 'helper methods' do before do @tag = ActsAsTaggableOn::Tag.create!(:name => "partytimeexcellent") - TagFollowing.create!(:tag => @tag, :user => bob ) - end - - describe 'tag_followings' do - it 'does nothing if no-one is signed in' do - @controller.stub!(:current_user).and_return(nil) - @controller.tag_followings.should be_nil - end - - it 'queries current_users tag_followings' do - alice.should_receive(:tag_followings).once.and_return([42]) - - @controller.stub(:current_user).and_return(alice) - @controller.tag_followings.should == [42] - end - - it 'does not query twice' do - alice.should_receive(:tag_followings).once.and_return([42]) - @controller.stub(:current_user).and_return(alice) - - @controller.tag_followings.should == [42] - @controller.tag_followings.should == [42] - end + TagFollowing.create!(:tag => @tag, :user => alice ) + alice.should_receive(:followed_tags).once.and_return([42]) end describe 'tags' do - it 'does nothing there are no tag_followings' do - @controller.stub!(:tag_followings).and_return([]) - @controller.tags.should == [] + it 'queries current_users tag if there are tag_followings' do + @controller.tags.should == [42] end - context "querying" do - before do - @ids = [1,2,3] - @tag_followings = @ids.map do |n| - tf = mock() - tf.should_receive(:id).and_return(n) - tf - end - - query = mock - query.should_receive(:all).and_return([42]) - - ActsAsTaggableOn::Tag.should_receive(:where).with(:id => @ids).once.and_return(query) - @controller.stub(:tag_followings).and_return(@tag_followings) - end - - it 'queries current_users tag if there are tag_followings' do - @controller.tags.should == [42] - end - - it 'does not query twice' do - @controller.tags.should == [42] - @controller.tags.should == [42] - end + it 'does not query twice' do + @controller.tags.should == [42] + @controller.tags.should == [42] end end end diff --git a/spec/controllers/tags_controller_spec.rb b/spec/controllers/tags_controller_spec.rb index 192d6f9bc..0754db63c 100644 --- a/spec/controllers/tags_controller_spec.rb +++ b/spec/controllers/tags_controller_spec.rb @@ -110,18 +110,19 @@ describe TagsController do context 'helper methods' do describe 'tag_followed?' do before do - sign_in alice + sign_in bob @tag = ActsAsTaggableOn::Tag.create!(:name => "partytimeexcellent") @controller.stub(:current_user).and_return(bob) + @controller.stub(:params).and_return({:name => "partytimeexcellent"}) end it 'returns true if the following already exists' do TagFollowing.create!(:tag => @tag, :user => bob ) - @controller.tag_following?.should be_true + @controller.tag_followed?.should be_true end it 'returns false if the following does not already exist' do - @controller.tag_following?.should be_false + @controller.tag_followed?.should be_false end end end From d15673c3de02370585a27e9b4cc5fd144d8c0f8a Mon Sep 17 00:00:00 2001 From: Ilyaaaaaaaaaaaaa Zhitomirskiy Date: Mon, 4 Jul 2011 14:54:56 -0700 Subject: [PATCH 06/11] changed the variable name --- app/controllers/tags_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index d4e6bdf04..8878460be 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -72,9 +72,9 @@ class TagsController < ApplicationController end def tag_followed? - if @tf.nil? - @tf = TagFollowing.joins(:tag).where(:tags => {:name => params[:name]}, :user_id => current_user.id).exists? #, + if @tag_followed.nil? + @tag_followed = TagFollowing.joins(:tag).where(:tags => {:name => params[:name]}, :user_id => current_user.id).exists? #, end - @tf + @tag_followed end end From edac7601f57a262ed58d03f71b06ade8ac11e114 Mon Sep 17 00:00:00 2001 From: Ilyaaaaaaaaaaaaa Zhitomirskiy Date: Mon, 4 Jul 2011 15:25:53 -0700 Subject: [PATCH 07/11] checkedout the create.js from master --- app/views/aspect_memberships/create.js.erb | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/views/aspect_memberships/create.js.erb b/app/views/aspect_memberships/create.js.erb index f70e7cc7c..595304cf6 100644 --- a/app/views/aspect_memberships/create.js.erb +++ b/app/views/aspect_memberships/create.js.erb @@ -4,9 +4,19 @@ ContactEdit.updateNumber("<%= @contact.person_id%>"); -var element = $(".stream_container"); +var element = $(".add[data-aspect_id=<%= @aspect.id %>][data-person_id=<%= @contact.person_id%>]"); -element.html("<%= escape_javascript(render('aspect_memberships/add_to_aspect', :aspect_id => @aspect.id, :person_id => @person.id)) %>"); +if( $("#no_contacts").is(':visible') ) { + $("#no_contacts").fadeOut(200); +} + +$(".badges").prepend("<%= escape_javascript( aspect_badge(@aspect).html_safe ) %>"); +element.parent().html("<%= escape_javascript(render('aspect_memberships/add_to_aspect', :aspect_id => @aspect.id, :person_id => @person.id)) %>"); + +if($('#aspects_list').length == 1) { + $('.aspect_list').attr('data-contact_id', "<%= @contact_id %>"); + $('.aspect_list ul').find('.add').each(function(a,b){$(b).attr('href', $(b).attr('href').replace('contacts','aspect_memberships'));}) +}; element.fadeTo(200,1); From 2d8b5bd54c6f08fa4d2fee060f2d0ac44974b9f1 Mon Sep 17 00:00:00 2001 From: Ilyaaaaaaaaaaaaa Zhitomirskiy Date: Mon, 4 Jul 2011 16:39:28 -0700 Subject: [PATCH 08/11] refactored the controller, moved flash message into translations --- app/controllers/tag_followings_controller.rb | 12 ++++++---- config/locales/diaspora/en.yml | 8 +++++++ .../tag_followings_controller_spec.rb | 23 +++++++++++++++---- 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/app/controllers/tag_followings_controller.rb b/app/controllers/tag_followings_controller.rb index f26c06442..2883f501d 100644 --- a/app/controllers/tag_followings_controller.rb +++ b/app/controllers/tag_followings_controller.rb @@ -8,10 +8,12 @@ class TagFollowingsController < ApplicationController @tag_following = current_user.tag_followings.new(:tag_id => @tag.id) if @tag_following.save - redirect_to(tag_path(:name => params[:name]), :notice => "Successfully following: #{params[:name]}" ) + flash[:notice] = I18n.t('tag_followings.create.success', :name => params[:name]) else - render :nothing => true, :status => 406 + flash[:error] = I18n.t('tag_followings.create.failure', :name => params[:name]) end + + redirect_to tag_path(:name => params[:name]) end # DELETE /tag_followings/1 @@ -20,9 +22,11 @@ class TagFollowingsController < ApplicationController @tag = ActsAsTaggableOn::Tag.find_by_name(params[:name]) @tag_following = current_user.tag_followings.where(:tag_id => @tag.id).first if @tag_following && @tag_following.destroy - redirect_to(tag_path(:name => params[:name]), :notice => "Successfully stopped following: #{params[:name]}" ) + flash[:notice] = I18n.t('tag_followings.destroy.success', :name => params[:name]) else - render :nothing => true, :status => 410 + flash[:error] = I18n.t('tag_followings.destroy.failure', :name => params[:name]) end + + redirect_to tag_path(:name => params[:name]) end end diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index 4dc934cb9..208ea5dfa 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -701,6 +701,14 @@ en: follow: "Follow #%{tag}" stop_following: "Stop Following #%{tag}" + tag_followings: + create: + success: "Successfully following: #%{name}" + failure: "Failed to follow: #%{name}" + destroy: + success: "Successfully stopped following: #%{name}" + failure: "Failed to stop following: #%{name}" + tokens: show: connect_to_cubbies: "Connect to Cubbi.es" diff --git a/spec/controllers/tag_followings_controller_spec.rb b/spec/controllers/tag_followings_controller_spec.rb index 2acae2a69..60dfb6bdc 100644 --- a/spec/controllers/tag_followings_controller_spec.rb +++ b/spec/controllers/tag_followings_controller_spec.rb @@ -41,15 +41,19 @@ describe TagFollowingsController do }.to_not change(alice.tag_followings, :count).by(1) end - it "redirects to the tag page" do + it "redirects and flashes success to the tag page" do post :create, valid_attributes + response.should redirect_to(tag_path(:name => valid_attributes[:name])) + flash[:notice].should == "Successfully following: ##{valid_attributes[:name]}" end - it "returns a 406 if you already have a tag" do + it "redirects and flashes error if you already have a tag" do TagFollowing.any_instance.stub(:save).and_return(false) post :create, valid_attributes - response.code.should == "406" + + response.should redirect_to(tag_path(:name => valid_attributes[:name])) + flash[:error].should == "Failed to follow: ##{valid_attributes[:name]}" end end end @@ -66,10 +70,19 @@ describe TagFollowingsController do }.to change(TagFollowing, :count).by(-1) end - it "returns a 410 if you already have a tag" do + it "redirects and flashes error if you already don't follow the tag" do + delete :destroy, valid_attributes + + response.should redirect_to(tag_path(:name => valid_attributes[:name])) + flash[:notice].should == "Successfully stopped following: ##{valid_attributes[:name]}" + end + + it "redirects and flashes error if you already don't follow the tag" do TagFollowing.any_instance.stub(:destroy).and_return(false) delete :destroy, valid_attributes - response.code.should == "410" + + response.should redirect_to(tag_path(:name => valid_attributes[:name])) + flash[:error].should == "Failed to stop following: ##{valid_attributes[:name]}" end end From 027f096ca7be7dc8c1e6829766a593681cb6169e Mon Sep 17 00:00:00 2001 From: Ilyaaaaaaaaaaaaa Zhitomirskiy Date: Tue, 5 Jul 2011 12:08:03 -0700 Subject: [PATCH 09/11] turns out for the join in the controller to work the current user needs to have contacts to whom they went to, added a spec --- features/follows_tags.feature | 9 ++++++--- spec/controllers/tags_controller_spec.rb | 7 +++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/features/follows_tags.feature b/features/follows_tags.feature index f05339b5c..ccacb623a 100644 --- a/features/follows_tags.feature +++ b/features/follows_tags.feature @@ -8,6 +8,8 @@ Feature: posting Given a user with username "bob" And a user with username "alice" When I sign in as "bob@bob.bob" + + And a user with username "bob" is connected with "alice" And I am on the home page And I expand the publisher @@ -40,9 +42,10 @@ Feature: posting Then I should see "I am da #boss" Scenario: can stop following a particular tag - Then I should see "Stop Following #boss" - When I go to the home page - And I should not see "#boss" in ".left_nav" + When I press "Stop Following #boss" + + And I go to the home page + Then I should not see "#boss" within ".left_nav" diff --git a/spec/controllers/tags_controller_spec.rb b/spec/controllers/tags_controller_spec.rb index 0754db63c..34d892e5f 100644 --- a/spec/controllers/tags_controller_spec.rb +++ b/spec/controllers/tags_controller_spec.rb @@ -62,6 +62,13 @@ describe TagsController do assigns(:posts).models.should == [other_post] response.status.should == 200 end + + it 'displays a public post that was sent to no one' do + stranger = Factory(:user_with_aspect) + stranger_post = stranger.post(:status_message, :text => "#hello", :public => true, :to => 'all') + get :show, :name => 'hello' + assigns(:posts).models.should == [stranger_post] + end end context "not signed in" do From 0ab961e09637895d2ceb648511c0ef27339f21d5 Mon Sep 17 00:00:00 2001 From: Ilyaaaaaaaaaaaaa Zhitomirskiy Date: Tue, 5 Jul 2011 12:19:41 -0700 Subject: [PATCH 10/11] tags controller fixed --- app/controllers/tags_controller.rb | 6 ++++-- features/follows_tags.feature | 6 ------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index 8878460be..fe9e18e1f 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -43,8 +43,10 @@ class TagsController < ApplicationController def show @aspect = :tag if current_user - @posts = StatusMessage.joins(:contacts).where(:pending => false).where( - Contact.arel_table[:user_id].eq(current_user.id).or( + @posts = StatusMessage. + joins("LEFT OUTER JOIN post_visibilities ON post_visibilities.post_id = posts.id"). + joins("LEFT OUTER JOIN contacts ON contacts.id = post_visibilities.contact_id"). + where(Contact.arel_table[:user_id].eq(current_user.id).or( StatusMessage.arel_table[:public].eq(true).or( StatusMessage.arel_table[:author_id].eq(current_user.person.id) ) diff --git a/features/follows_tags.feature b/features/follows_tags.feature index ccacb623a..6271ffed2 100644 --- a/features/follows_tags.feature +++ b/features/follows_tags.feature @@ -9,7 +9,6 @@ Feature: posting And a user with username "alice" When I sign in as "bob@bob.bob" - And a user with username "bob" is connected with "alice" And I am on the home page And I expand the publisher @@ -19,11 +18,6 @@ Feature: posting And I wait for the ajax to finish And I wait for the ajax to finish - #the following (3 lines) verbosity should not be needed - When I go to the home page - Then I should see "I am da #boss" - And I wait for 5 seconds - And I follow "#boss" And I wait for the ajax to finish Then I should see "I am da #boss" From c3e477f2c5554d5476d1efaacdcf17f39368f544 Mon Sep 17 00:00:00 2001 From: Ilyaaaaaaaaaaaaa Zhitomirskiy Date: Tue, 5 Jul 2011 15:02:52 -0700 Subject: [PATCH 11/11] Color the follow tag button --- app/views/tags/show.haml | 18 ++++++++++++++---- config/locales/diaspora/en.yml | 1 + features/signs_up.feature | 3 +-- features/step_definitions/custom_web_steps.rb | 11 +---------- public/stylesheets/sass/ui.sass | 6 ++++++ 5 files changed, 23 insertions(+), 16 deletions(-) diff --git a/app/views/tags/show.haml b/app/views/tags/show.haml index da714f91b..7fe40c9bb 100644 --- a/app/views/tags/show.haml +++ b/app/views/tags/show.haml @@ -2,6 +2,7 @@ -# 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]}" @@ -11,10 +12,19 @@ - content_for :head do = include_javascripts :home :javascript - $(".people_stream .pagination a").live("click", function() { - $.getScript(this.href); - return false; + $(document).ready(function(){ + $(".button.tag_following").hover(function(){ + $this = $(this); + $this.removeClass("in_aspects"); + $this.val("#{t('.stop_following', :tag => params[:name])}"); + }, + function(){ + $this = $(this); + $this.addClass("in_aspects"); + $this.val("#{t('.following', :tag => params[:name])}"); + }); }); + - content_for :body_class do = "tags_show" @@ -33,7 +43,7 @@ - unless tag_followed? = button_to t('.follow', :tag => params[:name]), tag_tag_followings_path(:name => params[:name]), :method => :post, :class => 'button take_action' - else - = button_to t('.stop_following', :tag => params[:name]), tag_tag_followings_path(:name => params[:name]), :method => :delete, :class => 'button take_action' + = button_to t('.following', :tag => params[:name]), tag_tag_followings_path(:name => params[:name]), :method => :delete, :class => 'button red_on_hover tag_following in_aspects take_action' %h2 = "##{params[:name]}" diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index 208ea5dfa..b8a609eb0 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -699,6 +699,7 @@ en: nobody_talking: "Nobody is talking about %{tag} yet." people_tagged_with: "People tagged with %{tag}" follow: "Follow #%{tag}" + following: "Following #%{tag}" stop_following: "Stop Following #%{tag}" tag_followings: diff --git a/features/signs_up.feature b/features/signs_up.feature index 1796cc531..566b6ebfd 100644 --- a/features/signs_up.feature +++ b/features/signs_up.feature @@ -16,7 +16,7 @@ Feature: new user registration And I fill in "profile_last_name" with "Hai" And I fill in "tags" with "#tags" And I press "Save and continue" - And I wait for "step 2" to load + And I wait for the ajax to finish Then I should see "Profile updated" And I should see "Would you like to find your Facebook friends on Diaspora?" And I follow "Skip" @@ -31,5 +31,4 @@ Feature: new user registration Scenario: new user skips the setup wizard When I follow "skip getting started" - And I wait for "the aspects page" to load Then I should be on the aspects page diff --git a/features/step_definitions/custom_web_steps.rb b/features/step_definitions/custom_web_steps.rb index c61534ed3..cb8548963 100644 --- a/features/step_definitions/custom_web_steps.rb +++ b/features/step_definitions/custom_web_steps.rb @@ -129,15 +129,6 @@ When /^I click ok in the confirm dialog to appear next$/ do JS end -When /^I wait for "([^\"]*)" to load$/ do |page_name| - wait_until(10) do - uri = URI.parse(current_url) - current_location = uri.path - current_location << "?#{uri.query}" unless uri.query.blank? - current_location == path_to(page_name) - end -end - Then /^I should get download alert$/ do page.evaluate_script("window.alert = function() { return true; }") end @@ -183,7 +174,7 @@ And /^I scroll down$/ do wait_until(10) { evaluate_script('$("#infscr-loading:visible").length') == 0 } end -When /^I wait for (\d+) seconds$/ do |seconds| +When /^I wait for (\d+) seconds?$/ do |seconds| sleep seconds.to_i end diff --git a/public/stylesheets/sass/ui.sass b/public/stylesheets/sass/ui.sass index 3f27cb274..4a34b1ae4 100644 --- a/public/stylesheets/sass/ui.sass +++ b/public/stylesheets/sass/ui.sass @@ -11,6 +11,7 @@ @include border-radius(2px) @include linear-gradient(rgb(248,250,250),rgb(228,223,223)) @include box-shadow(0,1px,1px,#cfcfcf) + @include transition(width, 3s) :font :style normal @@ -82,6 +83,11 @@ &:hover @include linear-gradient(lighten($creation-blue,3%), darken($creation-blue, 8%)) +.button.red_on_hover + &:hover + @include linear-gradient(desaturate(lighten($red, 20%),20%), desaturate(lighten($red,14%),20%)) + :color black + .right :position absolute :right 0