Commit d62200ca authored by Nihad Abbasov's avatar Nihad Abbasov

clean-up code

  * Remove trailing whitespace
  * Converts hard-tabs into two-space soft-tabs
  * Remove consecutive blank lines
parent f6a67fba
......@@ -8,7 +8,7 @@ $(document).ready(function(){
e.stopPropagation();
$(this).find("td.tree-item-file-name a").click();
return false;
}
}
});
$("#projects-list .project").live('click', function(e){
......
......@@ -3,5 +3,5 @@
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
* the top of the compiled file, but it's generally better to create a new file per style scope.
*= require_self
*= require_tree .
*= require_tree .
*/
@mixin round-borders-all($radius) {
@mixin round-borders-all($radius) {
border: 1px solid #eaeaea;
-moz-border-radius: $radius;
-webkit-border-radius: $radius;
......@@ -28,11 +28,11 @@ td.linenos{
.highlight pre{
}
.linenodiv pre {
.linenodiv pre {
white-space:pre-line;
}
td.linenos {
td.linenos {
background:#ECECEC;
color:#777;
padding:10px 0px 0px 10px;
......@@ -42,7 +42,7 @@ td.linenos {
}
td.code .highlight {
td.code .highlight {
overflow: auto;
}
table.highlighttable pre{
......@@ -53,9 +53,8 @@ table.highlighttable pre{
text-align:left;
}
.git-empty .highlight {
@include round-borders-all(4px);
@include round-borders-all(4px);
background:#eee;
padding:5px;
//overflow-x:scroll;
......@@ -71,10 +70,9 @@ table.highlighttable pre{
.shadow{
-webkit-box-shadow:0 5px 15px #000;
-moz-box-shadow:0 5px 15px #000;
box-shadow:0 5px 15px #000;
box-shadow:0 5px 15px #000;
}
.hll { background-color: #ffffff }
.c { color: #888888; font-style: italic } /* Comment */
.err { color: #a61717; background-color: #e3d2d2 } /* Error */
......@@ -105,7 +103,7 @@ table.highlighttable pre{
.highlight .nb{color:#0086B3;} /* Name.Builtin */
.highlight .nc{color:#458;font-weight:bold;} /* Name.Class */
.highlight .no{color:#008080;} /* Name.Constant */
.highlight .ni{color:#800080;}
.highlight .ni{color:#800080;}
.highlight .ne{color:#900;font-weight:bold;} /* Name.Exception */
.highlight .nf{color:#900;font-weight:bold;} /* Name.Function */
.highlight .nn{color:#005;font-weight:bold;} /* Name.Namespace */
......
......@@ -3,7 +3,7 @@
.ui-selectmenu { background:none; font-size:12px;display: block; display: inline-block; position: relative; height: 2.2em; vertical-align: middle; text-decoration: none; overflow: hidden; zoom: 1; }
.ui-selectmenu-icon { position:absolute; right:6px; margin-top:-8px; top: 50%; }
.ui-selectmenu-menu { padding:0; margin:0; position:absolute; top: 0; display: none; z-index: 1005;} /* z-index: 1005 to make selectmenu work with dialog */
.ui-selectmenu-menu ul { padding:0; margin:0; list-style:none; position: relative; overflow: auto; overflow-y: auto ; overflow-x: hidden; }
.ui-selectmenu-menu ul { padding:0; margin:0; list-style:none; position: relative; overflow: auto; overflow-y: auto ; overflow-x: hidden; }
.ui-selectmenu-open { display: block; }
.ui-selectmenu.ui-widget { background:none; }
.ui-selectmenu-menu-popup { margin-top: -1px; }
......
This diff is collapsed.
......@@ -20,7 +20,7 @@ class Admin::MailerController < ApplicationController
else
render :file => 'notify/note_wall_email.html.haml', :layout => 'notify'
end
rescue
rescue
render :text => "Preview not avaialble"
end
......@@ -29,7 +29,7 @@ class Admin::MailerController < ApplicationController
@password = "DHasJKDHAS!"
render :file => 'notify/new_user_email.html.haml', :layout => 'notify'
rescue
rescue
render :text => "Preview not avaialble"
end
......@@ -38,7 +38,7 @@ class Admin::MailerController < ApplicationController
@user = @issue.assignee
@project = @issue.project
render :file => 'notify/new_issue_email.html.haml', :layout => 'notify'
rescue
rescue
render :text => "Preview not avaialble"
end
end
......@@ -36,7 +36,7 @@ class Admin::UsersController < ApplicationController
def create
admin = params[:user].delete("admin")
@admin_user = User.new(params[:user])
@admin_user = User.new(params[:user])
@admin_user.admin = (admin && admin.to_i > 0)
respond_to do |format|
......@@ -54,8 +54,8 @@ class Admin::UsersController < ApplicationController
def update
admin = params[:user].delete("admin")
if params[:user][:password].empty?
params[:user].delete(:password)
params[:user].delete(:password_confirmation)
params[:user].delete(:password)
params[:user].delete(:password_confirmation)
end
@admin_user = User.find(params[:id])
......
......@@ -8,7 +8,7 @@ class ApplicationController < ActionController::Base
render :file => File.join(Rails.root, "public", "gitosis_error"), :layout => false
end
protected
protected
def abilities
@abilities ||= Six.new
......@@ -18,7 +18,7 @@ class ApplicationController < ActionController::Base
abilities.allowed?(object, action, subject)
end
def project
def project
@project ||= Project.find_by_code(params[:project_id])
end
......@@ -55,7 +55,7 @@ class ApplicationController < ActionController::Base
@tag = unless params[:tag].blank?
params[:tag]
else
else
nil
end
......
class IssuesController < ApplicationController
before_filter :authenticate_user!
before_filter :project
before_filter :project
before_filter :issue, :only => [:edit, :update, :destroy, :show]
# Authorize
before_filter :add_project_abilities
before_filter :authorize_read_issue!
before_filter :authorize_write_issue!, :only => [:new, :create, :close, :edit, :update, :sort]
before_filter :authorize_write_issue!, :only => [:new, :create, :close, :edit, :update, :sort]
respond_to :js
......@@ -57,14 +57,13 @@ class IssuesController < ApplicationController
end
end
def destroy
return access_denied! unless can?(current_user, :admin_issue, @issue)
@issue.destroy
respond_to do |format|
format.js { render :nothing => true }
format.js { render :nothing => true }
end
end
......@@ -78,7 +77,7 @@ class IssuesController < ApplicationController
render :nothing => true
end
protected
protected
def issue
@issue ||= @project.issues.find(params[:id])
......
......@@ -24,7 +24,7 @@ class KeysController < ApplicationController
respond_to do |format|
format.html { redirect_to keys_url }
format.js { render :nothing => true }
format.js { render :nothing => true }
end
end
end
class NotesController < ApplicationController
before_filter :project
before_filter :project
# Authorize
before_filter :add_project_abilities
before_filter :authorize_write_note!, :only => [:create]
before_filter :authorize_write_note!, :only => [:create]
respond_to :js
......@@ -15,10 +15,9 @@ class NotesController < ApplicationController
notify if params[:notify] == '1'
end
respond_to do |format|
format.html {redirect_to :back}
format.js
format.js
end
end
......@@ -30,11 +29,11 @@ class NotesController < ApplicationController
@note.destroy
respond_to do |format|
format.js { render :nothing => true }
format.js { render :nothing => true }
end
end
protected
protected
def notify
@project.users.reject { |u| u.id == current_user.id } .each do |u|
......
......@@ -14,7 +14,7 @@ class ProfileController < ApplicationController
end
def password_update
params[:user].reject!{ |k, v| k != "password" && k != "password_confirmation"}
params[:user].reject!{ |k, v| k != "password" && k != "password_confirmation"}
@user = current_user
if @user.update_attributes(params[:user])
......
class ProjectsController < ApplicationController
before_filter :project, :except => [:index, :new, :create]
before_filter :project, :except => [:index, :new, :create]
# Authorize
before_filter :add_project_abilities
before_filter :authorize_read_project!, :except => [:index, :new, :create]
before_filter :authorize_admin_project!, :only => [:edit, :update, :destroy]
before_filter :authorize_read_project!, :except => [:index, :new, :create]
before_filter :authorize_admin_project!, :only => [:edit, :update, :destroy]
before_filter :require_non_empty_project, :only => [:blob, :tree]
......@@ -23,7 +23,7 @@ class ProjectsController < ApplicationController
@project = Project.new(params[:project])
@project.owner = current_user
Project.transaction do
Project.transaction do
@project.save!
@project.users_projects.create!(:admin => true, :read => true, :write => true, :user => current_user)
end
......@@ -31,7 +31,7 @@ class ProjectsController < ApplicationController
respond_to do |format|
if @project.valid?
format.html { redirect_to @project, notice: 'Project was successfully created.' }
format.js
format.js
else
format.html { render action: "new" }
format.js
......@@ -51,10 +51,10 @@ class ProjectsController < ApplicationController
respond_to do |format|
if project.update_attributes(params[:project])
format.html { redirect_to project, :notice => 'Project was successfully updated.' }
format.js
format.js
else
format.html { render action: "edit" }
format.js
format.js
end
end
end
......@@ -105,7 +105,7 @@ class ProjectsController < ApplicationController
if params[:commit_id]
@commit = @repo.commits(params[:commit_id]).first
else
else
@commit = @repo.commits(@ref || "master").first
end
......@@ -114,7 +114,7 @@ class ProjectsController < ApplicationController
respond_to do |format|
format.html # show.html.erb
format.js do
format.js do
# diasbale cache to allow back button works
response.headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate"
response.headers["Pragma"] = "no-cache"
......@@ -132,7 +132,7 @@ class ProjectsController < ApplicationController
if @tree.is_a?(Grit::Blob)
send_data(@tree.data, :type => @tree.mime_type, :disposition => 'inline', :filename => @tree.name)
else
else
head(404)
end
rescue
......@@ -147,9 +147,9 @@ class ProjectsController < ApplicationController
end
end
protected
protected
def project
def project
@project ||= Project.find_by_code(params[:id])
end
end
class SnippetsController < ApplicationController
before_filter :authenticate_user!
before_filter :project
before_filter :project
# Authorize
before_filter :add_project_abilities
before_filter :authorize_read_snippet!
before_filter :authorize_write_snippet!, :only => [:new, :create, :close, :edit, :update, :sort]
before_filter :authorize_write_snippet!, :only => [:new, :create, :close, :edit, :update, :sort]
respond_to :html
......@@ -13,7 +13,7 @@ class SnippetsController < ApplicationController
@snippets = @project.snippets
end
def new
def new
@snippet = @project.snippets.new
end
......
class TeamMembersController < ApplicationController
before_filter :project
before_filter :project
# Authorize
before_filter :add_project_abilities
before_filter :authorize_read_project!
before_filter :authorize_admin_project!, :only => [:new, :create, :destroy, :update]
before_filter :authorize_admin_project!, :only => [:new, :create, :destroy, :update]
def show
@team_member = project.users_projects.find(params[:id])
......@@ -26,7 +26,7 @@ class TeamMembersController < ApplicationController
respond_to do |format|
format.js
format.html do
format.html do
unless @team_member.valid?
flash[:alert] = "User should have at least one role"
end
......@@ -41,7 +41,7 @@ class TeamMembersController < ApplicationController
respond_to do |format|
format.html { redirect_to root_path }
format.js { render :nothing => true }
format.js { render :nothing => true }
end
end
end
......@@ -23,9 +23,9 @@ module ApplicationHelper
end
def last_commit(project)
if project.repo_exists?
if project.repo_exists?
time_ago_in_words(project.commit.committed_date) + " ago"
else
else
"Never"
end
end
......@@ -33,8 +33,8 @@ module ApplicationHelper
def search_autocomplete_source
projects = current_user.projects.map{ |p| { :label => p.name, :url => project_path(p) } }
default_nav = [
{ :label => "Keys", :url => keys_path },
{ :label => "Projects", :url => projects_path },
{ :label => "Keys", :url => keys_path },
{ :label => "Projects", :url => projects_path },
{ :label => "Admin", :url => admin_root_path }
]
......@@ -42,10 +42,10 @@ module ApplicationHelper
if @project && !@project.new_record?
project_nav = [
{ :label => "#{@project.code} / Issues", :url => project_issues_path(@project) },
{ :label => "#{@project.code} / Wall", :url => wall_project_path(@project) },
{ :label => "#{@project.code} / Tree", :url => tree_project_path(@project) },
{ :label => "#{@project.code} / Commits", :url => project_commits_path(@project) },
{ :label => "#{@project.code} / Issues", :url => project_issues_path(@project) },
{ :label => "#{@project.code} / Wall", :url => wall_project_path(@project) },
{ :label => "#{@project.code} / Tree", :url => tree_project_path(@project) },
{ :label => "#{@project.code} / Commits", :url => project_commits_path(@project) },
{ :label => "#{@project.code} / Team", :url => team_project_path(@project) }
]
end
......
module CommitsHelper
def diff_line(line, line_new = 0, line_old = 0)
full_line = html_escape(line.gsub(/\n/, ''))
color = if line[0] == "+"
color = if line[0] == "+"
full_line = "<span class=\"old_line\">&nbsp;</span><span class=\"new_line\">#{line_new}</span> " + full_line
"#DFD"
elsif line[0] == "-"
elsif line[0] == "-"
full_line = "<span class=\"old_line\">#{line_old}</span><span class=\"new_line\">&nbsp;</span> " + full_line
"#FDD"
else
else
full_line = "<span class=\"old_line\">#{line_old}</span><span class=\"new_line\">#{line_new}</span> " + full_line
"none"
end
......
......@@ -12,7 +12,7 @@ module ProjectsHelper
else
true
end
rescue
rescue
nil
end
end
......@@ -17,14 +17,14 @@ class Ability
:read_issue,
:read_snippet,
:read_team_member,
:read_note
:read_note
] if project.readers.include?(user)
rules << [
:write_project,
:write_issue,
:write_snippet,
:write_note
:write_note
] if project.writers.include?(user)
rules << [
......@@ -32,13 +32,13 @@ class Ability
:admin_issue,
:admin_snippet,
:admin_team_member,
:admin_note
:admin_note
] if project.admins.include?(user)
rules.flatten
end
class << self
class << self
[:issue, :note, :snippet].each do |name|
define_method "#{name}_abilities" do |user, subject|
if subject.author == user
......@@ -48,7 +48,7 @@ class Ability
:"admin_#{name}"
]
else
subject.respond_to?(:project) ?
subject.respond_to?(:project) ?
project_abilities(user, subject.project) : []
end
end
......
......@@ -13,7 +13,7 @@ class Issue < ActiveRecord::Base
validates :title,
:presence => true,
:length => { :within => 0..255 }
validates :content,
:presence => true,
:length => { :within => 0..2000 }
......@@ -30,7 +30,7 @@ class Issue < ActiveRecord::Base
def today?
Date.today == created_at.to_date
end
def new?
today? && created_at == updated_at
end
......
......@@ -17,11 +17,11 @@ class Key < ActiveRecord::Base
def set_identifier
self.identifier = "#{user.identifier}_#{Time.now.to_i}"
end
def update_gitosis
Gitosis.new.configure do |c|
c.update_keys(identifier, key)
projects.each do |project|
c.update_project(project.path, project.gitosis_writers)
end
......
......@@ -7,7 +7,7 @@ class Note < ActiveRecord::Base
belongs_to :author,
:class_name => "User"
attr_protected :author, :author_id
attr_protected :author, :author_id
validates_presence_of :project
......@@ -15,10 +15,10 @@ class Note < ActiveRecord::Base
:presence => true,
:length => { :within => 0..255 }
validates :attachment,
:file_size => {
:maximum => 10.megabytes.to_i
}
validates :attachment,
:file_size => {
:maximum => 10.megabytes.to_i
}
scope :common, where(:noteable_id => nil)
......
......@@ -20,7 +20,7 @@ class Project < ActiveRecord::Base
:format => { :with => /^[a-zA-Z0-9_\-]*$/,
:message => "only letters, digits & '_' '-' allowed" },
:length => { :within => 0..255 }
validates :description,
:length => { :within => 0..2000 }
......@@ -57,13 +57,13 @@ class Project < ActiveRecord::Base
c.update_project(path, gitosis_writers)
end
end
def destroy_gitosis_project
Gitosis.new.configure do |c|
c.destroy_project(self)
end
end
def add_access(user, *access)
opts = { :user => user }
access.each { |name| opts.merge!(name => true) }
......@@ -102,12 +102,12 @@ class Project < ActiveRecord::Base
def url_to_repo
"#{GITOSIS["git_user"]}@#{GITOSIS["host"]}:#{path}.git"
end
def path_to_repo
GITOSIS["base_path"] + path + ".git"
end
def repo
def repo
@repo ||= Grit::Repo.new(path_to_repo)
end
......@@ -122,17 +122,17 @@ class Project < ActiveRecord::Base
def commit(commit_id = nil)
if commit_id
repo.commits(commit_id).first
else
else
repo.commits.first
end
end
def heads
def heads
@heads ||= repo.heads
end
def fresh_commits
commits = heads.map do |h|
commits = heads.map do |h|
repo.commits(h.name, 10)
end.flatten.uniq { |c| c.id }
......@@ -144,7 +144,7 @@ class Project < ActiveRecord::Base
end
def commits_since(date)
commits = heads.map do |h|
commits = heads.map do |h|
repo.log(h.name, nil, :since => date)
end.flatten.uniq { |c| c.id }
......@@ -165,7 +165,7 @@ class Project < ActiveRecord::Base
unless owner.can_create_project?
errors[:base] << ("Your own projects limit is #{owner.projects_limit}! Please contact administrator to increase it")
end
rescue
rescue
errors[:base] << ("Cant check your ability to create project")
end
......
......@@ -13,7 +13,7 @@ class Snippet < ActiveRecord::Base
validates :title,
:presence => true,
:length => { :within => 0..255 }
validates :file_name,
:presence => true,
:length => { :within => 0..255 }
......@@ -22,9 +22,8 @@ class Snippet < ActiveRecord::Base
:presence => true,
:length => { :within => 0..10000 }
def self.content_types
[
[
".rb", ".py", ".pl", ".scala", ".c", ".cpp", ".java",
".haml", ".html", ".sass", ".scss", ".xml", ".php", ".erb",
".js", ".sh", ".coffee", ".yml", ".md"
......
......@@ -5,7 +5,7 @@ class User < ActiveRecord::Base
:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me,
attr_accessible :email, :password, :password_confirmation, :remember_me,
:name, :projects_limit, :skype, :linkedin, :twitter
has_many :users_projects, :dependent => :destroy
......
%p This is page with preview for all system emails that are sent to user
%p Email previews built based on existing Project/Commit/Issue base - so some preview maybe unavailable unless object appear in system
%p Email previews built based on existing Project/Commit/Issue base - so some preview maybe unavailable unless object appear in system
#accordion
%h3
%a New user
%div
%div
%iframe{ :src=> admin_mailer_preview_user_new_path, :width=>"100%", :height=>"350"}
%h3
%a New issue
%div
%div
%iframe{ :src=> admin_mailer_preview_issue_new_path, :width=>"100%", :height=>"350"}
%h3
%h3
%a Commit note
%div
%iframe{ :src=> admin_mailer_preview_note_path(:type => "Commit"), :width=>"100%", :height=>"350"}
%h3
%a Issue note
%div
%div
%iframe{ :src=> admin_mailer_preview_note_path(:type => "Issue"), :width=>"100%", :height=>"350"}
%h3
%a Wall note
%div
%div
%iframe{ :src=> admin_mailer_preview_note_path(:type => "Wall"), :width=>"100%", :height=>"350"}
:javascript
:javascript
$(function() {
$( "#accordion" ).accordion(); });
%p#notice= notice
.span-8.colborder
%h2= @admin_project.name
%h2= @admin_project.name
%p
%b Name:
......@@ -22,16 +22,16 @@
.span-14
%h2 Team
%h2 Team
%table.round-borders
%tr
%th Name
%th Added
%th Added
%th Web
%th Git
%th Admin
%th
%th
- @admin_project.users_projects.each do |tm|
%tr
......
......@@ -7,8 +7,8 @@
%th Read
%th Git
%th Manage
%th Added
%th
%th Added
%th
%th
%th
- members.each do |tm|
......
......@@ -11,7 +11,6 @@
%b Since:
= @admin_team_member.updated_at
.span-10
.span-6
%b Access:
......
......@@ -44,7 +44,7 @@
.field
= f.label :twitter
%br
= f.text_field :twitter
= f.text_field :twitter
.clear
%br
.actions
......
......@@ -2,5 +2,4 @@
= render 'form'
= link_to 'Back', admin_users_path, :class => "right lbutton"
......@@ -19,28 +19,27 @@
= @admin_user.skype
%p
%b LinkedIn:
= @admin_user.linkedin
= @admin_user.linkedin
%p
%b Twitter:
= @admin_user.twitter
.clear
= link_to 'Edit', edit_admin_user_path(@admin_user)
\|
= link_to 'Back', admin_users_path
.span-14
%h2 Projects
%h2 Projects
%table.round-borders
%tr
%th Name
%th Added
%th Added
%th Web
%th Git
%th Admin
%th
%th
- @admin_user.users_projects.each do |tm|
- project = tm.project
......
......@@ -8,7 +8,7 @@
.diff_file_header
- if diff.deleted_file
%strong{:id => "#{diff.b_path}"}= diff.a_path
- else
- else
= link_to tree_file_project_path(@project, @commit.id, diff.b_path) do
%strong{:id => "#{diff.b_path}"}= diff.b_path
%br/
......@@ -19,5 +19,5 @@
.diff_file_content_image
%img{:src => "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"}
- else
%p
%p
%center No preview for this file type
......@@ -6,4 +6,4 @@
%h1 Listing commits
%div{:id => dom_id(@project)}
= render "commits"
%br/
\ No newline at end of file
%br/
......@@ -12,10 +12,10 @@
= diff_line(line, line_new, line_old)
- if line[0] == "+"
- line_new += 1
- elsif
- elsif
- line[0] == "-"
- line_old += 1
- else
- else
- line_new += 1
- line_old += 1
......@@ -4,5 +4,5 @@
side.html("#{escape_javascript(render "commits/show")}");
$("##{dom_id(@project)}").parent().append(side);
$("##{dom_id(@project)}").addClass("span-14");
:plain
:plain
$("#notes-list").html("#{escape_javascript(render(:partial => 'notes/notes_list'))}");
......@@ -9,4 +9,4 @@
<div><%= f.submit "Resend confirmation instructions" %></div>
<% end %>
<%= render :partial => "devise/shared/links" %>
\ No newline at end of file
<%= render :partial => "devise/shared/links" %>
......@@ -13,4 +13,4 @@
<div><%= f.submit "Change my password" %></div>
<% end %>
<%= render :partial => "devise/shared/links" %>
\ No newline at end of file
<%= render :partial => "devise/shared/links" %>
......@@ -22,4 +22,4 @@
<%- resource_class.omniauth_providers.each do |provider| %>
<%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %><br />
<% end -%>
<% end -%>
\ No newline at end of file
<% end -%>
......@@ -9,4 +9,4 @@
<div><%= f.submit "Resend unlock instructions" %></div>
<% end %>
<%= render :partial => "devise/shared/links" %>
\ No newline at end of file
<%= render :partial => "devise/shared/links" %>
%table.round-borders#issues-table
%tr
- if can?(current_user, :admin_issue, @project) && !params[:f] || params[:f] == "0"
%th
%th
%th Assignee
%th ID
%th Title
......
......@@ -21,10 +21,10 @@
-#notes
%td
- if can? current_user, :write_issue, @project
= form_for([@project, issue], :remote => true) do |f|
= form_for([@project, issue], :remote => true) do |f|
= f.check_box :closed, :onclick => "$(this).parent().submit();"
= hidden_field_tag :status_only, true
- else
- else
= check_box_tag "closed", 1, issue.closed, :disabled => true
%td
- if can?(current_user, :admin_issue, @project) || issue.author == current_user
......
......@@ -12,7 +12,7 @@
.span-2
= radio_button_tag :f, 3, params[:f] == "3", :onclick => "this.form.submit()", :id => "my_issues"
= label_tag "my_issues","To Me"
.span-2
= radio_button_tag :f, 1, params[:f] == "1", :onclick => "this.form.submit()", :id => "all_issues"
= label_tag "all_issues","All"
......@@ -20,9 +20,9 @@
#issues-table-holder= render "issues"
%br
:javascript
$('.delete-issue').live('ajax:success', function() {
$(this).closest('tr').fadeOut(); });
$('.delete-issue').live('ajax:success', function() {
$(this).closest('tr').fadeOut(); });
function setSortable(){
$('#issues-table>tbody').sortable({
axis: 'y',
......
......@@ -8,24 +8,24 @@
.span-8
- if @issue.closed
%center.success Closed
- else
- else
%center.error Open
%table.round-borders
%tr
%td Title:
%td Title:
%td
= truncate html_escape(@issue.title)
%tr
%td Project
%td Project
%td
%strong= @issue.project.name
%tr
%td Author:
%td Author:
%td
= image_tag gravatar_icon(@issue.author.email), :class => "left", :width => 40, :style => "padding:0 5px;"
= @issue.author.name
%tr
%td Assignee:
%td Assignee:
%td
= image_tag gravatar_icon(@issue.assignee.email), :class => "left", :width => 40, :style => "padding:0 5px;"
= @issue.assignee.name
......@@ -33,12 +33,11 @@
%td Closed?
%td
- if can? current_user, :write_issue, @project
= form_for([@project, @issue]) do |f|
= form_for([@project, @issue]) do |f|
= f.check_box :closed, :onclick => "$(this).parent().submit();"
= hidden_field_tag :status_only, true
- else
- else
= check_box_tag "closed", 1, @issue.closed, :disabled => true
.clear
:plain
:plain
$("#notes-list").html("#{escape_javascript(render(:partial => 'notes/notes_list'))}");
......@@ -2,7 +2,7 @@
- if @issue.valid?
:plain
$("##{dom_id(@issue)}").fadeOut();
- else
- else
- if @issue.valid?
:plain
$("#edit_issue_dialog").dialog("close");
......
......@@ -10,6 +10,6 @@
= render(:partial => 'show', :locals => {:key => key})
:javascript
$('.delete-key').live('ajax:success', function() {
$(this).closest('tr').fadeOut(); });
$('.delete-key').live('ajax:success', function() {
$(this).closest('tr').fadeOut(); });
......@@ -6,9 +6,9 @@
%h4= text
:javascript
$(function(){
$("#flash_container").slideDown("slow");
$("#flash_container").click(function(){
$(this).slideUp("slow");
$("#flash_container").slideDown("slow");
$("#flash_container").click(function(){
$(this).slideUp("slow");
});
setTimeout("hideFlash()",2000);
});
......
......@@ -22,7 +22,6 @@
</div>
</div>
<% if current_user %>
<%= javascript_tag do %>
$(function() {
......
......@@ -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"
- 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
......
......@@ -7,5 +7,5 @@
:plain
$("#new_note").replaceWith("#{escape_javascript(render('form'))}");
:plain
:plain
$("#submit_note").removeAttr("disabled");
......@@ -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
......@@ -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"}
......
......@@ -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"}
......
......@@ -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
......
......@@ -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 &amp; repository. Please wait for few minutes
- else
- else
%h3.prepend-top Updating project &amp; 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();
});
});
......@@ -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
......
......@@ -11,7 +11,7 @@
$(".list").toggle();
if($(".tile").is(":visible")){
$.cookie('project_view', 'tile', { expires: 14 });
} else {
} else {
$.cookie('project_view', 'list', { expires: 14 });
}
}
......@@ -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")
......
......@@ -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(); });
......@@ -40,7 +40,7 @@ eos
<p>
Be careful! <br/>
Project cant be recovered after destroy.</p>
<%= link_to 'Destroy', @project,
<%= link_to 'Destroy', @project,
:confirm => 'Are you sure?', :method => :delete,
:class => "left button negative span-6", :style => "text-align:center" %>
<div class="clear"></div>
......
......@@ -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
: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);
});
......@@ -20,7 +20,7 @@
%hr
= render "notes/notes"
:javascript
:javascript
$(function(){
$("#note_note").live("click", function(){
$(this).css("height", "100px");
......
:plain
:plain
$("#notes-list").html("#{escape_javascript(render(:partial => 'notes/notes_list'))}");
......@@ -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"
......@@ -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(); });
......@@ -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
......
......@@ -25,4 +25,3 @@
%b Twitter:
= user.twitter
......@@ -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 = {
......
......@@ -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
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 => /.*/
......
......@@ -11,7 +11,6 @@ class DeviseCreateUsers < ActiveRecord::Migration
# t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both
# t.token_authenticatable
t.timestamps
end
......
......@@ -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
......
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
......@@ -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
......
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
......
......@@ -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;
......
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
......
......@@ -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
......
......@@ -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
......
......@@ -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 }
......
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 }
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
# 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
......
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'
......
......@@ -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
......
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 }
......
......@@ -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"
......
......@@ -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
......
......@@ -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"
......
......@@ -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}")
......
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")
......
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
......
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 }
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment