Merge branch 'master' of github.com:diaspora/diaspora

This commit is contained in:
maxwell 2011-01-13 09:45:56 -08:00
commit c002692657
13 changed files with 124 additions and 134 deletions

View file

@ -51,7 +51,7 @@
%span.tip click to edit
%ul.tools
%li= link_to t('.add_a_new_contact'), "#manage_aspect_contacts_pane_#{hash[:aspect].id}", :class => 'manage_aspect_contacts_button'
%li= link_to t('.add_a_new_contact'), "#manage_aspect_contacts_pane_#{hash[:aspect].id}", :class => 'manage_aspect_contacts_button', :rel => "facebox"
%li!= remove_link(hash[:aspect])
%ul.dropzone{:data=>{:aspect_id=>hash[:aspect].id}}
@ -65,7 +65,7 @@
.draggable_info
=t('.drag_to_add')
.fancybox_content
.facebox_content
%div{:id => "manage_aspect_contacts_pane_#{hash[:aspect].id}"}
= render "requests/manage_aspect_contacts", :aspect => hash[:aspect], :manage => true, :contact_hashes => hash[:contacts]

View file

@ -51,7 +51,7 @@
%li
= link_to '+', '#add_aspect_pane', :class => "add_aspect_button", :title => t('aspects.manage.add_a_new_aspect'), :rel => 'facebox'
.fancybox_content
.facebox_content
#add_aspect_pane
= render "aspects/new_aspect"

View file

@ -7,10 +7,11 @@
.span-15.append-1.last
#photo_controls
.right
=link_to "← #{t('previous')}", @prev_photo, :rel => 'prefetch', :id => 'photo_show_left'
\/
=link_to "#{t('next')} →", @next_photo, :rel => 'prefetch', :id => 'photo_show_right'
-if @additional_photos.length > 1
.right
=link_to "← #{t('previous')}", @prev_photo, :rel => 'prefetch', :id => 'photo_show_left'
\/
=link_to "#{t('next')} →", @next_photo, :rel => 'prefetch', :id => 'photo_show_right'
- if @photo.status_message_id
=link_to "← #{t('.view_original_post')}", @photo.status_message

View file

@ -46,9 +46,9 @@
- for service in current_user.services
= image_tag "social_media_logos/#{service.provider}-16x16.png", :title => service.provider
= link_to '(?)', "#question_mark_pane", :class => 'question_mark', :style=>"display:none;"
= link_to '(?)', "#question_mark_pane", :class => 'question_mark', :style=>"display:none;", :rel => 'facebox'
.fancybox_content
.facebox_content
#question_mark_pane
= render 'shared/public_explain'

View file

