Commit ab0ad630 authored by Jonne Haß's avatar Jonne Haß

strip last beta leftovers and fix syntax errors, travis is kinda down, lets...

strip last beta leftovers and fix syntax errors, travis is kinda down, lets hope nothing breaks while I sleep
parent ffde639f
......@@ -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
......@@ -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
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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!
......
......@@ -37,7 +37,6 @@ class StreamsController < ApplicationController
def multi
stream_responder(Stream::Multi)
end
end
def commented
......
......@@ -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)+'&notes='+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)+'&notes='+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
......
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
......@@ -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
......@@ -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
......
......@@ -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
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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]
......
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
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
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
......@@ -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
......
......@@ -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
......@@ -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
......
......@@ -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]
......
......@@ -335,8 +335,7 @@ describe Profile do
"searchable",
"nsfw",
"location",
"full_name",
"wallpaper"].sort
"full_name"].sort
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment