From ab0ad630dfb9adcca3a7a4fa46a5d3650e2c211a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonne=20Ha=C3=9F?= <me@mrzyx.de> Date: Wed, 12 Sep 2012 05:48:12 +0200 Subject: [PATCH] strip last beta leftovers and fix syntax errors, travis is kinda down, lets hope nothing breaks while I sleep --- .../javascripts/app/forms/picture_form.js | 9 - app/controllers/application_controller.rb | 5 - app/controllers/home_controller.rb | 3 +- app/controllers/people_controller.rb | 4 - app/controllers/posts_controller.rb | 1 - app/controllers/status_messages_controller.rb | 5 +- app/controllers/streams_controller.rb | 1 - app/helpers/application_helper.rb | 15 +- app/models/feature_flagger.rb | 17 -- app/models/invitation_code.rb | 3 +- app/models/profile.rb | 2 - app/models/role.rb | 10 +- app/models/user.rb | 9 - app/views/aspects/_aspect_stream.haml | 10 +- app/views/layouts/main_stream.html.haml | 2 +- config/routes.rb | 3 - .../new_hotness/new_stream_steps.rb | 23 --- .../new_hotness/new_user_steps.rb | 19 -- .../new_hotness/trumpeter_steps.rb | 187 ------------------ spec/controllers/home_controller_spec.rb | 10 +- spec/controllers/profiles_controller_spec.rb | 22 +-- spec/controllers/users_controller_spec.rb | 5 - spec/models/invitation_code_spec.rb | 10 - spec/models/profile_spec.rb | 3 +- 24 files changed, 14 insertions(+), 364 deletions(-) delete mode 100644 app/models/feature_flagger.rb delete mode 100644 features/step_definitions/new_hotness/new_stream_steps.rb delete mode 100644 features/step_definitions/new_hotness/new_user_steps.rb delete mode 100644 features/step_definitions/new_hotness/trumpeter_steps.rb diff --git a/app/assets/javascripts/app/forms/picture_form.js b/app/assets/javascripts/app/forms/picture_form.js index 6fc4a19bef..76a8d6808f 100644 --- a/app/assets/javascripts/app/forms/picture_form.js +++ b/app/assets/javascripts/app/forms/picture_form.js @@ -57,12 +57,3 @@ app.forms.Picture = app.forms.PictureBase.extend({ }) } }); - -/* wallpaper uploader */ -app.forms.Wallpaper = app.forms.PictureBase.extend({ - templateName : "wallpaper-form", - - uploadSuccess : function(resp) { - $("#profile").css("background-image", "url(" + resp.data.wallpaper + ")") - } -}); \ No newline at end of file diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 9951449b48..d583f0ceb8 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -125,14 +125,9 @@ class ApplicationController < ActionController::Base params[:max_time] ? Time.at(params[:max_time].to_i) : Time.now + 1 end - def flag - @flag ||= FeatureFlagger.new(current_user) - end - private def current_user_redirect_path - return person_path(current_user.person) if current_user.beta? current_user.getting_started? ? getting_started_path : root_path end end diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index efdcc0c83c..b0160353de 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -5,7 +5,8 @@ class HomeController < ApplicationController def show if current_user - flag = FeatureFlagger.new(current_user, current_user.person) + if current_user.admin? + redirect_to person_path(current_user.person) else redirect_to stream_path end diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index a3ec40b351..534be62c12 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -191,10 +191,6 @@ class PeopleController < ApplicationController protected - def flag - @flag ||= FeatureFlagger.new(current_user, @person) - end - def remote_profile_with_no_user_session? @person.try(:remote?) && !user_signed_in? end diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 2f2fe56342..60c151810d 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -25,7 +25,6 @@ class PostsController < ApplicationController end def new - @feature_flag = FeatureFlagger.new(current_user, current_user.person) #I should be a global before filter so @feature_flag is accessible redirect_to "/stream" and return render :text => "", :layout => true end diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb index a1604bb859..512f139017 100644 --- a/app/controllers/status_messages_controller.rb +++ b/app/controllers/status_messages_controller.rb @@ -11,7 +11,7 @@ class StatusMessagesController < ApplicationController :mobile, :json - layout 'blank', :only => [ :bookmarklet, :new_bookmarklet ] + layout 'blank', :only => [ :bookmarklet ] # Called when a user clicks "Mention" on a profile page # @param person_id [Integer] The id of the person to be mentioned @@ -38,9 +38,6 @@ class StatusMessagesController < ApplicationController @aspect_ids = @aspects.map{|x| x.id} end - def new_bookmarklet - end - def create params[:status_message][:aspect_ids] = [*params[:aspect_ids]] normalize_public_flag! diff --git a/app/controllers/streams_controller.rb b/app/controllers/streams_controller.rb index 7a4dcb0b61..a28f477159 100644 --- a/app/controllers/streams_controller.rb +++ b/app/controllers/streams_controller.rb @@ -37,7 +37,6 @@ class StreamsController < ApplicationController def multi stream_responder(Stream::Multi) - end end def commented diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 39111b199f..f3e81c6609 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -20,21 +20,12 @@ module ApplicationHelper raw_bookmarklet end - def new_bookmarklet - raw_bookmarklet(520, 980, true) - end - - def raw_bookmarklet( height = 250, width = 620, new=false) - route = new ? 'new_bookmarklet' : 'bookmarklet' - "javascript:(function(){f='#{AppConfig[:pod_url]}#{route}?url='+encodeURIComponent(window.location.href)+'&title='+encodeURIComponent(document.title)+'¬es='+encodeURIComponent(''+(window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text))+'&v=1&';a=function(){if(!window.open(f+'noui=1&jump=doclose','diasporav1','location=yes,links=no,scrollbars=no,toolbar=no,width=#{width},height=#{height}'))location.href=f+'jump=yes'};if(/Firefox/.test(navigator.userAgent)){setTimeout(a,0)}else{a()}})()" + def raw_bookmarklet( height = 250, width = 620) + "javascript:(function(){f='#{AppConfig[:pod_url]}bookmarklet?url='+encodeURIComponent(window.location.href)+'&title='+encodeURIComponent(document.title)+'¬es='+encodeURIComponent(''+(window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text))+'&v=1&';a=function(){if(!window.open(f+'noui=1&jump=doclose','diasporav1','location=yes,links=no,scrollbars=no,toolbar=no,width=#{width},height=#{height}'))location.href=f+'jump=yes'};if(/Firefox/.test(navigator.userAgent)){setTimeout(a,0)}else{a()}})()" end def magic_bookmarklet_link - if user_signed_in? && current_user.beta? - new_bookmarklet - else - bookmarklet - end + bookmarklet end def contacts_link diff --git a/app/models/feature_flagger.rb b/app/models/feature_flagger.rb deleted file mode 100644 index 6de646b4fe..0000000000 --- a/app/models/feature_flagger.rb +++ /dev/null @@ -1,17 +0,0 @@ -class FeatureFlagger - def initialize(current_user, person_being_viewed=nil) - @current_user = current_user - @person = person_being_viewed - end - - protected - - def developer? - !(Rails.env.production? || Rails.env.staging?) #includes test, cucumber, or developer - end - - def admin? - @current_user.try(:admin?) - end - -end diff --git a/app/models/invitation_code.rb b/app/models/invitation_code.rb index 06313a7aad..48a710fd0d 100644 --- a/app/models/invitation_code.rb +++ b/app/models/invitation_code.rb @@ -5,7 +5,6 @@ class InvitationCode < ActiveRecord::Base before_create :generate_token, :set_default_invite_count - delegate :beta?, :to => :user def to_param token end @@ -39,4 +38,4 @@ class InvitationCode < ActiveRecord::Base def set_default_invite_count self.count = AppConfig[:invite_count] || 25 end -end \ No newline at end of file +end diff --git a/app/models/profile.rb b/app/models/profile.rb index 8dc6b120af..bf41aa31b0 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -5,8 +5,6 @@ class Profile < ActiveRecord::Base self.include_root_in_json = false - mount_uploader :wallpaper, WallpaperUploader - include Diaspora::Federated::Base include Diaspora::Taggable diff --git a/app/models/role.rb b/app/models/role.rb index d995f9077d..5fc0782f87 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -6,14 +6,6 @@ class Role < ActiveRecord::Base find_by_person_id_and_name(person.id, 'admin') end - def self.is_beta?(person) - find_by_person_id_and_name(person.id, 'beta').present? - end - - def self.add_beta(person) - find_or_create_by_person_id_and_name(person.id, 'beta') - end - def self.add_admin(person) find_or_create_by_person_id_and_name(person.id, 'admin') end @@ -37,4 +29,4 @@ class Role < ActiveRecord::Base find_or_create_by_person_id_and_name(person.id, 'spotlight') end end -end \ No newline at end of file +end diff --git a/app/models/user.rb b/app/models/user.rb index bbed4268b4..7e3cd1e93f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -106,10 +106,6 @@ class User < ActiveRecord::Base ConversationVisibility.sum(:unread, :conditions => "person_id = #{self.person.id}") end - def beta? - @beta ||= Role.is_beta?(self.person) - end - #@deprecated def ugly_accept_invitation_code begin @@ -437,11 +433,6 @@ class User < ActiveRecord::Base Role.is_admin?(self.person) end - def role_name - role = Role.find_by_person_id_and_name(self.person.id, 'beta') - role ? role.name : 'user' - end - def guard_unconfirmed_email self.unconfirmed_email = nil if unconfirmed_email.blank? || unconfirmed_email == email diff --git a/app/views/aspects/_aspect_stream.haml b/app/views/aspects/_aspect_stream.haml index 0e9375c67a..ca92631595 100644 --- a/app/views/aspects/_aspect_stream.haml +++ b/app/views/aspects/_aspect_stream.haml @@ -5,18 +5,10 @@ %h3#aspect_stream_header.stream_title = stream.title -- if current_user.beta? - = link_to t('.make_something'), "#composer", :rel => "facebox", :class => "button primary", :style => "display: block; margin: 20px 10px; margin-bottom: 30px; padding: 10px; text-align:center; font-weight: bold;" - - #composer{:style => "display:none;"} - %iframe{:src => '/posts/new', :height => 500, :width => 980, :style => "border:none;"} - -- else = render 'shared/publisher', :selected_aspects => stream.aspects, :aspect_ids => stream.aspect_ids, :for_all_aspects => stream.for_all_aspects?, :aspect => stream.aspect = render 'aspects/no_posts_message' -- unless current_user.beta? - #gs-shim{:title => popover_with_close_html("3. #{t('.stay_updated')}"), 'data-content' => t('.stay_updated_explanation')} +#gs-shim{:title => popover_with_close_html("3. #{t('.stay_updated')}"), 'data-content' => t('.stay_updated_explanation')} #main_stream.stream diff --git a/app/views/layouts/main_stream.html.haml b/app/views/layouts/main_stream.html.haml index e08963a1a4..4aa30e9fd6 100644 --- a/app/views/layouts/main_stream.html.haml +++ b/app/views/layouts/main_stream.html.haml @@ -6,7 +6,7 @@ - content_for :head do = javascript_include_tag :home -- if current_user.getting_started? && !current_user.beta? +- if current_user.getting_started? #welcome-to-diaspora .container{:style => "position: relative;"} .right diff --git a/config/routes.rb b/config/routes.rb index 3fa0449b93..564a6b2b64 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -56,14 +56,11 @@ Diaspora::Application.routes.draw do end get 'bookmarklet' => 'status_messages#bookmarklet' - get 'new_bookmarklet' => 'status_messages#new_bookmarklet' resources :photos, :except => [:index] do put :make_profile_photo end - post "upload_wallpaper" => 'profiles#upload_wallpaper_image' - # ActivityStreams routes scope "/activity_streams", :module => "activity_streams", :as => "activity_streams" do resources :photos, :controller => "photos", :only => [:create] diff --git a/features/step_definitions/new_hotness/new_stream_steps.rb b/features/step_definitions/new_hotness/new_stream_steps.rb deleted file mode 100644 index bf7a7eb9c5..0000000000 --- a/features/step_definitions/new_hotness/new_stream_steps.rb +++ /dev/null @@ -1,23 +0,0 @@ -Then /^"([^"]*)" should be frame (\d+)$/ do |post_text, position| - frame_numbers_content(position).find(".text-content").text.should == post_text -end - -When /^I click the "([^"]*)" stream frame$/ do |post_text| - within "#stream-content" do - find_frame_by_text(post_text).find(".content").click - end -end - -Then /^"([^"]*)" should be a comment for "([^"]*)"$/ do |comment_text, post_text| - post = find_frame_by_text(post_text) - post.find(".comment:contains('#{comment_text}')").should be_present -end - -When /^I click into the "([^"]*)" stream frame$/ do |post_text| - find("#stream-content .content:contains('#{post_text}') .permalink").click - #within "#stream-content" do - # post = find_frame_by_text(post_text) - # link = post.find(".permalink") - # link.click - #end -end \ No newline at end of file diff --git a/features/step_definitions/new_hotness/new_user_steps.rb b/features/step_definitions/new_hotness/new_user_steps.rb deleted file mode 100644 index 7f76aa06ab..0000000000 --- a/features/step_definitions/new_hotness/new_user_steps.rb +++ /dev/null @@ -1,19 +0,0 @@ -def create_beta_user(opts) - user = create_user(opts) - Role.add_beta(user.person) - user -end - -Given /^I am logged in as a beta user with email "(.*?)"$/ do |email| - @me = create_beta_user(:email => email, :password => 'password', :password_confirmation => 'password') - visit login_page - login_as(@me.username, 'password') -end - -Given /^a beta user "(.*?)"$/ do |email| - create_beta_user(:email => email) -end - -When /^"([^"]*)" is an admin$/ do |email| - Role.add_admin(User.find_by_email(email).person) -end \ No newline at end of file diff --git a/features/step_definitions/new_hotness/trumpeter_steps.rb b/features/step_definitions/new_hotness/trumpeter_steps.rb deleted file mode 100644 index c7672cdec5..0000000000 --- a/features/step_definitions/new_hotness/trumpeter_steps.rb +++ /dev/null @@ -1,187 +0,0 @@ -def type_to_mention(typed, user_name) - #add each of the charcters to jquery.mentionsInput's buffer - typed.each_char do |char| - key_code = char.ord - page.execute_script <<-JAVASCRIPT - var e = new $.Event("keypress") - e.which = #{key_code} - $("textarea.text").trigger(e) - JAVASCRIPT - end - - #trigger event that brings up mentions input - page.execute_script('$("textarea.text").trigger("input")') - - page.find(".mentions-autocomplete-list li:contains('#{user_name}')").click() -end - -def aspects_dropdown - find(".dropdown-toggle") -end - -def select_from_dropdown(option_text, dropdown) - dropdown.click - within ".dropdown-menu" do - label = find("label:contains('#{option_text}')") - label.should be_visible - label.click - end -end - -def go_to_framer - find(".next").click() -end - -def go_to_post_by_text post_text - visit post_path_by_content(post_text) -end - -def finalize_frame - find(".done").click() -end - -def assert_post_renders_with(mood) - find(".#{mood.downcase}").should be_present -end - -def get_image_filename(filename) - @image_sources[filename].tap {|src| src.should be_present} -end - -def set_image_filename(file_name) - @image_sources ||= {} - @image_sources[file_name] = all(".photos img").last["src"].tap {|src| src.should be_present} -end - -def find_image_by_filename(filename) - find("img[src='#{get_image_filename(filename)}']") -end - -def upload_photo(file_name) - orig_photo_count = all(".photos img").size - - within ".new_photo" do - attach_file "photo[user_file]", Rails.root.join("spec", "fixtures", file_name) - wait_until { all(".photos img").size == orig_photo_count + 1 } - end - - set_image_filename(file_name) -end - -When /^I trumpet$/ do - visit new_post_path -end - -When /^I write "([^"]*)"(?:| with body "([^"]*)")$/ do |headline, body| - fill_in 'text', :with => [headline, body].join("\n") -end - -Then /I type "([^"]*)" to mention "([^"]*)"$/ do |typed, user_name| - type_to_mention(typed, user_name) -end - -When /^I select "([^"]*)" in my aspects dropdown$/ do |title| - within ".aspect-selector" do - select_from_dropdown(title, aspects_dropdown) - end -end - -Then /^"([^"]*)" should be a (limited|public) post in my stream$/ do |post_text, scope| - find_post_by_text(post_text).find(".post_scope").text.should =~ /#{scope}/i -end - -When /^I upload a fixture picture with filename "([^"]*)"$/ do |file_name| - upload_photo(file_name) -end - -Then /^"([^"]*)" should have the "([^"]*)" picture$/ do |post_text, file_name| - within find_post_by_text(post_text) do - find_image_by_filename(file_name).should be_present - end -end - -When /^I make a new publisher post "([^"]*)"$/ do |post_text| - visit new_post_path - fill_in 'text', :with => post_text - go_to_framer - finalize_frame -end - -When /^I go through the default framer$/ do - go_to_framer - finalize_frame -end - -When /^I start the framing process$/ do - go_to_framer -end - -When /^I finalize my frame$/ do - finalize_frame -end - -Then /^"([^"]*)" should have (\d+) pictures$/ do |post_text, number_of_pictures| - find_post_by_text(post_text).all(".photo_attachments img").size.should == number_of_pictures.to_i -end - -Then /^I should see "([^"]*)" in the framer preview$/ do |post_text| - within(find(".canvas-frame")) { page.should have_content(post_text) } -end - -When /^I select the mood "([^"]*)"$/ do |mood| - find("label:contains('#{mood}')").click -end - -Then /^the post's (?:default |)mood should (?:still |)be "([^"]*)"$/ do |mood| - assert_post_renders_with(mood) -end - -When /^"([^"]*)" should be in the post's picture viewer$/ do |file_name| - within(".photo_viewer") do - find_image_by_filename(file_name).should be_present - end -end - -When /^"([^"]*)" should be in the post's small frame$/ do |file_name| - within(".canvas-frame") do - find_image_by_filename(file_name).should be_present - end -end - -Then /^it should be a wallpaper frame with the background "([^"]*)"$/ do |file_name| - assert_post_renders_with("Wallpaper") - find("div.photo-fill")["data-img-src"].should == get_image_filename(file_name) -end - -Then /^it should be a wallpaper small frame with the background "([^"]*)"$/ do |file_name| - assert_post_renders_with("Wallpaper") - find("div.image-container img")["src"].should == get_image_filename(file_name) -end - -When /^the frame's headline should be "([^"]*)"$/ do |header_text| - find("header").text.should == header_text -end - -When /^the frame's body should be "([^"]*)"$/ do |body_text| - find("section.body").text.should == body_text -end - -Then /^the post should mention "([^"]*)"$/ do |user_name| - within('#post-content') { find("a:contains('#{user_name}')").should be_present } -end - -When /^I click into the "([^"]*)" post$/ do |post_text| - find("#canvas .content:contains('#{post_text}') .permalink").click -end - -Then /^"([^"]*)" should be the first canvas frame$/ do |post_text| - find(".canvas-frame").should have_content(post_text) -end - -When /^I go back to the composer$/ do - find(".back").click() -end - -When /^I open the show page of the "([^"]*)" post$/ do |post_text| - go_to_post_by_text post_text -end diff --git a/spec/controllers/home_controller_spec.rb b/spec/controllers/home_controller_spec.rb index 88941e4bc9..f994e21017 100644 --- a/spec/controllers/home_controller_spec.rb +++ b/spec/controllers/home_controller_spec.rb @@ -12,7 +12,7 @@ describe HomeController do response.should_not be_redirect end - context 'redirection' + context 'redirection' do before do sign_in alice end @@ -28,13 +28,7 @@ describe HomeController do get :show, :home => true response.should redirect_to(person_path(alice.person)) end - - it "points to the root_path if a user is an admin without contacts" do - alice.contacts.destroy_all - Role.add_beta(alice.person) - get :show, :home => true - response.should redirect_to(person_path(alice.person)) - end + end end describe '#toggle_mobile' do diff --git a/spec/controllers/profiles_controller_spec.rb b/spec/controllers/profiles_controller_spec.rb index 94cc429faa..742e4635ce 100644 --- a/spec/controllers/profiles_controller_spec.rb +++ b/spec/controllers/profiles_controller_spec.rb @@ -161,24 +161,4 @@ describe ProfilesController do end end end - - describe '#upload_wallpaper_image' do - it 'returns a success=false response if the photo param is not present' do - post :upload_wallpaper_image, :format => :json - JSON.parse(response.body).should include("success" => false) - end - - it 'stores the wallpaper for the current_user' do - # we should have another test here asserting that the wallpaper is set... i was having problems testing - # this behavior though :( - - @controller.stub!(:current_user).and_return(eve) - @controller.stub!(:remotipart_submitted?).and_return(true) - @controller.stub!(:file_handler).and_return(uploaded_photo) - @params = {:photo => {:user_file => uploaded_photo} } - - eve.person.profile.wallpaper.should_receive(:store!) - post :upload_wallpaper_image, @params.merge(:format => :json) - end - end -end \ No newline at end of file +end diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index 8da6c6de2e..e3c15f3ed4 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -266,11 +266,6 @@ describe UsersController do it "redirects to getting started if the user has getting started set to true" do @controller.after_sign_in_path_for(eve).should == getting_started_path end - - it "does not redirect to getting started if the user is beta" do - Role.add_beta(eve.person) - @controller.after_sign_in_path_for(eve).should == person_path(eve.person) - end end end end diff --git a/spec/models/invitation_code_spec.rb b/spec/models/invitation_code_spec.rb index c902c6c363..18d949f982 100644 --- a/spec/models/invitation_code_spec.rb +++ b/spec/models/invitation_code_spec.rb @@ -20,16 +20,6 @@ describe InvitationCode do end end - describe '.beta?' do - it 'returns true if the invite code user is beta' do - code = Factory(:invitation_code) - Role.add_beta(code.user.person) - code.user.should be_beta - code.should be_beta - end - end - - describe '.default_inviter_or' do before do @old_account = AppConfig[:admin_account] diff --git a/spec/models/profile_spec.rb b/spec/models/profile_spec.rb index be2b311f19..efd46b4ebc 100644 --- a/spec/models/profile_spec.rb +++ b/spec/models/profile_spec.rb @@ -335,8 +335,7 @@ describe Profile do "searchable", "nsfw", "location", - "full_name", - "wallpaper"].sort + "full_name"].sort end end end -- GitLab