@ -86,7 +86,7 @@ var Stream = {
var $this = $(this),
container = document.createElement("div"),
$container = $(container).attr("class", "video-container"),
$videoContainer = $this.parent().siblings("div.video-container");
$videoContainer = $this.siblings("div.video-container");
if ($videoContainer.length > 0) {
$videoContainer.slideUp('fast', function() {
@ -116,7 +116,7 @@ var Stream = {
}
$container.hide()
.insertAfter($this.parent())
.insertAfter($this)
.slideDown('fast');
$this.click(function() {

View file

@ -12,19 +12,27 @@ var Validation = {
characters: /^(([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,}))(, *(([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})))*$/
}
},
whiteListed: function(keyCode) {
var keyCodes = [0, 37, 38, 39, 40, 8, 9];
return $.grep(keyCodes, function(element) { return keyCode !== element; }).length === keyCodes.length - 1;
},
events: {
usernameKeypress: function(evt) {
if(evt.keyCode === 0) {
if(Validation.whiteListed(evt.keyCode)) {
return;
}
if(!Validation.rules.username.characters.test(this.value + String.fromCharCode(evt.keyCode))) {
evt.preventDefault();
}
},
},
emailKeypress: function(evt) {
if(evt.keyCode === 0) {
if(Validation.whiteListed(evt.keyCode)) {
return;
}
if(!Validation.rules.email.characters.test(this.value + String.fromCharCode(evt.keyCode))) {
$('#user_email').css('border-color', '#8B0000');
} else {

View file

@ -65,20 +65,6 @@ var View = {
selector: ".add_aspect_button"
},
fancyBoxButtons: {
selectors: [
".add_aspect_button",
".manage_aspect_contacts_button",
".invite_user_button",
".add_photo_button",
".remove_person_button",
".question_mark",
".share_with_button",
".aspect_detail_button",
".aspect_selector_edit"
]
},
debug: {
click: function() {
$("#debug_more").toggle("fast");

View file

@ -1207,10 +1207,6 @@ ul#settings_nav
.settings_pane
:display none
#fancybox-close:hover
:background
:color transparent
.contact_pictures,
#aspect_listings li
img
@ -1302,7 +1298,7 @@ input[type="search"]
:-webkit-appearance textfield
:-moz-appearance textfield
.fancybox_content
.facebox_content
:display none
#photo_edit_options

View file

@ -3,6 +3,7 @@
# the COPYRIGHT file.
require 'spec_helper'
require File.join(Rails.root, "spec", "shared_behaviors", "log_override")
describe AspectsController do
render_views
@ -25,6 +26,21 @@ describe AspectsController do
request.env["HTTP_REFERER"] = 'http://' + request.host
end
describe "custom logging on success" do
before do
@action = :index
end
it_should_behave_like "it overrides the logs on success"
end
describe "custom logging on redirect" do
before do
@action = :show
@action_params = {'id' => @aspect0.id.to_s}
end
it_should_behave_like "it overrides the logs on redirect"
end
describe "#index" do
it "assigns @contacts to all the user's contacts" do
Factory.create :person

View file

@ -3,6 +3,7 @@
# the COPYRIGHT file.
require 'spec_helper'
require File.join(Rails.root, "spec", "shared_behaviors", "log_override")
describe HomeController do
render_views
@ -26,102 +27,20 @@ describe HomeController do
end
end
#This describe should apply to any controller class. HomeController is just the simplest.
describe 'log overriding in lib/log_overrider' do
describe "custom logging on success" do
before do
Rails.stub(:logger).and_return(FakeLogger.new)
end
context 'cross-stage' do
before do
pending "This might require patching Rails"
get :show
@lines = Rails.logger.infos
@id = @lines[1].match(/r_id=(\w+)\s/).captures.first
end
it 'logs a unified id in a request' do
id = @lines.first.match(/r_id=(\w+)\s/).captures.first
@lines.each do |line|
line.match(/r_id=(\w+)\s/).captures.first.should == @id
end
end
it 'logs different ids in different requests' do
get :show
old_lines = Rails.logger.infos.select do |line|
line.match(/r_id=(\w+)\s/).captures.first == @id
end
old_lines.length.should == Rails.logger.infos.length/2
end
end
context 'starting' do
before do
pending "This code is never reached in tests, but it seems to work in actual requests"
get :show
@line = Rails.logger.infos.first
end
it 'logs it' do
@line.should match /event=request_started/
end
end
context 'rendering' do
before do
get :show, :lasers => 'green'
@lines = Rails.logger.infos.select{|l| l.include?("event=render")}
end
it 'logs all renders' do
@lines.length.should == 1
end
it 'logs layouts' do
pending 'where is the template=home/show line?'
home_line = @lines.detect{|t|
t.include?("template=home/show.html.haml")}
home_line.should match /layout=layouts\/application/
end
end
context 'completion' do
context 'ok' do
before do
get :show, :lasers => 'green'
@line = Rails.logger.infos.last
end
it 'logs the completion of a request' do
@line.include?('event=request_completed').should be_true
end
it 'logs an ok' do
@line.include?('status=200').should be_true
end
it 'logs the controller' do
@line.include?('controller=HomeController').should be_true
end
it 'logs the action' do
@line.include?('action=show').should be_true
end
it 'logs params' do
@line.include?("params='{\"lasers\"=>\"green\"}'").should be_true
end
it 'does not log the view rendering time addition' do
@line.include?("(Views: ").should be_false
end
end
context 'redirected' do
before do
sign_in @user
get :show, :lasers => 'green'
@line = Rails.logger.infos.last
end
it 'logs a redirect' do
@line.include?('status=302').should be_true
end
end
@action = :show
@action_params = {"lasers" => "green"}
end
it_should_behave_like "it overrides the logs on success"
end
class FakeLogger
attr_accessor :infos
def initialize
self.infos = []
end
def info line
self.infos << line
describe "custom logging on redirect" do
before do
sign_in :user, make_user
@action = :show
@action_params = {"lasers" => "green"}
end
it_should_behave_like "it overrides the logs on redirect"
end
end

View file

@ -15,6 +15,15 @@ describe("Validation", function() {
});
});
});
describe("whiteListed", function() {
it("returns true if the keyCode is whitelisted", function() {
expect(Validation.whiteListed(0)).toBeTruthy();
});
it("returns false if it's not", function() {
expect(Validation.whiteListed(9001)).toBeFalsy();
});
});
describe("events", function() {
describe("usernameKeypress", function() {
it("doesn't allow the user to type anything but letters, numbers and underscores", function() {

View file

@ -11,14 +11,6 @@ describe("View", function() {
});
});
describe("fancyBoxButtons", function() {
describe("selectors", function() {
it("is an array of all the selectors that will have fancybox attached", function() {
expect(typeof View.fancyBoxButtons.selectors === "object").toBeTruthy();
expect($.isArray(View.fancyBoxButtons.selectors)).toBeTruthy();
});
});
});
describe("debug", function() {
describe("click", function() {

View file

@ -0,0 +1,63 @@
class FakeLogger
attr_accessor :infos
def initialize
self.infos = []
end
def info line
self.infos << line
end
end
shared_examples_for 'it overrides the logs on success' do
before do
Rails.stub(:logger).and_return(FakeLogger.new)
end
context 'rendering' do
it 'logs renders' do
get @action, @action_params
@lines = Rails.logger.infos.select { |l| l.include?("event=render") }
@lines.length.should > 0
end
end
context 'completion' do
context 'ok' do
before do
get @action, @action_params
@line = Rails.logger.infos.last
end
it 'logs the completion of a request' do
@line.include?('event=request_completed').should be_true
end
it 'logs an ok' do
@line.include?('status=200').should be_true
end
it 'logs the controller' do
@line.include?("controller=#{controller.class.name}").should be_true
end
it 'logs the action' do
@line.include?("action=#{@action}").should be_true
end
it 'logs params' do
if @action_params
@line.include?("params='#{@action_params.inspect.gsub(" ", "")}'").should be_true
end
end
it 'does not log the view rendering time addition' do
@line.include?("(Views: ").should be_false
end
end
end
end
shared_examples_for 'it overrides the logs on redirect' do
before do
Rails.stub(:logger).and_return(FakeLogger.new)
get @action, @action_params
@line = Rails.logger.infos.last
end
it 'logs a redirect' do
@line.include?('status=302').should be_true
end
end