diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 024dfe11..86887fdd 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -5,11 +5,14 @@ // the compiled file. // //= require jquery +//= require jquery-ui //= require jquery_ujs +//= require jquery.ui.selectmenu +//= require jquery.cookie //= require_tree . $(function(){ - $(".one_click_select").click(function(){ + $(".one_click_select").live("click", function(){ $(this).select(); }); diff --git a/app/assets/javascripts/jquery.ui.selectmenu.js b/app/assets/javascripts/jquery.ui.selectmenu.js deleted file mode 100644 index d61d75f9..00000000 --- a/app/assets/javascripts/jquery.ui.selectmenu.js +++ /dev/null @@ -1,845 +0,0 @@ - /* - * jQuery UI selectmenu dev version - * - * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. - * - * http://docs.jquery.com/UI - * https://github.com/fnagel/jquery-ui/wiki/Selectmenu - */ - -(function($) { - -$.widget("ui.selectmenu", { - getter: "value", - version: "1.8", - eventPrefix: "selectmenu", - options: { - transferClasses: true, - typeAhead: "sequential", - style: 'dropdown', - positionOptions: { - my: "left top", - at: "left bottom", - offset: null - }, - width: null, - menuWidth: null, - handleWidth: 26, - maxHeight: null, - icons: null, - format: null, - bgImage: function() {}, - wrapperElement: "
" - }, - - _create: function() { - var self = this, o = this.options; - - // set a default id value, generate a new random one if not set by developer - var selectmenuId = this.element.attr( 'id' ) || 'ui-selectmenu-' + Math.random().toString( 16 ).slice( 2, 10 ); - - // quick array of button and menu id's - this.ids = [ selectmenuId + '-button', selectmenuId + '-menu' ]; - - // define safe mouseup for future toggling - this._safemouseup = true; - - // create menu button wrapper - this.newelement = $( '', { - 'class': this.widgetBaseClass + ' ui-widget ui-state-default ui-corner-all', - 'id' : this.ids[ 0 ], - 'role': 'button', - 'href': '#nogo', - 'tabindex': this.element.attr( 'disabled' ) ? 1 : 0, - 'aria-haspopup': true, - 'aria-owns': this.ids[ 1 ] - }); - this.newelementWrap = $( o.wrapperElement ) - .append( this.newelement ) - .insertAfter( this.element ); - - // transfer tabindex - var tabindex = this.element.attr( 'tabindex' ); - if ( tabindex ) { - this.newelement.attr( 'tabindex', tabindex ); - } - - // save reference to select in data for ease in calling methods - this.newelement.data( 'selectelement', this.element ); - - // menu icon - this.selectmenuIcon = $( '' ) - .prependTo( this.newelement ); - - // append status span to button - this.newelement.prepend( '' ); - - // make associated form label trigger focus - $( 'label[for="' + selectmenuId + '"]' ) - .attr( 'for', this.ids[0] ) - .bind( 'click.selectmenu', function() { - self.newelement[0].focus(); - return false; - }); - - // click toggle for menu visibility - this.newelement - .bind('mousedown.selectmenu', function(event) { - self._toggle(event, true); - // make sure a click won't open/close instantly - if (o.style == "popup") { - self._safemouseup = false; - setTimeout(function() { self._safemouseup = true; }, 300); - } - return false; - }) - .bind('click.selectmenu', function() { - return false; - }) - .bind("keydown.selectmenu", function(event) { - var ret = false; - switch (event.keyCode) { - case $.ui.keyCode.ENTER: - ret = true; - break; - case $.ui.keyCode.SPACE: - self._toggle(event); - break; - case $.ui.keyCode.UP: - if (event.altKey) { - self.open(event); - } else { - self._moveSelection(-1); - } - break; - case $.ui.keyCode.DOWN: - if (event.altKey) { - self.open(event); - } else { - self._moveSelection(1); - } - break; - case $.ui.keyCode.LEFT: - self._moveSelection(-1); - break; - case $.ui.keyCode.RIGHT: - self._moveSelection(1); - break; - case $.ui.keyCode.TAB: - ret = true; - break; - default: - ret = true; - } - return ret; - }) - .bind('keypress.selectmenu', function(event) { - self._typeAhead(event.which, 'mouseup'); - return true; - }) - .bind('mouseover.selectmenu focus.selectmenu', function() { - if (!o.disabled) { - $(this).addClass(self.widgetBaseClass + '-focus ui-state-hover'); - } - }) - .bind('mouseout.selectmenu blur.selectmenu', function() { - if (!o.disabled) { - $(this).removeClass(self.widgetBaseClass + '-focus ui-state-hover'); - } - }); - - // document click closes menu - $(document).bind("mousedown.selectmenu", function(event) { - self.close(event); - }); - - // change event on original selectmenu - this.element - .bind("click.selectmenu", function() { - self._refreshValue(); - }) - // FIXME: newelement can be null under unclear circumstances in IE8 - // TODO not sure if this is still a problem (fnagel 20.03.11) - .bind("focus.selectmenu", function() { - if (self.newelement) { - self.newelement[0].focus(); - } - }); - - // set width when not set via options - if (!o.width) { - o.width = this.element.outerWidth(); - } - // set menu button width - this.newelement.width(o.width); - - // hide original selectmenu element - this.element.hide(); - - // create menu portion, append to body - this.list = $( '
- <% if current_user %> <%= javascript_tag do %> $(function() { diff --git a/app/views/notes/_form.html.haml b/app/views/notes/_form.html.haml index ca56a245..14e74fa6 100644 --- a/app/views/notes/_form.html.haml +++ b/app/views/notes/_form.html.haml @@ -22,7 +22,7 @@ = check_box_tag :notify, 1, true = label_tag :notify, "Notify project team about your note" - + .clear %br = f.submit 'Add note', :class => "lbutton vm", :id => "submit_note" diff --git a/app/views/notes/_notes.html.haml b/app/views/notes/_notes.html.haml index 2d110162..e7cc2360 100644 --- a/app/views/notes/_notes.html.haml +++ b/app/views/notes/_notes.html.haml @@ -1,7 +1,7 @@ - if controller.action_name == "wall" %ul#notes-list= render "notes/notes_list" -- else +- else %ul#notes-list= render "notes/notes_list" %br %br @@ -9,17 +9,16 @@ = render "notes/form" :javascript - $('.delete-note').live('ajax:success', function() { - $(this).closest('li').fadeOut(); }); + $('.delete-note').live('ajax:success', function() { + $(this).closest('li').fadeOut(); }); $("#new_note").live("ajax:before", function(){ - $("#submit_note").attr("disabled", "disabled"); + $("#submit_note").attr("disabled", "disabled"); }) $("#new_note").live("ajax:complete", function(){ - $("#submit_note").removeAttr("disabled"); + $("#submit_note").removeAttr("disabled"); }) - - if ["issues", "projects"].include?(controller.controller_name) :javascript diff --git a/app/views/notes/create.js.haml b/app/views/notes/create.js.haml index 15371dbc..a04130e8 100644 --- a/app/views/notes/create.js.haml +++ b/app/views/notes/create.js.haml @@ -7,5 +7,5 @@ :plain $("#new_note").replaceWith("#{escape_javascript(render('form'))}"); -:plain +:plain $("#submit_note").removeAttr("disabled"); diff --git a/app/views/notify/new_issue_email.html.haml b/app/views/notify/new_issue_email.html.haml index 213a7379..1a5a603a 100644 --- a/app/views/notify/new_issue_email.html.haml +++ b/app/views/notify/new_issue_email.html.haml @@ -10,9 +10,9 @@ %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"} %td{:align => "left", :style => "padding: 20px 0 0;"} %h2{:style => "color:#646464 !important; font-weight: bold; margin: 0; padding: 0; line-height: 26px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; "} - = link_to project_issue_url(@project, @issue) do + = link_to project_issue_url(@project, @issue) do = "Issue ##{@issue.id.to_s}" - = truncate(@issue.title, :length => 45) + = truncate(@issue.title, :length => 45) %br %cite{:style => "color:#767676; font-weight: normal; margin: 0; padding: 0; line-height: 20px; font-size: 12px;font-family: Helvetica, Arial, sans-serif; "} = @issue.content diff --git a/app/views/notify/new_user_email.html.haml b/app/views/notify/new_user_email.html.haml index 969ea7e5..2d3abf2e 100644 --- a/app/views/notify/new_user_email.html.haml +++ b/app/views/notify/new_user_email.html.haml @@ -4,7 +4,7 @@ %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"} %td{:align => "left", :style => "padding: 20px 0 0;"} %h2{:style => "color:#646464; font-weight: bold; margin: 0; padding: 0; line-height: 26px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; "} - Hi #{@user.name}! + Hi #{@user.name}! %p{:style => "color:#767676; font-weight: normal; margin: 0; padding: 0; line-height: 20px; font-size: 12px;font-family: Helvetica, Arial, sans-serif; "} Administrator created account for you. Now you are a member of company gitlab application. %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"} diff --git a/app/views/notify/note_issue_email.html.haml b/app/views/notify/note_issue_email.html.haml index 242c97bf..7d8e2156 100644 --- a/app/views/notify/note_issue_email.html.haml +++ b/app/views/notify/note_issue_email.html.haml @@ -4,10 +4,10 @@ %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"} %td{:align => "left", :style => "padding: 20px 0 0;"} %h2{:style => "color:#646464 !important; font-weight: bold; margin: 0; padding: 0; line-height: 26px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; "} - New comment - - = link_to project_issue_url(@project, @issue, :anchor => "note_#{@note.id}") do + New comment - + = link_to project_issue_url(@project, @issue, :anchor => "note_#{@note.id}") do = "Issue ##{@issue.id.to_s}" - = truncate(@issue.title, :length => 35) + = truncate(@issue.title, :length => 35) %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"} %tr %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"} diff --git a/app/views/notify/note_wall_email.html.haml b/app/views/notify/note_wall_email.html.haml index c9fdae12..a2bd5a76 100644 --- a/app/views/notify/note_wall_email.html.haml +++ b/app/views/notify/note_wall_email.html.haml @@ -4,7 +4,7 @@ %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"} %td{:align => "left", :style => "padding: 20px 0 0;"} %h2{:style => "color:#646464; font-weight: bold; margin: 0; padding: 0; line-height: 26px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; "} - New message on + New message on = link_to "Project Wall", wall_project_url(@project, :anchor => "note_#{@note.id}") %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"} %tr diff --git a/app/views/projects/_form.html.haml b/app/views/projects/_form.html.haml index 00ca98ef..164f1d45 100644 --- a/app/views/projects/_form.html.haml +++ b/app/views/projects/_form.html.haml @@ -21,7 +21,7 @@ %td = f.text_field :path, :placeholder => "example_project", :disabled => !@project.new_record? %tr - %td + %td .left= f.label :code %cite.right http://yourserver/ %td= f.text_field :code, :placeholder => "example" @@ -39,10 +39,10 @@ = image_tag "ajax-loader.gif", :class => "append-bottom" - if @project.new_record? %h3.prepend-top Creating project & repository. Please wait for few minutes - - else + - else %h3.prepend-top Updating project & repository. Please wait for few minutes :javascript - $('.new_project, .edit_project').bind('ajax:before', function() { - $(this).find(".form_content").hide(); + $('.new_project, .edit_project').bind('ajax:before', function() { + $(this).find(".form_content").hide(); $('.ajax_loader').show(); - }); + }); diff --git a/app/views/projects/_list.html.haml b/app/views/projects/_list.html.haml index aec61ffb..65f0b7fd 100644 --- a/app/views/projects/_list.html.haml +++ b/app/views/projects/_list.html.haml @@ -16,7 +16,7 @@ %td= check_box_tag "read", 1, project.readers.include?(current_user), :disabled => :disabled %td= check_box_tag "commit", 1, project.writers.include?(current_user), :disabled => :disabled %td= check_box_tag "admin", 1, project.admins.include?(current_user), :disabled => :disabled - %td + %td -if can? current_user, :admin_project, project = link_to 'Edit', edit_project_path(project), :class => "lbutton positive" %br diff --git a/app/views/projects/_projects_top_menu.html.haml b/app/views/projects/_projects_top_menu.html.haml index f80f28a8..9e199183 100644 --- a/app/views/projects/_projects_top_menu.html.haml +++ b/app/views/projects/_projects_top_menu.html.haml @@ -11,7 +11,7 @@ $(".list").toggle(); if($(".tile").is(":visible")){ $.cookie('project_view', 'tile', { expires: 14 }); - } else { + } else { $.cookie('project_view', 'list', { expires: 14 }); } } diff --git a/app/views/projects/_recent_commits.html.haml b/app/views/projects/_recent_commits.html.haml index 3157c356..b34470d6 100644 --- a/app/views/projects/_recent_commits.html.haml +++ b/app/views/projects/_recent_commits.html.haml @@ -6,8 +6,8 @@ = image_tag "no_avatar.png", :class => "left", :width => 40, :style => "padding-right:5px;" %p{:style => "margin-bottom: 3px;"} %strong - = link_to truncate(commit.safe_message, :length => 60), project_commit_path(@project, :id => commit.id) - + = link_to truncate(commit.safe_message, :length => 60), project_commit_path(@project, :id => commit.id) + %span %span.author = commit.author.name.force_encoding("UTF-8") diff --git a/app/views/projects/_team.html.haml b/app/views/projects/_team.html.haml index bb906336..4001c7a2 100644 --- a/app/views/projects/_team.html.haml +++ b/app/views/projects/_team.html.haml @@ -14,5 +14,5 @@ = render(:partial => 'team_members/show', :locals => {:member => up}) :javascript - $('.delete-team-member').live('ajax:success', function() { - $(this).closest('tr').fadeOut(); }); + $('.delete-team-member').live('ajax:success', function() { + $(this).closest('tr').fadeOut(); }); diff --git a/app/views/projects/empty.html.erb b/app/views/projects/empty.html.erb index 4c60facd..ffc1ebfa 100644 --- a/app/views/projects/empty.html.erb +++ b/app/views/projects/empty.html.erb @@ -40,7 +40,7 @@ eos

Be careful!
Project cant be recovered after destroy.

- <%= link_to 'Destroy', @project, + <%= link_to 'Destroy', @project, :confirm => 'Are you sure?', :method => :delete, :class => "left button negative span-6", :style => "text-align:center" %>
diff --git a/app/views/projects/index.html.haml b/app/views/projects/index.html.haml index 888a72b6..4b9457c1 100644 --- a/app/views/projects/index.html.haml +++ b/app/views/projects/index.html.haml @@ -3,7 +3,7 @@ = render "tile" %div{:class => "list", :style => view_mode_style("list")} = render "list" -- else +- else %center.prepend-top %h2 %cite Nothing here diff --git a/app/views/projects/tree.js.haml b/app/views/projects/tree.js.haml index 60cbd199..eb08adb1 100644 --- a/app/views/projects/tree.js.haml +++ b/app/views/projects/tree.js.haml @@ -1,5 +1,5 @@ :plain - $("#tree-holder table").hide("slide", { direction: "left" }, 150, function(){ + $("#tree-holder table").hide("slide", { direction: "left" }, 150, function(){ $("#tree-holder").html("#{escape_javascript(render(:partial => "tree", :locals => {:repo => @repo, :commit => @commit, :tree => @tree}))}"); $("#tree-holder table").show("slide", { direction: "right" }, 150); }); diff --git a/app/views/projects/wall.html.haml b/app/views/projects/wall.html.haml index ed22478c..63c9613a 100644 --- a/app/views/projects/wall.html.haml +++ b/app/views/projects/wall.html.haml @@ -20,7 +20,7 @@ %hr = render "notes/notes" -:javascript +:javascript $(function(){ $("#note_note").live("click", function(){ $(this).css("height", "100px"); diff --git a/app/views/projects/wall.js.haml b/app/views/projects/wall.js.haml index 5b9a34c0..ae2ff32c 100644 --- a/app/views/projects/wall.js.haml +++ b/app/views/projects/wall.js.haml @@ -1,2 +1,2 @@ -:plain +:plain $("#notes-list").html("#{escape_javascript(render(:partial => 'notes/notes_list'))}"); diff --git a/app/views/snippets/_form.html.haml b/app/views/snippets/_form.html.haml index 571e2b06..7a34ae8e 100644 --- a/app/views/snippets/_form.html.haml +++ b/app/views/snippets/_form.html.haml @@ -17,6 +17,6 @@ = f.label :content, "Code" %br = f.text_area :content, :style => "height:240px;width:932px;" - + .actions.prepend-top = f.submit 'Save', :class => "lbutton vm" diff --git a/app/views/snippets/index.html.haml b/app/views/snippets/index.html.haml index 6e5dbde5..fe5e6170 100644 --- a/app/views/snippets/index.html.haml +++ b/app/views/snippets/index.html.haml @@ -10,5 +10,5 @@ %th = render @snippets :javascript - $('.delete-snippet').live('ajax:success', function() { - $(this).closest('tr').fadeOut(); }); + $('.delete-snippet').live('ajax:success', function() { + $(this).closest('tr').fadeOut(); }); diff --git a/app/views/team_members/_show.html.haml b/app/views/team_members/_show.html.haml index b9a68e6c..88260cca 100644 --- a/app/views/team_members/_show.html.haml +++ b/app/views/team_members/_show.html.haml @@ -7,11 +7,11 @@ %td= truncate user.email, :lenght => 16 - if can? current_user, :admin_project, @project - = form_for(member, :as => :team_member, :url => project_team_member_path(@project, member)) do |f| + = form_for(member, :as => :team_member, :url => project_team_member_path(@project, member)) do |f| %td= f.check_box :read, :onclick => "$(this.form).submit();" %td= f.check_box :write, :onclick => "$(this.form).submit();" %td= f.check_box :admin, :onclick => "$(this.form).submit();" - - else + - else %td= check_box_tag "read", 1, member.read, :disabled => :disabled %td= check_box_tag "commit", 1, member.write, :disabled => :disabled %td= check_box_tag "admin", 1, member.admin, :disabled => :disabled diff --git a/app/views/team_members/show.html.haml b/app/views/team_members/show.html.haml index d07c54f8..4a093ee1 100644 --- a/app/views/team_members/show.html.haml +++ b/app/views/team_members/show.html.haml @@ -25,4 +25,3 @@ %b Twitter: = user.twitter - diff --git a/config/environments/production.rb b/config/environments/production.rb index 7ebe4523..d8094817 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -58,7 +58,6 @@ Gitlab::Application.configure do # Send deprecation notices to registered listeners config.active_support.deprecation = :notify - config.action_mailer.delivery_method = :sendmail # Defaults to: # # config.action_mailer.sendmail_settings = { diff --git a/config/initializers/grit_ext.rb b/config/initializers/grit_ext.rb index 9231da6f..1a7e6361 100644 --- a/config/initializers/grit_ext.rb +++ b/config/initializers/grit_ext.rb @@ -7,6 +7,6 @@ Grit::Blob.class_eval do include Utils::Colorize end -Grit::Commit.class_eval do +Grit::Commit.class_eval do include CommitExt end diff --git a/config/routes.rb b/config/routes.rb index 57879224..5f95e113 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,5 @@ Gitlab::Application.routes.draw do - namespace :admin do + namespace :admin do resources :users resources :projects resources :team_members @@ -10,7 +10,7 @@ Gitlab::Application.routes.draw do root :to => "users#index" end - get "errors/gitosis" + get "errors/gitosis" get "profile/password", :to => "profile#password" put "profile/password", :to => "profile#password_update" put "profile/edit", :to => "profile#social_update" @@ -21,8 +21,8 @@ Gitlab::Application.routes.draw do resources :keys devise_for :users - resources :projects, :except => [:new, :create, :index], :path => "/" do - member do + resources :projects, :except => [:new, :create, :index], :path => "/" do + member do get "tree" get "blob" get "team" @@ -32,7 +32,7 @@ Gitlab::Application.routes.draw do get "tree/:commit_id" => "projects#tree" get "tree/:commit_id/:path" => "projects#tree", :as => :tree_file, - :constraints => { + :constraints => { :id => /[a-zA-Z0-9_\-]+/, :commit_id => /[a-zA-Z0-9]+/, :path => /.*/ diff --git a/db/migrate/20110913200833_devise_create_users.rb b/db/migrate/20110913200833_devise_create_users.rb index 3083e742..01869a9e 100644 --- a/db/migrate/20110913200833_devise_create_users.rb +++ b/db/migrate/20110913200833_devise_create_users.rb @@ -11,7 +11,6 @@ class DeviseCreateUsers < ActiveRecord::Migration # t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both # t.token_authenticatable - t.timestamps end diff --git a/lib/color.rb b/lib/color.rb index 23feecf4..4eabe249 100644 --- a/lib/color.rb +++ b/lib/color.rb @@ -17,7 +17,7 @@ module Color def command(string) `#{string}` - if $?.to_i > 0 + if $?.to_i > 0 puts red " == #{string} - FAIL" puts red " == Error during configure" exit diff --git a/lib/commit_ext.rb b/lib/commit_ext.rb index e09dbdaf..411809f0 100644 --- a/lib/commit_ext.rb +++ b/lib/commit_ext.rb @@ -1,11 +1,11 @@ module CommitExt def safe_message - message.encode("UTF-8", - :invalid => :replace, - :undef => :replace, + message.encode("UTF-8", + :invalid => :replace, + :undef => :replace, :universal_newline => true, :replace => "") - rescue + rescue "-- invalid encoding for commit message" end end diff --git a/lib/file_size_validator.rb b/lib/file_size_validator.rb index 151e0ce5..611e584f 100644 --- a/lib/file_size_validator.rb +++ b/lib/file_size_validator.rb @@ -33,7 +33,7 @@ class FileSizeValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) raise(ArgumentError, "A CarrierWave::Uploader::Base object was expected") unless value.kind_of? CarrierWave::Uploader::Base - + value = (options[:tokenizer] || DEFAULT_TOKENIZER).call(value) if value.kind_of?(String) CHECKS.each do |key, validity_check| @@ -53,7 +53,7 @@ class FileSizeValidator < ActiveModel::EachValidator record.errors.add(attribute, MESSAGES[key], errors_options) end end - + def help Helper.instance end diff --git a/lib/utils.rb b/lib/utils.rb index e57121a3..f43e2edd 100644 --- a/lib/utils.rb +++ b/lib/utils.rb @@ -1,8 +1,8 @@ module Utils module FileHelper - def binary?(string) + def binary?(string) string.each_byte do |x| - x.nonzero? or return true + x.nonzero? or return true end false end diff --git a/public/index.html.example b/public/index.html.example index 9d9811a5..16248eda 100644 --- a/public/index.html.example +++ b/public/index.html.example @@ -25,7 +25,6 @@ text-decoration: none; } - #page { background-color: #f0f0f0; width: 750px; @@ -57,7 +56,6 @@ padding-right: 30px; } - #header { background-image: url("/assets/rails.png"); background-repeat: no-repeat; @@ -71,7 +69,6 @@ font-size: 16px; } - #about h3 { margin: 0; margin-bottom: 10px; @@ -112,7 +109,6 @@ padding: 10px; } - #getting-started { border-top: 1px solid #ccc; margin-top: 25px; @@ -149,7 +145,6 @@ font-size: 13px; } - #sidebar ul { margin-left: 0; padding-left: 0; diff --git a/spec/factory.rb b/spec/factory.rb index 29e552b1..5edef358 100644 --- a/spec/factory.rb +++ b/spec/factory.rb @@ -1,7 +1,7 @@ class Factory @factories = {} - class << self + class << self def add(name, klass, &block) @factories[name] = [klass, block] end @@ -13,10 +13,10 @@ class Factory def new(name, opts) factory = @factories[name] factory[0].new.tap do |obj| - factory[1].call(obj) + factory[1].call(obj) end.tap do |obj| opts.each do |k, opt| - obj.send("#{k}=", opt) + obj.send("#{k}=", opt) end end end diff --git a/spec/models/issue_spec.rb b/spec/models/issue_spec.rb index b2d594c9..e0559ab6 100644 --- a/spec/models/issue_spec.rb +++ b/spec/models/issue_spec.rb @@ -14,7 +14,7 @@ describe Issue do it { should validate_presence_of(:assignee_id) } end - describe "Scope" do + describe "Scope" do it { Issue.should respond_to :closed } it { Issue.should respond_to :opened } end diff --git a/spec/models/key_spec.rb b/spec/models/key_spec.rb index 8515f19b..6522b825 100644 --- a/spec/models/key_spec.rb +++ b/spec/models/key_spec.rb @@ -10,7 +10,7 @@ describe Key do it { should validate_presence_of(:key) } end - describe "Methods" do + describe "Methods" do it { should respond_to :projects } end diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb index 20bd41ad..5b16ad36 100644 --- a/spec/models/note_spec.rb +++ b/spec/models/note_spec.rb @@ -13,8 +13,8 @@ describe Note do it { Factory.create(:note, :project => Factory.create(:project)).should be_valid } - describe :authorization do - before do + describe :authorization do + before do @p1 = Factory :project @p2 = Factory :project, :code => "alien", :path => "legit_1" @u1 = Factory :user @@ -24,10 +24,10 @@ describe Note do @abilities << Ability end - describe :read do - before do - @p1.users_projects.create(:user => @u1, :read => false) - @p1.users_projects.create(:user => @u2, :read => true) + describe :read do + before do + @p1.users_projects.create(:user => @u1, :read => false) + @p1.users_projects.create(:user => @u2, :read => true) @p2.users_projects.create(:user => @u3, :read => true) end @@ -36,11 +36,11 @@ describe Note do it { @abilities.allowed?(@u3, :read_note, @p1).should be_false } end - describe :write do - before do - @p1.users_projects.create(:user => @u1, :write => false) - @p1.users_projects.create(:user => @u2, :write => true) - @p2.users_projects.create(:user => @u3, :write => true) + describe :write do + before do + @p1.users_projects.create(:user => @u1, :write => false) + @p1.users_projects.create(:user => @u2, :write => true) + @p2.users_projects.create(:user => @u3, :write => true) end it { @abilities.allowed?(@u1, :write_note, @p1).should be_false } @@ -48,11 +48,11 @@ describe Note do it { @abilities.allowed?(@u3, :write_note, @p1).should be_false } end - describe :admin do - before do - @p1.users_projects.create(:user => @u1, :admin => false) - @p1.users_projects.create(:user => @u2, :admin => true) - @p2.users_projects.create(:user => @u3, :admin => true) + describe :admin do + before do + @p1.users_projects.create(:user => @u1, :admin => false) + @p1.users_projects.create(:user => @u2, :admin => true) + @p2.users_projects.create(:user => @u3, :admin => true) end it { @abilities.allowed?(@u1, :admin_note, @p1).should be_false } diff --git a/spec/models/project_security_spec.rb b/spec/models/project_security_spec.rb index 8eb8ee80..f8029463 100644 --- a/spec/models/project_security_spec.rb +++ b/spec/models/project_security_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' describe Project do - describe :authorization do - before do + describe :authorization do + before do @p1 = Factory :project @u1 = Factory :user @u2 = Factory :user @@ -10,30 +10,30 @@ describe Project do @abilities << Ability end - describe :read do - before do - @p1.users_projects.create(:project => @p1, :user => @u1, :read => false) - @p1.users_projects.create(:project => @p1, :user => @u2, :read => true) + describe :read do + before do + @p1.users_projects.create(:project => @p1, :user => @u1, :read => false) + @p1.users_projects.create(:project => @p1, :user => @u2, :read => true) end it { @abilities.allowed?(@u1, :read_project, @p1).should be_false } it { @abilities.allowed?(@u2, :read_project, @p1).should be_true } end - describe :write do - before do - @p1.users_projects.create(:project => @p1, :user => @u1, :write => false) - @p1.users_projects.create(:project => @p1, :user => @u2, :write => true) + describe :write do + before do + @p1.users_projects.create(:project => @p1, :user => @u1, :write => false) + @p1.users_projects.create(:project => @p1, :user => @u2, :write => true) end it { @abilities.allowed?(@u1, :write_project, @p1).should be_false } it { @abilities.allowed?(@u2, :write_project, @p1).should be_true } end - describe :admin do - before do - @p1.users_projects.create(:project => @p1, :user => @u1, :admin => false) - @p1.users_projects.create(:project => @p1, :user => @u2, :admin => true) + describe :admin do + before do + @p1.users_projects.create(:project => @p1, :user => @u1, :admin => false) + @p1.users_projects.create(:project => @p1, :user => @u2, :admin => true) end it { @abilities.allowed?(@u1, :admin_project, @p1).should be_false } diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 0c62743d..7bce57e8 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -40,20 +40,20 @@ describe Project do should_not allow_value("gitosis-admin").for(:path) end - it "should return valid url to repo" do + it "should return valid url to repo" do project = Project.new(:path => "somewhere") project.url_to_repo.should == "git@localhost:somewhere.git" end - it "should return path to repo" do + it "should return path to repo" do project = Project.new(:path => "somewhere") project.path_to_repo.should == File.join(Rails.root, "tmp", "tests", "somewhere") end - describe :valid_repo? do - it "should be valid repo" do + describe :valid_repo? do + it "should be valid repo" do project = Factory :project - project.valid_repo?.should be_true + project.valid_repo?.should be_true end it "should be invalid repo" do @@ -62,43 +62,43 @@ describe Project do end end - describe "Git methods" do + describe "Git methods" do let(:project) { Factory :project } - describe :repo do - it "should return valid repo" do + describe :repo do + it "should return valid repo" do project.repo.should be_kind_of(Grit::Repo) end - it "should return nil" do + it "should return nil" do lambda { Project.new(:path => "invalid").repo }.should raise_error(Grit::NoSuchPathError) end - it "should return nil" do + it "should return nil" do lambda { Project.new.repo }.should raise_error(TypeError) end end - describe :commit do - it "should return first head commit if without params" do + describe :commit do + it "should return first head commit if without params" do project.commit.id.should == project.repo.commits.first.id end - it "should return valid commit" do + it "should return valid commit" do project.commit(ValidCommit::ID).should be_valid_commit end - it "should return nil" do + it "should return nil" do project.commit("+123_4532530XYZ").should be_nil end end - describe :tree do - before do + describe :tree do + before do @commit = project.commit(ValidCommit::ID) end - it "should raise error w/o arguments" do + it "should raise error w/o arguments" do lambda { project.tree }.should raise_error end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 32fb90a3..d66b1c25 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -14,7 +14,7 @@ describe User do it { should respond_to(:name) } end - it "should return valid identifier" do + it "should return valid identifier" do user = User.new(:email => "test@mail.com") user.identifier.should == "test_mail.com" end diff --git a/spec/models/users_project_spec.rb b/spec/models/users_project_spec.rb index d6a4d02b..c1539161 100644 --- a/spec/models/users_project_spec.rb +++ b/spec/models/users_project_spec.rb @@ -11,7 +11,7 @@ describe UsersProject do it { should validate_presence_of(:project_id) } end - describe "Delegate methods" do + describe "Delegate methods" do it { should respond_to(:user_name) } it { should respond_to(:user_email) } end diff --git a/spec/monkeypatch.rb b/spec/monkeypatch.rb index ea42337f..2e491496 100644 --- a/spec/monkeypatch.rb +++ b/spec/monkeypatch.rb @@ -1,6 +1,6 @@ # Stubbing Project <-> gitosis path # create project using Factory only -class Project +class Project def update_gitosis_project true end @@ -9,12 +9,12 @@ class Project true end - def path_to_repo + def path_to_repo File.join(Rails.root, "tmp", "tests", path) end end -class Key +class Key def update_gitosis true end diff --git a/spec/requests/admin/admin_projects_spec.rb b/spec/requests/admin/admin_projects_spec.rb index e36ee441..fd8703ec 100644 --- a/spec/requests/admin/admin_projects_spec.rb +++ b/spec/requests/admin/admin_projects_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe "Admin::Projects" do - before do + before do @project = Factory :project, :name => "LeGiT", :code => "LGT" @@ -9,7 +9,7 @@ describe "Admin::Projects" do end describe "GET /admin/projects" do - before do + before do visit admin_projects_path end @@ -17,49 +17,49 @@ describe "Admin::Projects" do current_path.should == admin_projects_path end - it "should have projects list" do + it "should have projects list" do page.should have_content(@project.code) page.should have_content(@project.name) end end - describe "GET /admin/projects/:id" do - before do + describe "GET /admin/projects/:id" do + before do visit admin_projects_path click_link "Show" end - it "should have project info" do + it "should have project info" do page.should have_content(@project.code) page.should have_content(@project.name) end end - describe "GET /admin/projects/:id/edit" do - before do + describe "GET /admin/projects/:id/edit" do + before do visit admin_projects_path click_link "edit_project_#{@project.id}" end - it "should have project edit page" do + it "should have project edit page" do page.should have_content("Name") page.should have_content("Code") end describe "Update project" do - before do + before do fill_in "project_name", :with => "Big Bang" fill_in "project_code", :with => "BB1" click_button "Save" @project.reload end - it "should show page with new data" do + it "should show page with new data" do page.should have_content("BB1") page.should have_content("Big Bang") end - it "should change project entry" do + it "should change project entry" do @project.name.should == "Big Bang" @project.code.should == "BB1" end @@ -67,24 +67,24 @@ describe "Admin::Projects" do end describe "GET /admin/projects/new" do - before do + before do visit admin_projects_path click_link "New Project" end it "should be correct path" do - current_path.should == new_admin_project_path + current_path.should == new_admin_project_path end it "should have labels for new project" do - page.should have_content("Name") - page.should have_content("Path") - page.should have_content("Description") + page.should have_content("Name") + page.should have_content("Path") + page.should have_content("Description") end end describe "POST /admin/projects" do - before do + before do visit new_admin_project_path fill_in 'Name', :with => 'NewProject' fill_in 'Code', :with => 'NPR' diff --git a/spec/requests/admin/admin_users_spec.rb b/spec/requests/admin/admin_users_spec.rb index 8d9cbcae..67cfde5f 100644 --- a/spec/requests/admin/admin_users_spec.rb +++ b/spec/requests/admin/admin_users_spec.rb @@ -4,7 +4,7 @@ describe "Admin::Users" do before { login_as :admin } describe "GET /admin/users" do - before do + before do visit admin_users_path end @@ -12,14 +12,14 @@ describe "Admin::Users" do current_path.should == admin_users_path end - it "should have users list" do + it "should have users list" do page.should have_content(@user.email) page.should have_content(@user.name) end end - describe "GET /admin/users/new" do - before do + describe "GET /admin/users/new" do + before do @password = "123ABC" visit new_admin_user_path fill_in "user_name", :with => "Big Bang" @@ -28,23 +28,23 @@ describe "Admin::Users" do fill_in "user_password_confirmation", :with => @password end - it "should create new user" do + it "should create new user" do expect { click_button "Save" }.to change {User.count}.by(1) end - it "should create user with valid data" do + it "should create user with valid data" do click_button "Save" user = User.last user.name.should == "Big Bang" user.email.should == "bigbang@mail.com" end - it "should call send mail" do + it "should call send mail" do Notify.should_receive(:new_user_email).and_return(stub(:deliver => true)) click_button "Save" end - it "should send valid email to user with email & password" do + it "should send valid email to user with email & password" do click_button "Save" user = User.last email = ActionMailer::Base.deliveries.last @@ -54,45 +54,45 @@ describe "Admin::Users" do end end - describe "GET /admin/users/:id" do - before do + describe "GET /admin/users/:id" do + before do visit admin_users_path click_link "Show" end - it "should have user info" do + it "should have user info" do page.should have_content(@user.email) page.should have_content(@user.name) page.should have_content(@user.is_admin?) end end - describe "GET /admin/users/:id/edit" do - before do + describe "GET /admin/users/:id/edit" do + before do @simple_user = Factory :user visit admin_users_path click_link "edit_user_#{@simple_user.id}" end - it "should have user edit page" do + it "should have user edit page" do page.should have_content("Name") page.should have_content("Password") end describe "Update user" do - before do + before do fill_in "user_name", :with => "Big Bang" fill_in "user_email", :with => "bigbang@mail.com" check "user_admin" click_button "Save" end - it "should show page with new data" do + it "should show page with new data" do page.should have_content("bigbang@mail.com") page.should have_content("Big Bang") end - it "should change user entry" do + it "should change user entry" do @simple_user.reload @simple_user.name.should == "Big Bang" @simple_user.is_admin?.should be_true diff --git a/spec/requests/admin/security_spec.rb b/spec/requests/admin/security_spec.rb index 743f9f08..27b60196 100644 --- a/spec/requests/admin/security_spec.rb +++ b/spec/requests/admin/security_spec.rb @@ -1,25 +1,25 @@ require 'spec_helper' describe "Admin::Projects" do - describe "GET /admin/projects" do + describe "GET /admin/projects" do it { admin_projects_path.should be_allowed_for :admin } it { admin_projects_path.should be_denied_for :user } it { admin_projects_path.should be_denied_for :visitor } end - describe "GET /admin/users" do + describe "GET /admin/users" do it { admin_users_path.should be_allowed_for :admin } it { admin_users_path.should be_denied_for :user } it { admin_users_path.should be_denied_for :visitor } end - describe "GET /admin/team_members" do + describe "GET /admin/team_members" do it { admin_team_members_path.should be_allowed_for :admin } it { admin_team_members_path.should be_denied_for :user } it { admin_team_members_path.should be_denied_for :visitor } end - describe "GET /admin/emails" do + describe "GET /admin/emails" do it { admin_emails_path.should be_allowed_for :admin } it { admin_emails_path.should be_denied_for :user } it { admin_emails_path.should be_denied_for :visitor } diff --git a/spec/requests/commits_notes_spec.rb b/spec/requests/commits_notes_spec.rb index 522fe518..c424f4fc 100644 --- a/spec/requests/commits_notes_spec.rb +++ b/spec/requests/commits_notes_spec.rb @@ -4,13 +4,13 @@ describe "Issues" do let(:project) { Factory :project } let!(:commit) { project.repo.commits.first } - before do + before do login_as :user project.add_access(@user, :read, :write) end - describe "add new note", :js => true do - before do + describe "add new note", :js => true do + before do visit project_commit_path(project, commit) click_link "Comments" # notes tab fill_in "note_note", :with => "I commented this commit" diff --git a/spec/requests/commits_spec.rb b/spec/requests/commits_spec.rb index cd7314f9..79bb03f5 100644 --- a/spec/requests/commits_spec.rb +++ b/spec/requests/commits_spec.rb @@ -3,13 +3,13 @@ require 'spec_helper' describe "Commits" do let(:project) { Factory :project } let!(:commit) { project.repo.commits.first } - before do + before do login_as :user project.add_access(@user, :read) end describe "GET /commits" do - before do + before do visit project_commits_path(project) end @@ -17,22 +17,22 @@ describe "Commits" do current_path.should == project_commits_path(project) end - it "should have project name" do + it "should have project name" do page.should have_content(project.name) end - it "should list commits" do + it "should list commits" do page.should have_content(commit.author) page.should have_content(commit.message) end end - describe "GET /commits/:id" do - before do + describe "GET /commits/:id" do + before do visit project_commit_path(project, commit) end - it "should have valid path" do + it "should have valid path" do current_path.should == project_commit_path(project, commit) end end diff --git a/spec/requests/issues_notes_spec.rb b/spec/requests/issues_notes_spec.rb index 95eb2f35..9ebad394 100644 --- a/spec/requests/issues_notes_spec.rb +++ b/spec/requests/issues_notes_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe "Issues" do let(:project) { Factory :project } - before do + before do login_as :user project.add_access(@user, :read, :write) @@ -13,8 +13,8 @@ describe "Issues" do :project => project end - describe "add new note", :js => true do - before do + describe "add new note", :js => true do + before do visit project_issue_path(project, @issue) fill_in "note_note", :with => "I commented this issue" click_button "Add note" diff --git a/spec/requests/issues_spec.rb b/spec/requests/issues_spec.rb index b7f4d411..184f8293 100644 --- a/spec/requests/issues_spec.rb +++ b/spec/requests/issues_spec.rb @@ -3,13 +3,13 @@ require 'spec_helper' describe "Issues" do let(:project) { Factory :project } - before do + before do login_as :user project.add_access(@user, :read, :write) end describe "GET /issues" do - before do + before do @issue = Factory :issue, :author => @user, :assignee => @user, @@ -24,23 +24,23 @@ describe "Issues" do it { should have_content(@issue.project.name) } it { should have_content(@issue.assignee.name) } - describe "Destroy" do - before do + describe "Destroy" do + before do # admin access to remove issue @user.users_projects.destroy_all project.add_access(@user, :read, :write, :admin) visit project_issues_path(project) end - it "should remove entry" do + it "should remove entry" do expect { click_link "destroy_issue_#{@issue.id}" }.to change { Issue.count }.by(-1) end end - describe "statuses", :js => true do - before do + describe "statuses", :js => true do + before do @closed_issue = Factory :issue, :author => @user, :assignee => @user, @@ -48,18 +48,18 @@ describe "Issues" do :closed => true end - it "should show only open" do + it "should show only open" do should have_content(@issue.title) should have_no_content(@closed_issue.title) end - it "should show only closed" do + it "should show only closed" do choose "closed_issues" should have_no_content(@issue.title) should have_content(@closed_issue.title) end - it "should show all" do + it "should show all" do choose "all_issues" should have_content(@issue.title) should have_content(@closed_issue.title) @@ -67,17 +67,17 @@ describe "Issues" do end end - describe "New issue", :js => true do - before do + describe "New issue", :js => true do + before do visit project_issues_path(project) click_link "New Issue" end - it "should open new issue popup" do + it "should open new issue popup" do page.should have_content("Add new issue") end - describe "fill in" do + describe "fill in" do before do fill_in "issue_title", :with => "bug 345" fill_in "issue_content", :with => "app bug 345" @@ -87,7 +87,7 @@ describe "Issues" do it { expect { click_button "Save" }.to change {Issue.count}.by(1) } - it "should add new issue to table" do + it "should add new issue to table" do click_button "Save" page.should_not have_content("Add new issue") @@ -96,12 +96,12 @@ describe "Issues" do page.should have_content project.name end - it "should call send mail" do + it "should call send mail" do Notify.should_receive(:new_issue_email).and_return(stub(:deliver => true)) click_button "Save" end - it "should send valid email to user with email & password" do + it "should send valid email to user with email & password" do click_button "Save" issue = Issue.last email = ActionMailer::Base.deliveries.last @@ -112,8 +112,8 @@ describe "Issues" do end end - describe "Edit issue", :js => true do - before do + describe "Edit issue", :js => true do + before do @issue = Factory :issue, :author => @user, :assignee => @user, @@ -122,11 +122,11 @@ describe "Issues" do click_link "Edit" end - it "should open new issue popup" do + it "should open new issue popup" do page.should have_content("Issue ##{@issue.id}") end - describe "fill in" do + describe "fill in" do before do fill_in "issue_title", :with => "bug 345" fill_in "issue_content", :with => "app bug 345" @@ -134,7 +134,7 @@ describe "Issues" do it { expect { click_button "Save" }.to_not change {Issue.count} } - it "should update issue fields" do + it "should update issue fields" do click_button "Save" page.should_not have_content("Issue ##{@issue.id}") diff --git a/spec/requests/keys_spec.rb b/spec/requests/keys_spec.rb index 316115f9..6ce22b30 100644 --- a/spec/requests/keys_spec.rb +++ b/spec/requests/keys_spec.rb @@ -1,12 +1,12 @@ require 'spec_helper' describe "Issues" do - before do + before do login_as :user end describe "GET /keys" do - before do + before do @key = Factory :key, :user => @user visit keys_path end @@ -15,8 +15,8 @@ describe "Issues" do it { should have_content(@key.title) } - describe "Destroy" do - it "should remove entry" do + describe "Destroy" do + it "should remove entry" do expect { click_link "destroy_key_#{@key.id}" }.to change { @user.keys.count }.by(-1) @@ -24,17 +24,17 @@ describe "Issues" do end end - describe "New key", :js => true do - before do + describe "New key", :js => true do + before do visit keys_path click_link "Add new" end - it "should open new key popup" do + it "should open new key popup" do page.should have_content("Add new public key") end - describe "fill in" do + describe "fill in" do before do fill_in "key_title", :with => "laptop" fill_in "key_key", :with => "publickey234=" @@ -42,7 +42,7 @@ describe "Issues" do it { expect { click_button "Save" }.to change {Key.count}.by(1) } - it "should add new key to table" do + it "should add new key to table" do click_button "Save" page.should_not have_content("Add new public key") diff --git a/spec/requests/profile_spec.rb b/spec/requests/profile_spec.rb index 5838f63b..eca1c12e 100644 --- a/spec/requests/profile_spec.rb +++ b/spec/requests/profile_spec.rb @@ -1,12 +1,12 @@ require 'spec_helper' describe "Profile" do - before do + before do login_as :user end describe "Show profile" do - before do + before do visit profile_path end @@ -15,13 +15,13 @@ describe "Profile" do end describe "Profile update" do - before do + before do visit profile_path fill_in "user_skype", :with => "testskype" - fill_in "user_linkedin", :with => "testlinkedin" + fill_in "user_linkedin", :with => "testlinkedin" fill_in "user_twitter", :with => "testtwitter" click_button "Save" - @user.reload + @user.reload end it { @user.skype.should == 'testskype' } @@ -29,18 +29,17 @@ describe "Profile" do it { @user.twitter.should == 'testtwitter' } end - describe "Password update" do - before do + before do visit profile_password_path end it { page.should have_content("Password") } it { page.should have_content("Password confirmation") } - describe "change password" do - before do - @old_pwd = @user.encrypted_password + describe "change password" do + before do + @old_pwd = @user.encrypted_password fill_in "user_password", :with => "777777" fill_in "user_password_confirmation", :with => "777777" click_button "Save" @@ -51,18 +50,18 @@ describe "Profile" do current_path.should == new_user_session_path end - it "should change password" do + it "should change password" do @user.encrypted_password.should_not == @old_pwd end - describe "login with new password" do + describe "login with new password" do before do fill_in "user_email", :with => @user.email fill_in "user_password", :with => "777777" click_button "Sign in" end - - it "should login user" do + + it "should login user" do current_path.should == root_path end end diff --git a/spec/requests/projects_security_spec.rb b/spec/requests/projects_security_spec.rb index 90f88d88..1d42c5e7 100644 --- a/spec/requests/projects_security_spec.rb +++ b/spec/requests/projects_security_spec.rb @@ -1,33 +1,33 @@ require 'spec_helper' describe "Projects" do - describe "GET /projects" do + describe "GET /projects" do it { projects_path.should be_allowed_for :admin } it { projects_path.should be_allowed_for :user } it { projects_path.should be_denied_for :visitor } end - describe "GET /projects/new" do + describe "GET /projects/new" do it { projects_path.should be_allowed_for :admin } it { projects_path.should be_allowed_for :user } it { projects_path.should be_denied_for :visitor } end describe "Project" do - before do + before do @project = Factory :project @u1 = Factory :user @u2 = Factory :user @u3 = Factory :user # full access - @project.users_projects.create(:user => @u1, :read => true, :write => true, :admin => true) + @project.users_projects.create(:user => @u1, :read => true, :write => true, :admin => true) # no access - @project.users_projects.create(:user => @u2, :read => false, :write => false, :admin => false) + @project.users_projects.create(:user => @u2, :read => false, :write => false, :admin => false) # readonly - @project.users_projects.create(:user => @u3, :read => true, :write => false, :admin => false) + @project.users_projects.create(:user => @u3, :read => true, :write => false, :admin => false) end - describe "GET /project_code" do + describe "GET /project_code" do it { project_path(@project).should be_allowed_for @u1 } it { project_path(@project).should be_allowed_for @u3 } it { project_path(@project).should be_denied_for :admin } @@ -36,7 +36,7 @@ describe "Projects" do it { project_path(@project).should be_denied_for :visitor } end - describe "GET /project_code/tree" do + describe "GET /project_code/tree" do it { tree_project_path(@project).should be_allowed_for @u1 } it { tree_project_path(@project).should be_allowed_for @u3 } it { tree_project_path(@project).should be_denied_for :admin } @@ -45,7 +45,7 @@ describe "Projects" do it { tree_project_path(@project).should be_denied_for :visitor } end - describe "GET /project_code/commits" do + describe "GET /project_code/commits" do it { project_commits_path(@project).should be_allowed_for @u1 } it { project_commits_path(@project).should be_allowed_for @u3 } it { project_commits_path(@project).should be_denied_for :admin } @@ -54,7 +54,7 @@ describe "Projects" do it { project_commits_path(@project).should be_denied_for :visitor } end - describe "GET /project_code/commit" do + describe "GET /project_code/commit" do it { project_commit_path(@project, @project.commit).should be_allowed_for @u1 } it { project_commit_path(@project, @project.commit).should be_allowed_for @u3 } it { project_commit_path(@project, @project.commit).should be_denied_for :admin } @@ -63,7 +63,7 @@ describe "Projects" do it { project_commit_path(@project, @project.commit).should be_denied_for :visitor } end - describe "GET /project_code/team" do + describe "GET /project_code/team" do it { team_project_path(@project).should be_allowed_for @u1 } it { team_project_path(@project).should be_allowed_for @u3 } it { team_project_path(@project).should be_denied_for :admin } @@ -72,7 +72,7 @@ describe "Projects" do it { team_project_path(@project).should be_denied_for :visitor } end - describe "GET /project_code/wall" do + describe "GET /project_code/wall" do it { wall_project_path(@project).should be_allowed_for @u1 } it { wall_project_path(@project).should be_allowed_for @u3 } it { wall_project_path(@project).should be_denied_for :admin } @@ -81,8 +81,8 @@ describe "Projects" do it { wall_project_path(@project).should be_denied_for :visitor } end - describe "GET /project_code/blob" do - before do + describe "GET /project_code/blob" do + before do @commit = @project.commit @path = @commit.tree.contents.select { |i| i.is_a?(Grit::Blob)}.first.name @blob_path = blob_project_path(@project, :commit_id => @commit.id, :path => @path) @@ -96,7 +96,7 @@ describe "Projects" do it { @blob_path.should be_denied_for :visitor } end - describe "GET /project_code/edit" do + describe "GET /project_code/edit" do it { edit_project_path(@project).should be_allowed_for @u1 } it { edit_project_path(@project).should be_denied_for @u3 } it { edit_project_path(@project).should be_denied_for :admin } @@ -105,7 +105,7 @@ describe "Projects" do it { edit_project_path(@project).should be_denied_for :visitor } end - describe "GET /project_code/issues" do + describe "GET /project_code/issues" do it { project_issues_path(@project).should be_allowed_for @u1 } it { project_issues_path(@project).should be_allowed_for @u3 } it { project_issues_path(@project).should be_denied_for :admin } @@ -114,7 +114,7 @@ describe "Projects" do it { project_issues_path(@project).should be_denied_for :visitor } end - describe "GET /project_code/snippets" do + describe "GET /project_code/snippets" do it { project_snippets_path(@project).should be_allowed_for @u1 } it { project_snippets_path(@project).should be_allowed_for @u3 } it { project_snippets_path(@project).should be_denied_for :admin } diff --git a/spec/requests/projects_spec.rb b/spec/requests/projects_spec.rb index 945c1ea2..e1e9773c 100644 --- a/spec/requests/projects_spec.rb +++ b/spec/requests/projects_spec.rb @@ -4,38 +4,38 @@ describe "Projects" do before { login_as :user } describe "GET /projects" do - before do + before do visit projects_path end it "should be on projects page" do - current_path.should == projects_path + current_path.should == projects_path end it "should have link to new project" do - page.should have_content("New Project") + page.should have_content("New Project") end end describe "GET /projects/new" do - before do + before do visit projects_path click_link "New Project" end it "should be correct path" do - current_path.should == new_project_path + current_path.should == new_project_path end it "should have labels for new project" do - page.should have_content("Name") - page.should have_content("Path") - page.should have_content("Description") + page.should have_content("Name") + page.should have_content("Path") + page.should have_content("Description") end end describe "POST /projects" do - before do + before do visit new_project_path fill_in 'Name', :with => 'NewProject' fill_in 'Code', :with => 'NPR' @@ -61,7 +61,7 @@ describe "Projects" do end describe "GET /projects/show" do - before do + before do @project = Factory :project @project.add_access(@user, :read) @@ -72,14 +72,14 @@ describe "Projects" do current_path.should == project_path(@project) end - it "should beahave like dashboard" do + it "should beahave like dashboard" do page.should have_content("History") end end describe "GET /projects/team" do - before do + before do @project = Factory :project @project.add_access(@user, :read) @@ -92,13 +92,13 @@ describe "Projects" do current_path.should == team_project_path(@project) end - it "should have as as team member" do + it "should have as as team member" do page.should have_content(@user.name) end end describe "GET /projects/:id/edit" do - before do + before do @project = Factory :project @project.add_access(@user, :admin, :read) @@ -110,14 +110,14 @@ describe "Projects" do end it "should have labels for new project" do - page.should have_content("Name") - page.should have_content("Path") - page.should have_content("Description") + page.should have_content("Name") + page.should have_content("Path") + page.should have_content("Description") end end describe "PUT /projects/:id" do - before do + before do @project = Factory :project @project.add_access(@user, :admin, :read) @@ -140,14 +140,14 @@ describe "Projects" do end #describe "DELETE /projects/:id", :js => true do - #before do + #before do #@project = Factory :project #@project.add_access(@user, :read, :admin) #visit projects_path #end #it "should be correct path" do - #expect { click_link "Destroy" }.to change {Project.count}.by(1) + #expect { click_link "Destroy" }.to change {Project.count}.by(1) #end #end end diff --git a/spec/requests/projects_tree_perfomance_spec.rb b/spec/requests/projects_tree_perfomance_spec.rb index 5b4facb1..bf3ca167 100644 --- a/spec/requests/projects_tree_perfomance_spec.rb +++ b/spec/requests/projects_tree_perfomance_spec.rb @@ -6,13 +6,13 @@ describe "Projects" do describe "GET /projects/tree" do describe "head" do - before do + before do @project = Factory :project @project.add_access(@user, :read) end - it "should be fast" do + it "should be fast" do time = Benchmark.realtime do visit tree_project_path(@project) end @@ -21,12 +21,12 @@ describe "Projects" do end describe ValidCommit::ID do - before do + before do @project = Factory :project @project.add_access(@user, :read) end - it "should be fast" do + it "should be fast" do time = Benchmark.realtime do visit tree_project_path(@project, :commit_id => ValidCommit::ID) end diff --git a/spec/requests/projects_tree_spec.rb b/spec/requests/projects_tree_spec.rb index 4e3176bb..fd49ffaa 100644 --- a/spec/requests/projects_tree_spec.rb +++ b/spec/requests/projects_tree_spec.rb @@ -5,7 +5,7 @@ describe "Projects" do describe "GET /projects/tree" do describe "head" do - before do + before do @project = Factory :project @project.add_access(@user, :read) @@ -20,7 +20,7 @@ describe "Projects" do end describe ValidCommit::ID do - before do + before do @project = Factory :project @project.add_access(@user, :read) @@ -36,7 +36,7 @@ describe "Projects" do end describe "branch passed" do - before do + before do @project = Factory :project @project.add_access(@user, :read) @@ -53,7 +53,7 @@ describe "Projects" do # TREE FILE PREVIEW describe "file preview" do - before do + before do @project = Factory :project @project.add_access(@user, :read) @@ -70,9 +70,9 @@ describe "Projects" do end end - # RAW FILE + # RAW FILE describe "GET /projects/blob" do - before do + before do @project = Factory :project @project.add_access(@user, :read) @@ -85,7 +85,7 @@ describe "Projects" do current_path.should == blob_project_path(@project) end - it "raw file response" do + it "raw file response" do page.source.should == ValidCommit::BLOB_FILE end end diff --git a/spec/requests/projects_wall_spec.rb b/spec/requests/projects_wall_spec.rb index a7387f93..bb734bda 100644 --- a/spec/requests/projects_wall_spec.rb +++ b/spec/requests/projects_wall_spec.rb @@ -3,13 +3,13 @@ require 'spec_helper' describe "Projects", "Wall" do let(:project) { Factory :project } - before do + before do login_as :user project.add_access(@user, :read, :write) end describe "View notes on wall" do - before do + before do Factory :note, :project => project, :note => "Project specs", :author => @user visit wall_project_path(project) end @@ -19,8 +19,8 @@ describe "Projects", "Wall" do it { page.should have_content("less than a minute ago") } end - describe "add new note", :js => true do - before do + describe "add new note", :js => true do + before do visit wall_project_path(project) fill_in "note_note", :with => "my post on wall" click_button "Add note" diff --git a/spec/requests/snippets_spec.rb b/spec/requests/snippets_spec.rb index 00ae58da..d4811958 100644 --- a/spec/requests/snippets_spec.rb +++ b/spec/requests/snippets_spec.rb @@ -3,13 +3,13 @@ require 'spec_helper' describe "Snippets" do let(:project) { Factory :project } - before do + before do login_as :user project.add_access(@user, :read, :write) end describe "GET /snippets" do - before do + before do @snippet = Factory :snippet, :author => @user, :project => project @@ -23,15 +23,15 @@ describe "Snippets" do it { should have_content(@snippet.project.name) } it { should have_content(@snippet.author.name) } - describe "Destroy" do - before do + describe "Destroy" do + before do # admin access to remove snippet @user.users_projects.destroy_all project.add_access(@user, :read, :write, :admin) visit project_snippets_path(project) end - it "should remove entry" do + it "should remove entry" do expect { click_link "destroy_snippet_#{@snippet.id}" }.to change { Snippet.count }.by(-1) @@ -39,17 +39,17 @@ describe "Snippets" do end end - describe "New snippet" do - before do + describe "New snippet" do + before do visit project_snippets_path(project) click_link "New Snippet" end - it "should open new snippet popup" do + it "should open new snippet popup" do page.current_path.should == new_project_snippet_path(project) end - describe "fill in" do + describe "fill in" do before do fill_in "snippet_title", :with => "login function" fill_in "snippet_file_name", :with => "test.rb" @@ -58,7 +58,7 @@ describe "Snippets" do it { expect { click_button "Save" }.to change {Snippet.count}.by(1) } - it "should add new snippet to table" do + it "should add new snippet to table" do click_button "Save" page.current_path.should == project_snippet_path(project, Snippet.last) page.should have_content "login function" @@ -67,8 +67,8 @@ describe "Snippets" do end end - describe "Edit snippet" do - before do + describe "Edit snippet" do + before do @snippet = Factory :snippet, :author => @user, :project => project @@ -76,11 +76,11 @@ describe "Snippets" do click_link "Edit" end - it "should open edit page" do + it "should open edit page" do page.current_path.should == edit_project_snippet_path(project, @snippet) end - describe "fill in" do + describe "fill in" do before do fill_in "snippet_title", :with => "login function" fill_in "snippet_file_name", :with => "test.rb" @@ -89,7 +89,7 @@ describe "Snippets" do it { expect { click_button "Save" }.to_not change {Snippet.count} } - it "should update snippet fields" do + it "should update snippet fields" do click_button "Save" page.current_path.should == project_snippet_path(project, @snippet) diff --git a/spec/requests/team_members_spec.rb b/spec/requests/team_members_spec.rb index 650ed449..d6555518 100644 --- a/spec/requests/team_members_spec.rb +++ b/spec/requests/team_members_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe "TeamMembers" do - before do + before do login_as :user @project = Factory :project @project.add_access(@user, :read, :admin) @@ -10,7 +10,7 @@ describe "TeamMembers" do describe "View profile" do it "should be available" do visit(team_project_path(@project)) - within "#team-table" do + within "#team-table" do click_link(@user.name) end page.should have_content @user.skype @@ -18,23 +18,23 @@ describe "TeamMembers" do end end - describe "New Team member", :js => true do - before do + describe "New Team member", :js => true do + before do @user_1 = Factory :user visit team_project_path(@project) click_link "Add new" end - it "should open new team member popup" do + it "should open new team member popup" do page.should have_content("Add new member to project") end - describe "fill in" do + describe "fill in" do before do click_link "Select user" click_link @user_1.name - within "#team_member_new" do + within "#team_member_new" do check "team_member_read" check "team_member_write" end @@ -42,7 +42,7 @@ describe "TeamMembers" do it { expect { click_button "Save";sleep(1) }.to change {UsersProject.count}.by(1) } - it "should add new member to table" do + it "should add new member to table" do click_button "Save" @member = UsersProject.last @@ -53,8 +53,8 @@ describe "TeamMembers" do @member.admin.should be_false end - it "should not allow creation without access selected" do - within "#team_member_new" do + it "should not allow creation without access selected" do + within "#team_member_new" do uncheck "team_member_read" uncheck "team_member_write" uncheck "team_member_admin" @@ -66,8 +66,8 @@ describe "TeamMembers" do end end - describe "Cancel membership" do - it "should cancel membership" do + describe "Cancel membership" do + it "should cancel membership" do visit team_project_path(@project) expect { click_link "Cancel" }.to change { UsersProject.count }.by(-1) end diff --git a/spec/requests/top_panel_spec.rb b/spec/requests/top_panel_spec.rb index bd4d2047..d1cea6d8 100644 --- a/spec/requests/top_panel_spec.rb +++ b/spec/requests/top_panel_spec.rb @@ -4,7 +4,7 @@ describe "Top Panel", :js => true do before { login_as :user } describe "Search autocomplete" do - before do + before do visit projects_path fill_in "search", :with => "Ke" sleep(2) @@ -12,12 +12,12 @@ describe "Top Panel", :js => true do end it "should be on projects page" do - current_path.should == keys_path + current_path.should == keys_path end end describe "with project" do - before do + before do @project = Factory :project @project.add_access(@user, :read) visit project_path(@project) @@ -28,7 +28,7 @@ describe "Top Panel", :js => true do end it "should be on projects page" do - current_path.should == project_commits_path(@project) + current_path.should == project_commits_path(@project) end end end diff --git a/spec/requests/user_security_spec.rb b/spec/requests/user_security_spec.rb index a27eb1ca..b75a1779 100644 --- a/spec/requests/user_security_spec.rb +++ b/spec/requests/user_security_spec.rb @@ -2,32 +2,32 @@ require 'spec_helper' describe "Users Security" do describe "Project" do - before do + before do @u1 = Factory :user end - describe "GET /login" do + describe "GET /login" do #it { new_user_session_path.should be_denied_for @u1 } #it { new_user_session_path.should be_denied_for :admin } #it { new_user_session_path.should be_denied_for :user } it { new_user_session_path.should_not be_404_for :visitor } end - describe "GET /keys" do + describe "GET /keys" do it { keys_path.should be_allowed_for @u1 } it { keys_path.should be_allowed_for :admin } it { keys_path.should be_allowed_for :user } it { keys_path.should be_denied_for :visitor } end - describe "GET /profile" do + describe "GET /profile" do it { profile_path.should be_allowed_for @u1 } it { profile_path.should be_allowed_for :admin } it { profile_path.should be_allowed_for :user } it { profile_path.should be_denied_for :visitor } end - describe "GET /profile/password" do + describe "GET /profile/password" do it { profile_password_path.should be_allowed_for @u1 } it { profile_password_path.should be_allowed_for :admin } it { profile_password_path.should be_allowed_for :user } diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 0c2545e3..aa7f23d8 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -11,7 +11,6 @@ require 'capybara/dsl' require 'factories' require 'monkeypatch' - # Requires supporting ruby files with custom matchers and macros, etc, # in spec/support/ and its subdirectories. Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} diff --git a/spec/support/login.rb b/spec/support/login.rb index 462647ab..a700c8b9 100644 --- a/spec/support/login.rb +++ b/spec/support/login.rb @@ -1,12 +1,12 @@ module LoginMacros def login_as role - @user = User.create(:email => "user#{User.count}@mail.com", + @user = User.create(:email => "user#{User.count}@mail.com", :name => "John Smith", :password => "123456", :password_confirmation => "123456", :skype => 'user_skype') - - if role == :admin + + if role == :admin @user.admin = true @user.save! end @@ -23,7 +23,7 @@ module LoginMacros fill_in "Password", :with => "123456" click_button "Sign in" end - + def logout click_link "Logout" rescue nil end diff --git a/spec/support/matchers.rb b/spec/support/matchers.rb index dcdfa6d5..e0672166 100644 --- a/spec/support/matchers.rb +++ b/spec/support/matchers.rb @@ -18,17 +18,17 @@ RSpec::Matchers.define :be_denied_for do |user| match do |url| include UrlAccess url_denied?(user, url) - end + end end RSpec::Matchers.define :be_404_for do |user| match do |url| include UrlAccess url_404?(user, url) - end + end end -module UrlAccess +module UrlAccess def url_allowed?(user, url) emulate_user(user) visit url diff --git a/spec/support/shared_examples.rb b/spec/support/shared_examples.rb index a2e94ac1..118b9b2a 100644 --- a/spec/support/shared_examples.rb +++ b/spec/support/shared_examples.rb @@ -6,13 +6,12 @@ shared_examples_for :project_side_pane do it { should have_content("Tree") } end - shared_examples_for :tree_view do subject { page } it "should have Tree View of project" do - should have_content("app") - should have_content("history") - should have_content("Gemfile") + should have_content("app") + should have_content("history") + should have_content("Gemfile") end end diff --git a/app/assets/javascripts/jquery-ui-1.8.16.custom.min.js b/vendor/assets/javascripts/jquery-ui.js similarity index 99% rename from app/assets/javascripts/jquery-ui-1.8.16.custom.min.js rename to vendor/assets/javascripts/jquery-ui.js index 14c9064f..d92b7a34 100644 --- a/app/assets/javascripts/jquery-ui-1.8.16.custom.min.js +++ b/vendor/assets/javascripts/jquery-ui.js @@ -41,7 +41,7 @@ c);return this},enable:function(){return this._setOption("disabled",false)},disa * http://docs.jquery.com/UI/Mouse * * Depends: - * jquery.ui.widget.js + * jquery.ui.widget.js */ (function(b){var d=false;b(document).mouseup(function(){d=false});b.widget("ui.mouse",{options:{cancel:":input,option",distance:1,delay:0},_mouseInit:function(){var a=this;this.element.bind("mousedown."+this.widgetName,function(c){return a._mouseDown(c)}).bind("click."+this.widgetName,function(c){if(true===b.data(c.target,a.widgetName+".preventClickEvent")){b.removeData(c.target,a.widgetName+".preventClickEvent");c.stopImmediatePropagation();return false}});this.started=false},_mouseDestroy:function(){this.element.unbind("."+ this.widgetName)},_mouseDown:function(a){if(!d){this._mouseStarted&&this._mouseUp(a);this._mouseDownEvent=a;var c=this,f=a.which==1,g=typeof this.options.cancel=="string"&&a.target.nodeName?b(a.target).closest(this.options.cancel).length:false;if(!f||g||!this._mouseCapture(a))return true;this.mouseDelayMet=!this.options.delay;if(!this.mouseDelayMet)this._mouseDelayTimer=setTimeout(function(){c.mouseDelayMet=true},this.options.delay);if(this._mouseDistanceMet(a)&&this._mouseDelayMet(a)){this._mouseStarted= @@ -74,9 +74,9 @@ g=d.offset(),e=parseInt(c.curCSS(b,"top",true),10)||0,h=parseInt(c.curCSS(b,"lef * http://docs.jquery.com/UI/Draggables * * Depends: - * jquery.ui.core.js - * jquery.ui.mouse.js - * jquery.ui.widget.js + * jquery.ui.core.js + * jquery.ui.mouse.js + * jquery.ui.widget.js */ (function(d){d.widget("ui.draggable",d.ui.mouse,{widgetEventPrefix:"drag",options:{addClasses:true,appendTo:"parent",axis:false,connectToSortable:false,containment:false,cursor:"auto",cursorAt:false,grid:false,handle:false,helper:"original",iframeFix:false,opacity:false,refreshPositions:false,revert:false,revertDuration:500,scope:"default",scroll:true,scrollSensitivity:20,scrollSpeed:20,snap:false,snapMode:"both",snapTolerance:20,stack:false,zIndex:false},_create:function(){if(this.options.helper== "original"&&!/^(?:r|a|f)/.test(this.element.css("position")))this.element[0].style.position="relative";this.options.addClasses&&this.element.addClass("ui-draggable");this.options.disabled&&this.element.addClass("ui-draggable-disabled");this._mouseInit()},destroy:function(){if(this.element.data("draggable")){this.element.removeData("draggable").unbind(".draggable").removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled");this._mouseDestroy();return this}},_mouseCapture:function(a){var b= @@ -124,10 +124,10 @@ p||q||r||s;if(f.snapMode!="outer"){p=Math.abs(k-n)<=e;q=Math.abs(m-o)<=e;r=Math. * http://docs.jquery.com/UI/Droppables * * Depends: - * jquery.ui.core.js - * jquery.ui.widget.js - * jquery.ui.mouse.js - * jquery.ui.draggable.js + * jquery.ui.core.js + * jquery.ui.widget.js + * jquery.ui.mouse.js + * jquery.ui.draggable.js */ (function(d){d.widget("ui.droppable",{widgetEventPrefix:"drop",options:{accept:"*",activeClass:false,addClasses:true,greedy:false,hoverClass:false,scope:"default",tolerance:"intersect"},_create:function(){var a=this.options,b=a.accept;this.isover=0;this.isout=1;this.accept=d.isFunction(b)?b:function(c){return c.is(b)};this.proportions={width:this.element[0].offsetWidth,height:this.element[0].offsetHeight};d.ui.ddmanager.droppables[a.scope]=d.ui.ddmanager.droppables[a.scope]||[];d.ui.ddmanager.droppables[a.scope].push(this); a.addClasses&&this.element.addClass("ui-droppable")},destroy:function(){for(var a=d.ui.ddmanager.droppables[this.options.scope],b=0;b').css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(), @@ -200,9 +200,9 @@ d.height+a}else{b.size.width=d.width+h;b.size.height=d.height+a;b.position.top=f * http://docs.jquery.com/UI/Selectables * * Depends: - * jquery.ui.core.js - * jquery.ui.mouse.js - * jquery.ui.widget.js + * jquery.ui.core.js + * jquery.ui.mouse.js + * jquery.ui.widget.js */ (function(e){e.widget("ui.selectable",e.ui.mouse,{options:{appendTo:"body",autoRefresh:true,distance:0,filter:"*",tolerance:"touch"},_create:function(){var c=this;this.element.addClass("ui-selectable");this.dragged=false;var f;this.refresh=function(){f=e(c.options.filter,c.element[0]);f.each(function(){var d=e(this),b=d.offset();e.data(this,"selectable-item",{element:this,$element:d,left:b.left,top:b.top,right:b.left+d.outerWidth(),bottom:b.top+d.outerHeight(),startselected:false,selected:d.hasClass("ui-selected"), selecting:d.hasClass("ui-selecting"),unselecting:d.hasClass("ui-unselecting")})})};this.refresh();this.selectees=f.addClass("ui-selectee");this._mouseInit();this.helper=e("
")},destroy:function(){this.selectees.removeClass("ui-selectee").removeData("selectable-item");this.element.removeClass("ui-selectable ui-selectable-disabled").removeData("selectable").unbind(".selectable");this._mouseDestroy();return this},_mouseStart:function(c){var f=this;this.opos=[c.pageX, @@ -222,9 +222,9 @@ e.data(this,"selectable-item");d.$element.removeClass("ui-selecting").addClass(" * http://docs.jquery.com/UI/Sortables * * Depends: - * jquery.ui.core.js - * jquery.ui.mouse.js - * jquery.ui.widget.js + * jquery.ui.core.js + * jquery.ui.mouse.js + * jquery.ui.widget.js */ (function(d){d.widget("ui.sortable",d.ui.mouse,{widgetEventPrefix:"sort",options:{appendTo:"parent",axis:false,connectWith:false,containment:false,cursor:"auto",cursorAt:false,dropOnEmpty:true,forcePlaceholderSize:false,forceHelperSize:false,grid:false,handle:false,helper:"original",items:"> *",opacity:false,placeholder:false,revert:false,scroll:true,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1E3},_create:function(){var a=this.options;this.containerCache={};this.element.addClass("ui-sortable"); this.refresh();this.floating=this.items.length?a.axis==="x"||/left|right/.test(this.items[0].item.css("float"))||/inline|table-cell/.test(this.items[0].item.css("display")):false;this.offset=this.element.offset();this._mouseInit()},destroy:function(){this.element.removeClass("ui-sortable ui-sortable-disabled").removeData("sortable").unbind(".sortable");this._mouseDestroy();for(var a=this.items.length-1;a>=0;a--)this.items[a].item.removeData("sortable-item");return this},_setOption:function(a,b){if(a=== @@ -282,8 +282,8 @@ _uiHash:function(a){var b=a||this;return{helper:b.helper,placeholder:b.placehold * http://docs.jquery.com/UI/Accordion * * Depends: - * jquery.ui.core.js - * jquery.ui.widget.js + * jquery.ui.core.js + * jquery.ui.widget.js */ (function(c){c.widget("ui.accordion",{options:{active:0,animated:"slide",autoHeight:true,clearStyle:false,collapsible:false,event:"click",fillSpace:false,header:"> li > :first-child,> :not(li):even",icons:{header:"ui-icon-triangle-1-e",headerSelected:"ui-icon-triangle-1-s"},navigation:false,navigationFilter:function(){return this.href.toLowerCase()===location.href.toLowerCase()}},_create:function(){var a=this,b=a.options;a.running=0;a.element.addClass("ui-accordion ui-widget ui-helper-reset").children("li").addClass("ui-accordion-li-fix"); a.headers=a.element.find(b.header).addClass("ui-accordion-header ui-helper-reset ui-state-default ui-corner-all").bind("mouseenter.accordion",function(){b.disabled||c(this).addClass("ui-state-hover")}).bind("mouseleave.accordion",function(){b.disabled||c(this).removeClass("ui-state-hover")}).bind("focus.accordion",function(){b.disabled||c(this).addClass("ui-state-focus")}).bind("blur.accordion",function(){b.disabled||c(this).removeClass("ui-state-focus")});a.headers.next().addClass("ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom"); @@ -312,9 +312,9 @@ paddingTop:"hide",paddingBottom:"hide"},a);else a.toShow.animate({height:"show", * http://docs.jquery.com/UI/Autocomplete * * Depends: - * jquery.ui.core.js - * jquery.ui.widget.js - * jquery.ui.position.js + * jquery.ui.core.js + * jquery.ui.widget.js + * jquery.ui.position.js */ (function(d){var e=0;d.widget("ui.autocomplete",{options:{appendTo:"body",autoFocus:false,delay:300,minLength:1,position:{my:"left top",at:"left bottom",collision:"none"},source:null},pending:0,_create:function(){var a=this,b=this.element[0].ownerDocument,g;this.element.addClass("ui-autocomplete-input").attr("autocomplete","off").attr({role:"textbox","aria-autocomplete":"list","aria-haspopup":"true"}).bind("keydown.autocomplete",function(c){if(!(a.options.disabled||a.element.propAttr("readOnly"))){g= false;var f=d.ui.keyCode;switch(c.keyCode){case f.PAGE_UP:a._move("previousPage",c);break;case f.PAGE_DOWN:a._move("nextPage",c);break;case f.UP:a._move("previous",c);c.preventDefault();break;case f.DOWN:a._move("next",c);c.preventDefault();break;case f.ENTER:case f.NUMPAD_ENTER:if(a.menu.active){g=true;c.preventDefault()}case f.TAB:if(!a.menu.active)return;a.menu.select(c);break;case f.ESCAPE:a.element.val(a.term);a.close(c);break;default:clearTimeout(a.searching);a.searching=setTimeout(function(){if(a.term!= @@ -344,8 +344,8 @@ this.first()?":last":":first"))},hasScroll:function(){return this.element.height * http://docs.jquery.com/UI/Button * * Depends: - * jquery.ui.core.js - * jquery.ui.widget.js + * jquery.ui.core.js + * jquery.ui.widget.js */ (function(b){var h,i,j,g,l=function(){var a=b(this).find(":ui-button");setTimeout(function(){a.button("refresh")},1)},k=function(a){var c=a.name,e=a.form,f=b([]);if(c)f=e?b(e).find("[name='"+c+"']"):b("[name='"+c+"']",a.ownerDocument).filter(function(){return!this.form});return f};b.widget("ui.button",{options:{disabled:null,text:true,label:null,icons:{primary:null,secondary:null}},_create:function(){this.element.closest("form").unbind("reset.button").bind("reset.button",l);if(typeof this.options.disabled!== "boolean")this.options.disabled=this.element.propAttr("disabled");this._determineButtonType();this.hasTitle=!!this.buttonElement.attr("title");var a=this,c=this.options,e=this.type==="checkbox"||this.type==="radio",f="ui-state-hover"+(!e?" ui-state-active":"");if(c.label===null)c.label=this.buttonElement.html();if(this.element.is(":disabled"))c.disabled=true;this.buttonElement.addClass("ui-button ui-widget ui-state-default ui-corner-all").attr("role","button").bind("mouseenter.button",function(){if(!c.disabled){b(this).addClass("ui-state-hover"); @@ -371,13 +371,13 @@ b.Widget.prototype.destroy.call(this)}})})(jQuery); * http://docs.jquery.com/UI/Dialog * * Depends: - * jquery.ui.core.js - * jquery.ui.widget.js + * jquery.ui.core.js + * jquery.ui.widget.js * jquery.ui.button.js - * jquery.ui.draggable.js - * jquery.ui.mouse.js - * jquery.ui.position.js - * jquery.ui.resizable.js + * jquery.ui.draggable.js + * jquery.ui.mouse.js + * jquery.ui.position.js + * jquery.ui.resizable.js */ (function(c,l){var m={buttons:true,height:true,maxHeight:true,maxWidth:true,minHeight:true,minWidth:true,width:true},n={maxHeight:true,maxWidth:true,minHeight:true,minWidth:true},o=c.attrFn||{val:true,css:true,html:true,text:true,data:true,width:true,height:true,offset:true,click:true};c.widget("ui.dialog",{options:{autoOpen:true,buttons:{},closeOnEscape:true,closeText:"close",dialogClass:"",draggable:true,hide:null,height:"auto",maxHeight:false,maxWidth:false,minHeight:150,minWidth:150,modal:false, position:{my:"center",at:"center",collision:"fit",using:function(a){var b=c(this).css(a).offset().top;b<0&&c(this).css("top",a.top-b)}},resizable:true,show:null,stack:true,title:"",width:300,zIndex:1E3},_create:function(){this.originalTitle=this.element.attr("title");if(typeof this.originalTitle!=="string")this.originalTitle="";this.options.title=this.options.title||this.originalTitle;var a=this,b=a.options,d=b.title||" ",e=c.ui.dialog.getTitleId(a.element),g=(a.uiDialog=c("
")).appendTo(document.body).hide().addClass("ui-dialog ui-widget ui-widget-content ui-corner-all "+ @@ -411,9 +411,9 @@ c.browser.version<7){a=Math.max(document.documentElement.scrollHeight,document.b * http://docs.jquery.com/UI/Slider * * Depends: - * jquery.ui.core.js - * jquery.ui.mouse.js - * jquery.ui.widget.js + * jquery.ui.core.js + * jquery.ui.mouse.js + * jquery.ui.widget.js */ (function(d){d.widget("ui.slider",d.ui.mouse,{widgetEventPrefix:"slide",options:{animate:false,distance:0,max:100,min:0,orientation:"horizontal",range:false,step:1,value:0,values:null},_create:function(){var a=this,b=this.options,c=this.element.find(".ui-slider-handle").addClass("ui-state-default ui-corner-all"),f=b.values&&b.values.length||1,e=[];this._mouseSliding=this._keySliding=false;this._animateOff=true;this._handleIndex=null;this._detectOrientation();this._mouseInit();this.element.addClass("ui-slider ui-slider-"+ this.orientation+" ui-widget ui-widget-content ui-corner-all"+(b.disabled?" ui-slider-disabled ui-disabled":""));this.range=d([]);if(b.range){if(b.range===true){if(!b.values)b.values=[this._valueMin(),this._valueMin()];if(b.values.length&&b.values.length!==2)b.values=[b.values[0],b.values[0]]}this.range=d("
").appendTo(this.element).addClass("ui-slider-range ui-widget-header"+(b.range==="min"||b.range==="max"?" ui-slider-range-"+b.range:""))}for(var j=c.length;j"); @@ -444,8 +444,8 @@ b.animate);if(a==="max"&&this.orientation==="horizontal")this.range[f?"animate": * http://docs.jquery.com/UI/Tabs * * Depends: - * jquery.ui.core.js - * jquery.ui.widget.js + * jquery.ui.core.js + * jquery.ui.widget.js */ (function(d,p){function u(){return++v}function w(){return++x}var v=0,x=0;d.widget("ui.tabs",{options:{add:null,ajaxOptions:null,cache:false,cookie:null,collapsible:false,disable:null,disabled:[],enable:null,event:"click",fx:null,idPrefix:"ui-tabs-",load:null,panelTemplate:"
",remove:null,select:null,show:null,spinner:"Loading…",tabTemplate:"
  • #{label}
  • "},_create:function(){this._tabify(true)},_setOption:function(b,e){if(b=="selected")this.options.collapsible&& e==this.options.selected||this.select(e);else{this.options[b]=e;this._tabify()}},_tabId:function(b){return b.title&&b.title.replace(/\s/g,"_").replace(/[^\w\u00c0-\uFFFF-]/g,"")||this.options.idPrefix+u()},_sanitizeSelector:function(b){return b.replace(/:/g,"\\:")},_cookie:function(){var b=this.cookie||(this.cookie=this.options.cookie.name||"ui-tabs-"+w());return d.cookie.apply(null,[b].concat(d.makeArray(arguments)))},_ui:function(b,e){return{tab:b,panel:e,index:this.anchors.index(b)}},_cleanup:function(){this.lis.filter(".ui-state-processing").removeClass("ui-state-processing").find("span:data(label.tabs)").each(function(){var b= @@ -479,7 +479,7 @@ a.rotate(null)}:function(){t=c.selected;h()});if(b){this.element.bind("tabsshow" * http://docs.jquery.com/UI/Datepicker * * Depends: - * jquery.ui.core.js + * jquery.ui.core.js */ (function(d,C){function M(){this.debug=false;this._curInst=null;this._keyEvent=false;this._disabledInputs=[];this._inDialog=this._datepickerShowing=false;this._mainDivId="ui-datepicker-div";this._inlineClass="ui-datepicker-inline";this._appendClass="ui-datepicker-append";this._triggerClass="ui-datepicker-trigger";this._dialogClass="ui-datepicker-dialog";this._disableClass="ui-datepicker-disabled";this._unselectableClass="ui-datepicker-unselectable";this._currentClass="ui-datepicker-current-day";this._dayOverClass= "ui-datepicker-days-cell-over";this.regional=[];this.regional[""]={closeText:"Done",prevText:"Prev",nextText:"Next",currentText:"Today",monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dayNamesMin:["Su", @@ -609,7 +609,7 @@ a*2-e,0,d,e)*0.5+d*0.5+b}})}(jQuery); * http://docs.jquery.com/UI/Effects/Blind * * Depends: - * jquery.effects.core.js + * jquery.effects.core.js */ (function(b){b.effects.blind=function(c){return this.queue(function(){var a=b(this),g=["position","top","bottom","left","right"],f=b.effects.setMode(a,c.options.mode||"hide"),d=c.options.direction||"vertical";b.effects.save(a,g);a.show();var e=b.effects.createWrapper(a).css({overflow:"hidden"}),h=d=="vertical"?"height":"width";d=d=="vertical"?e.height():e.width();f=="show"&&e.css(h,0);var i={};i[h]=f=="show"?d:0;e.animate(i,c.duration,c.options.easing,function(){f=="hide"&&a.hide();b.effects.restore(a, g);b.effects.removeWrapper(a);c.callback&&c.callback.apply(a[0],arguments);a.dequeue()})})}})(jQuery); @@ -623,7 +623,7 @@ g);b.effects.removeWrapper(a);c.callback&&c.callback.apply(a[0],arguments);a.deq * http://docs.jquery.com/UI/Effects/Bounce * * Depends: - * jquery.effects.core.js + * jquery.effects.core.js */ (function(e){e.effects.bounce=function(b){return this.queue(function(){var a=e(this),l=["position","top","bottom","left","right"],h=e.effects.setMode(a,b.options.mode||"effect"),d=b.options.direction||"up",c=b.options.distance||20,m=b.options.times||5,i=b.duration||250;/show|hide/.test(h)&&l.push("opacity");e.effects.save(a,l);a.show();e.effects.createWrapper(a);var f=d=="up"||d=="down"?"top":"left";d=d=="up"||d=="left"?"pos":"neg";c=b.options.distance||(f=="top"?a.outerHeight({margin:true})/3:a.outerWidth({margin:true})/ 3);if(h=="show")a.css("opacity",0).css(f,d=="pos"?-c:c);if(h=="hide")c/=m*2;h!="hide"&&m--;if(h=="show"){var g={opacity:1};g[f]=(d=="pos"?"+=":"-=")+c;a.animate(g,i/2,b.options.easing);c/=2;m--}for(g=0;g").css({position:"absolute",visibility:"visible",left:-f*(h/d),top:-e*(i/c)}).parent().addClass("ui-effects-explode").css({position:"absolute",overflow:"hidden",width:h/d,height:i/c,left:g.left+f*(h/d)+(a.options.mode=="show"?(f-Math.floor(d/2))*(h/d):0),top:g.top+e*(i/c)+(a.options.mode=="show"?(e-Math.floor(c/2))*(i/c):0),opacity:a.options.mode=="show"?0:1}).animate({left:g.left+f*(h/d)+(a.options.mode=="show"?0:(f-Math.floor(d/2))*(h/d)),top:g.top+ @@ -681,7 +681,7 @@ e*(i/c)+(a.options.mode=="show"?0:(e-Math.floor(c/2))*(i/c)),opacity:a.options.m * http://docs.jquery.com/UI/Effects/Fade * * Depends: - * jquery.effects.core.js + * jquery.effects.core.js */ (function(b){b.effects.fade=function(a){return this.queue(function(){var c=b(this),d=b.effects.setMode(c,a.options.mode||"hide");c.animate({opacity:d},{queue:false,duration:a.duration,easing:a.options.easing,complete:function(){a.callback&&a.callback.apply(this,arguments);c.dequeue()}})})}})(jQuery); ;/* @@ -694,7 +694,7 @@ e*(i/c)+(a.options.mode=="show"?0:(e-Math.floor(c/2))*(i/c)),opacity:a.options.m * http://docs.jquery.com/UI/Effects/Fold * * Depends: - * jquery.effects.core.js + * jquery.effects.core.js */ (function(c){c.effects.fold=function(a){return this.queue(function(){var b=c(this),j=["position","top","bottom","left","right"],d=c.effects.setMode(b,a.options.mode||"hide"),g=a.options.size||15,h=!!a.options.horizFirst,k=a.duration?a.duration/2:c.fx.speeds._default/2;c.effects.save(b,j);b.show();var e=c.effects.createWrapper(b).css({overflow:"hidden"}),f=d=="show"!=h,l=f?["width","height"]:["height","width"];f=f?[e.width(),e.height()]:[e.height(),e.width()];var i=/([0-9]+)%/.exec(g);if(i)g=parseInt(i[1], 10)/100*f[d=="hide"?0:1];if(d=="show")e.css(h?{height:0,width:g}:{height:g,width:0});h={};i={};h[l[0]]=d=="show"?f[0]:g;i[l[1]]=d=="show"?f[1]:0;e.animate(h,k,a.options.easing).animate(i,k,a.options.easing,function(){d=="hide"&&b.hide();c.effects.restore(b,j);c.effects.removeWrapper(b);a.callback&&a.callback.apply(b[0],arguments);b.dequeue()})})}})(jQuery); @@ -708,7 +708,7 @@ e*(i/c)+(a.options.mode=="show"?0:(e-Math.floor(c/2))*(i/c)),opacity:a.options.m * http://docs.jquery.com/UI/Effects/Highlight * * Depends: - * jquery.effects.core.js + * jquery.effects.core.js */ (function(b){b.effects.highlight=function(c){return this.queue(function(){var a=b(this),e=["backgroundImage","backgroundColor","opacity"],d=b.effects.setMode(a,c.options.mode||"show"),f={backgroundColor:a.css("backgroundColor")};if(d=="hide")f.opacity=0;b.effects.save(a,e);a.show().css({backgroundImage:"none",backgroundColor:c.options.color||"#ffff99"}).animate(f,{queue:false,duration:c.duration,easing:c.options.easing,complete:function(){d=="hide"&&a.hide();b.effects.restore(a,e);d=="show"&&!b.support.opacity&& this.style.removeAttribute("filter");c.callback&&c.callback.apply(this,arguments);a.dequeue()}})})}})(jQuery); @@ -722,7 +722,7 @@ this.style.removeAttribute("filter");c.callback&&c.callback.apply(this,arguments * http://docs.jquery.com/UI/Effects/Pulsate * * Depends: - * jquery.effects.core.js + * jquery.effects.core.js */ (function(d){d.effects.pulsate=function(a){return this.queue(function(){var b=d(this),c=d.effects.setMode(b,a.options.mode||"show");times=(a.options.times||5)*2-1;duration=a.duration?a.duration/2:d.fx.speeds._default/2;isVisible=b.is(":visible");animateTo=0;if(!isVisible){b.css("opacity",0).show();animateTo=1}if(c=="hide"&&isVisible||c=="show"&&!isVisible)times--;for(c=0;c').appendTo(document.body).addClass(a.options.className).css({top:d.top,left:d.left,height:b.innerHeight(),width:b.innerWidth(),position:"absolute"}).animate(c,a.duration,a.options.easing,function(){f.remove();a.callback&&a.callback.apply(b[0],arguments); b.dequeue()})})}})(jQuery); -; \ No newline at end of file +; diff --git a/app/assets/javascripts/jquery.cookie.js b/vendor/assets/javascripts/jquery.cookie.js similarity index 100% rename from app/assets/javascripts/jquery.cookie.js rename to vendor/assets/javascripts/jquery.cookie.js diff --git a/vendor/assets/javascripts/jquery.ui.selectmenu.js b/vendor/assets/javascripts/jquery.ui.selectmenu.js new file mode 100644 index 00000000..957fe4d8 --- /dev/null +++ b/vendor/assets/javascripts/jquery.ui.selectmenu.js @@ -0,0 +1,844 @@ + /* + * jQuery UI selectmenu dev version + * + * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT (MIT-LICENSE.txt) + * and GPL (GPL-LICENSE.txt) licenses. + * + * http://docs.jquery.com/UI + * https://github.com/fnagel/jquery-ui/wiki/Selectmenu + */ + +(function($) { + +$.widget("ui.selectmenu", { + getter: "value", + version: "1.8", + eventPrefix: "selectmenu", + options: { + transferClasses: true, + typeAhead: "sequential", + style: 'dropdown', + positionOptions: { + my: "left top", + at: "left bottom", + offset: null + }, + width: null, + menuWidth: null, + handleWidth: 26, + maxHeight: null, + icons: null, + format: null, + bgImage: function() {}, + wrapperElement: "
    " + }, + + _create: function() { + var self = this, o = this.options; + + // set a default id value, generate a new random one if not set by developer + var selectmenuId = this.element.attr( 'id' ) || 'ui-selectmenu-' + Math.random().toString( 16 ).slice( 2, 10 ); + + // quick array of button and menu id's + this.ids = [ selectmenuId + '-button', selectmenuId + '-menu' ]; + + // define safe mouseup for future toggling + this._safemouseup = true; + + // create menu button wrapper + this.newelement = $( '', { + 'class': this.widgetBaseClass + ' ui-widget ui-state-default ui-corner-all', + 'id' : this.ids[ 0 ], + 'role': 'button', + 'href': '#nogo', + 'tabindex': this.element.attr( 'disabled' ) ? 1 : 0, + 'aria-haspopup': true, + 'aria-owns': this.ids[ 1 ] + }); + this.newelementWrap = $( o.wrapperElement ) + .append( this.newelement ) + .insertAfter( this.element ); + + // transfer tabindex + var tabindex = this.element.attr( 'tabindex' ); + if ( tabindex ) { + this.newelement.attr( 'tabindex', tabindex ); + } + + // save reference to select in data for ease in calling methods + this.newelement.data( 'selectelement', this.element ); + + // menu icon + this.selectmenuIcon = $( '' ) + .prependTo( this.newelement ); + + // append status span to button + this.newelement.prepend( '' ); + + // make associated form label trigger focus + $( 'label[for="' + selectmenuId + '"]' ) + .attr( 'for', this.ids[0] ) + .bind( 'click.selectmenu', function() { + self.newelement[0].focus(); + return false; + }); + + // click toggle for menu visibility + this.newelement + .bind('mousedown.selectmenu', function(event) { + self._toggle(event, true); + // make sure a click won't open/close instantly + if (o.style == "popup") { + self._safemouseup = false; + setTimeout(function() { self._safemouseup = true; }, 300); + } + return false; + }) + .bind('click.selectmenu', function() { + return false; + }) + .bind("keydown.selectmenu", function(event) { + var ret = false; + switch (event.keyCode) { + case $.ui.keyCode.ENTER: + ret = true; + break; + case $.ui.keyCode.SPACE: + self._toggle(event); + break; + case $.ui.keyCode.UP: + if (event.altKey) { + self.open(event); + } else { + self._moveSelection(-1); + } + break; + case $.ui.keyCode.DOWN: + if (event.altKey) { + self.open(event); + } else { + self._moveSelection(1); + } + break; + case $.ui.keyCode.LEFT: + self._moveSelection(-1); + break; + case $.ui.keyCode.RIGHT: + self._moveSelection(1); + break; + case $.ui.keyCode.TAB: + ret = true; + break; + default: + ret = true; + } + return ret; + }) + .bind('keypress.selectmenu', function(event) { + self._typeAhead(event.which, 'mouseup'); + return true; + }) + .bind('mouseover.selectmenu focus.selectmenu', function() { + if (!o.disabled) { + $(this).addClass(self.widgetBaseClass + '-focus ui-state-hover'); + } + }) + .bind('mouseout.selectmenu blur.selectmenu', function() { + if (!o.disabled) { + $(this).removeClass(self.widgetBaseClass + '-focus ui-state-hover'); + } + }); + + // document click closes menu + $(document).bind("mousedown.selectmenu", function(event) { + self.close(event); + }); + + // change event on original selectmenu + this.element + .bind("click.selectmenu", function() { + self._refreshValue(); + }) + // FIXME: newelement can be null under unclear circumstances in IE8 + // TODO not sure if this is still a problem (fnagel 20.03.11) + .bind("focus.selectmenu", function() { + if (self.newelement) { + self.newelement[0].focus(); + } + }); + + // set width when not set via options + if (!o.width) { + o.width = this.element.outerWidth(); + } + // set menu button width + this.newelement.width(o.width); + + // hide original selectmenu element + this.element.hide(); + + // create menu portion, append to body + this.list = $( '