[issue #195] Merge branch '3.2-master' into 195-new_design_for_projects

Conflicts:
	app/views/projects/_sidebar.html.haml
This commit is contained in:
George Vinogradov 2012-03-22 18:15:57 +04:00
commit 9f23cf7727
70 changed files with 493 additions and 780 deletions

19
Gemfile
View File

@ -12,15 +12,17 @@ gem 'omniauth', '~> 1.0.3'
gem 'omniauth-openid', '~> 1.0.1'
gem 'cancan', '~> 1.6.7'
gem 'ancestry', '~> 1.2.4'
gem 'ancestry', '~> 1.2.5'
gem 'paperclip', '~> 2.7.0'
gem 'delayed_job_active_record', '~> 0.3.2'
gem 'russian', '~> 0.6.0'
gem 'highline', '~> 1.6.11'
gem 'rails-xmlrpc', '~> 0.3.6' # :git => 'git://github.com/chipiga/rails-xmlrpc.git'
# gem 'rugged', '~> 0.16.0'
gem 'grack', :git => 'git://github.com/rdblue/grack.git', :require => 'git_http'
gem "grit", :git => 'git://github.com/mojombo/grit.git', :branch => 'master'
gem "grit", :git => 'git://github.com/chipiga/grit.git'
gem 'charlock_holmes', '~> 0.6.8' #, :git => 'git://github.com/brianmario/charlock_holmes.git', :branch => 'bundle-icu'
# Wiki
gem "gollum", "1.3.1"
@ -31,8 +33,9 @@ gem 'rdiscount'
gem 'RedCloth'
gem 'wikicloth'
gem 'unicorn', '~> 4.2.0'
gem 'newrelic_rpm', '~> 3.3.2'
gem 'unicorn', '~> 4.2.0', :platforms => [:mri, :rbx]
gem 'trinidad', '~> 1.0.2', :platforms => :jruby
gem 'newrelic_rpm', '~> 3.3.2', :platforms => [:mri, :rbx]
gem 'whenever', '~> 0.7.3', :require => false
gem 'rails3-jquery-autocomplete', '~> 1.0.6'
@ -42,11 +45,12 @@ gem "haml-rails", '~> 0.3.4'
gem 'jquery-rails', '~> 2.0.1'
group :assets do
gem 'sass-rails', '~> 3.2.4'
gem 'sass-rails', '~> 3.2.5'
gem 'coffee-rails', '~> 3.2.2'
gem 'compass-rails', '~> 1.0.0.rc.3'
gem 'compass-rails', '~> 1.0.1'
gem 'uglifier', '~> 1.2.1'
gem 'therubyracer', '~> 0.9.10'
gem 'therubyracer', '~> 0.9.10', :platforms => [:mri, :rbx]
gem 'therubyrhino', '~> 1.73.1', :platforms => :jruby
end
group :production do
@ -70,4 +74,5 @@ group :test do
gem 'rspec-rails', '~> 2.8.1'
gem 'factory_girl_rails', '~> 1.7.0'
gem 'rr', '~> 1.0.4'
gem 'shoulda'
end

View File

@ -1,3 +1,12 @@
GIT
remote: git://github.com/chipiga/grit.git
revision: 696b0967cb7e6bac044569d898e5acef431d4f97
specs:
grit (2.4.1)
diff-lcs (~> 1.1)
mime-types (~> 1.15)
posix-spawn (~> 0.3.6)
GIT
remote: git://github.com/chipiga/redhillonrails_core.git
revision: 5f58167c41882890c223168b0a5521d99e8d92aa
@ -6,16 +15,6 @@ GIT
redhillonrails_core (2.0.0.pre)
activerecord (>= 3.1.0.rc)
GIT
remote: git://github.com/mojombo/grit.git
revision: 3fc864f3c637e06e2fa7a81f6b48a5df58a9bc5b
branch: master
specs:
grit (2.4.1)
diff-lcs (~> 1.1)
mime-types (~> 1.15)
posix-spawn (~> 0.3.6)
GIT
remote: git://github.com/rdblue/grack.git
revision: 020be3fef3fb308b9d214252522aa5945bf6584a
@ -26,6 +25,7 @@ GEM
remote: http://rubygems.org/
specs:
RedCloth (4.2.9)
RedCloth (4.2.9-java)
actionmailer (3.2.2)
actionpack (= 3.2.2)
mail (~> 2.4.0)
@ -58,10 +58,11 @@ GEM
builder
albino (1.3.3)
posix-spawn (>= 0.3.6)
ancestry (1.2.4)
ancestry (1.2.5)
activerecord (>= 2.2.2)
arel (3.0.2)
bcrypt-ruby (3.0.1)
bcrypt-ruby (3.0.1-java)
bluepill (0.0.60)
activesupport (>= 3.0.0)
daemons (~> 1.1.4, <= 1.1.6)
@ -77,6 +78,7 @@ GEM
net-ssh (>= 2.0.14)
net-ssh-gateway (>= 1.1.0)
capistrano_colors (0.5.5)
charlock_holmes (0.6.8)
chronic (0.6.7)
chunky_png (1.2.5)
cocaine (0.2.1)
@ -87,12 +89,12 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.2.0)
compass (0.12.rc.1)
compass (0.12.1)
chunky_png (~> 1.2)
fssm (>= 0.2.7)
sass (~> 3.1)
compass-rails (1.0.0.rc.3)
compass (~> 0.12.rc.0)
compass-rails (1.0.1)
compass (~> 0.12.0)
creole (0.4.2)
daemons (1.1.6)
delayed_job (3.0.1)
@ -108,10 +110,11 @@ GEM
diff-lcs (1.1.3)
erubis (2.7.0)
eventmachine (0.12.10)
eventmachine (0.12.10-java)
execjs (1.3.0)
multi_json (~> 1.0)
expression_parser (0.9.0)
factory_girl (2.6.1)
factory_girl (2.6.4)
activesupport (>= 2.3.9)
factory_girl_rails (1.7.0)
factory_girl (~> 2.6.0)
@ -136,16 +139,18 @@ GEM
hashie (1.2.0)
highline (1.6.11)
hike (1.2.1)
hirb (0.6.0)
hirb (0.6.2)
i18n (0.6.0)
journey (1.0.3)
jquery-rails (2.0.1)
railties (>= 3.2.0, < 5.0)
thor (~> 0.14)
jruby-rack (1.1.4)
json (1.6.5)
kgio (2.7.2)
json (1.6.5-java)
kgio (2.7.3)
libv8 (3.3.10.4)
mail (2.4.3)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
@ -160,7 +165,7 @@ GEM
thin (~> 1.2)
meta-tags (1.2.6)
actionpack
mime-types (1.17.2)
mime-types (1.18)
multi_json (1.1.0)
mustache (0.99.4)
net-scp (1.0.4)
@ -170,8 +175,9 @@ GEM
net-ssh (2.3.0)
net-ssh-gateway (1.1.0)
net-ssh (>= 1.99.1)
newrelic_rpm (3.3.2)
nokogiri (1.5.0)
newrelic_rpm (3.3.2.1)
nokogiri (1.5.2)
nokogiri (1.5.2-java)
omniauth (1.0.3)
hashie (~> 1.2)
rack
@ -245,12 +251,17 @@ GEM
sanitize (2.0.3)
nokogiri (>= 1.4.4, < 1.6)
sass (3.1.15)
sass-rails (3.2.4)
sass-rails (3.2.5)
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
shotgun (0.9)
rack (>= 1.0)
shoulda (3.0.1)
shoulda-context (~> 1.0.0)
shoulda-matchers (~> 1.0.0)
shoulda-context (1.0.0)
shoulda-matchers (1.0.0)
sinatra (1.3.2)
rack (~> 1.3, >= 1.3.6)
rack-protection (~> 1.2)
@ -266,6 +277,7 @@ GEM
state_machine (1.1.2)
therubyracer (0.9.10)
libv8 (~> 3.3.10)
therubyrhino (1.73.1)
thin (1.3.1)
daemons (>= 1.0.9)
eventmachine (>= 0.12.6)
@ -275,6 +287,10 @@ GEM
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
trinidad (1.0.5)
jruby-rack (>= 1.0.2)
trinidad_jars (>= 0.3.0)
trinidad_jars (1.0.2)
tzinfo (0.3.32)
uglifier (1.2.3)
execjs (>= 0.3.0)
@ -294,19 +310,21 @@ GEM
will_paginate (3.0.3)
PLATFORMS
java
ruby
DEPENDENCIES
RedCloth
airbrake (~> 3.0.9)
ancestry (~> 1.2.4)
ancestry (~> 1.2.5)
bluepill (~> 0.0.60)
cancan (~> 1.6.7)
cape
capistrano
capistrano_colors
charlock_holmes (~> 0.6.8)
coffee-rails (~> 3.2.2)
compass-rails (~> 1.0.0.rc.3)
compass-rails (~> 1.0.1)
creole
daemons (= 1.1.6)
delayed_job_active_record (~> 0.3.2)
@ -336,9 +354,12 @@ DEPENDENCIES
rr (~> 1.0.4)
rspec-rails (~> 2.8.1)
russian (~> 0.6.0)
sass-rails (~> 3.2.4)
sass-rails (~> 3.2.5)
shotgun
shoulda
therubyracer (~> 0.9.10)
therubyrhino (~> 1.73.1)
trinidad (~> 1.0.2)
uglifier (~> 1.2.1)
unicorn (~> 4.2.0)
whenever (~> 0.7.3)

View File

@ -1,8 +1,8 @@
# -*- encoding : utf-8 -*-
class Git::BaseController < ApplicationController
before_filter :authenticate_user!
load_and_authorize_resource :project
before_filter :find_project
before_filter :find_git_repository
before_filter :find_tags
before_filter :find_branches
@ -10,13 +10,7 @@ class Git::BaseController < ApplicationController
before_filter :set_current_tag
before_filter :set_current_branch
load_and_authorize_resource :project
protected
def find_project
@project = Project.find(params[:project_id] || params[:id])
end
def find_git_repository
@git_repository = @project.git_repository
end
@ -30,7 +24,7 @@ class Git::BaseController < ApplicationController
end
def set_treeish
@treeish = params[:treeish].present? ? params[:treeish] : @project.default_branch
@treeish = params[:treeish].presence || @project.default_branch
end
def set_current_tag

View File

@ -2,29 +2,25 @@
class Git::BlobsController < Git::BaseController
before_filter :find_tree
before_filter :find_branch
before_filter :set_commit_hash
before_filter :set_path_blob
def show
redirect_to project_path(@project) and return unless @blob.present?
if params[:raw]
image_url = Rails.root.to_s + "/" + @path
response.headers['Cache-Control'] = "public, max-age=#{12.hours.to_i}"
response.headers['Content-Type'] = @blob.mime_type
response.headers['Content-Disposition'] = 'inline'
render(:text => open(image_url).read) and return
render(:text => @blob.data) and return
end
end
def edit
redirect_to project_repo_path(@project) and return unless @blob.present?
redirect_to project_path(@project) and return unless @blob.present?
authorize! :write, @project
end
def update
redirect_to project_repo_path(@project) and return unless @blob.present?
redirect_to project_path(@project) and return unless @blob.present?
authorize! :write, @project
# Here might be callbacks for notification purposes:
# @git_repository.after_update_file do |repo, sha|
@ -33,9 +29,9 @@ class Git::BlobsController < Git::BaseController
res = @git_repository.update_file(params[:path], params[:content].gsub("\r", ''),
:message => params[:message].gsub("\r", ''), :actor => current_user, :head => @treeish)
if res
flash[:notice] = t("flash.blob.successfully_updated", :name => params[:path].encode_to_default)
flash[:notice] = t("flash.blob.successfully_updated", :name => params[:path])
else
flash[:notice] = t("flash.blob.updating_error", :name => params[:path].encode_to_default)
flash[:notice] = t("flash.blob.updating_error", :name => params[:path])
end
redirect_to :action => :show
end
@ -45,40 +41,24 @@ class Git::BlobsController < Git::BaseController
end
def raw
redirect_to project_repo_path(@project) and return unless @blob.present?
redirect_to project_path(@project) and return unless @blob.present?
headers["Content-Disposition"] = %[attachment;filename="#{@blob.name}"]
render :text => @blob.data, :content_type => @blob.mime_type
end
protected
def find_branch
@branch = @project.branch(@treeish)
end
def set_path_blob
@path = params[:path]
@unenc_path = @path.dup
@path.force_encoding(Encoding::ASCII_8BIT)
puts @path.inspect
@blob = @tree / @path
puts @blob.inspect
end
def find_branch
@branch = @project.branch(@treeish)
end
def set_commit_hash
@commit_hash = params[:commit_hash].present? ? params[:commit_hash] : nil
end
def set_path_blob
@path = params[:path]
@blob = @tree / @path
end
def find_tree
if @commit_hash
puts "1"
@tree = @git_repository.tree(@commit_hash)
@commit = @git_repository.commits(@treeish, 1).first
else
puts "2"
@tree = @git_repository.tree(@treeish)
@commit = @git_repository.log(@treeish, @path, :max_count => 1).first # TODO WTF nil ?
end
puts @tree.inspect
puts @commit.inspect
end
def find_tree
@tree = @git_repository.tree(@treeish)
@commit = @git_repository.log(@treeish, @path, :max_count => 1).first # TODO WTF nil ?
end
end

View File

@ -1,6 +1,5 @@
# -*- encoding : utf-8 -*-
class Git::CommitsController < Git::BaseController
helper_method :split_commits_by_date
def index
@ -22,7 +21,7 @@ class Git::CommitsController < Git::BaseController
respond_to do |format|
format.html
format.diff { render :text => (@commit.diffs.map{|d| d.diff}.join("\n") rescue ''), :content_type => "text/plain" }
format.diff { render :text => (@commit.diffs.map(&:diff).join("\n") rescue ''), :content_type => "text/plain" }
format.patch { render :text => (@commit.to_patch rescue ''), :content_type => "text/plain" }
end
end
@ -40,5 +39,4 @@ class Git::CommitsController < Git::BaseController
end
return res
end
end

View File

@ -1,11 +0,0 @@
# -*- encoding : utf-8 -*-
class Git::RepositoriesController < Git::BaseController
def show
@commit = @git_repository.master
@tree = @commit ? @commit.tree : nil
render :template => "git/repositories/empty" unless @tree
end
end

View File

@ -1,26 +1,18 @@
# -*- encoding : utf-8 -*-
class Git::TreesController < Git::BaseController
def show
if params[:treeish].present? and @treeish.dup.encode_to_default == @project.default_branch
redirect_to project_path(@project) and return
end
redirect_to project_path(@project) and return if params[:treeish] == @project.default_branch and params[:path].blank?
@path = params[:path]
@tree = @git_repository.tree(@treeish)
@branch = @project.branch(@treeish)
# @commit = @git_repository.commits(@treeish, 1).first
# Raises Grit::Git::GitTimeout
@commit = @branch.present? ? @branch.commit() : @git_repository.log(@treeish, @path, :max_count => 1).first
render :template => "git/repositories/empty" and return unless @commit
render :template => "git/trees/empty" and return unless @commit
if @path
@path.force_encoding(Encoding::ASCII_8BIT)
@tree = @tree / @path
end
render :template => "git/repositories/show"
@tree = @tree / @path if @path
render :template => "git/trees/show"
end
end

View File

@ -7,7 +7,8 @@ class GroupsController < ApplicationController
before_filter :authenticate_user!
before_filter :find_group, :only => [:show, :edit, :update, :destroy]
load_and_authorize_resource
load_and_authorize_resource :except => :create
authorize_resource :only => :create
autocomplete :group, :uname
def index
@ -34,8 +35,9 @@ class GroupsController < ApplicationController
end
def create
@group = Group.new params[:group]
@group = Group.new(:description => params[:group][:description])
@group.owner = current_user
@group.uname = params[:group][:uname]
if @group.save
flash[:notice] = t('flash.group.saved')

View File

@ -5,7 +5,7 @@ module CommitHelper
res = ["<table class='commit_stats'>"]
stats.files.each do |filename, adds, deletes, total|
res << "<tr>"
res << "<td><a href='##{h(filename)}'>#{h(filename)}</a></td>".encode_to_default
res << "<td><a href='##{h(filename)}'>#{h(filename)}</a></td>"
res << "<td class='diffstat'>"
res << I18n.t("layout.projects.inline_changes_count", :count => total).strip +
" (" +
@ -17,7 +17,7 @@ module CommitHelper
end
res << "</table>"
res.join("\n").encode_to_default.html_safe
res.join("\n").html_safe.default_encoding!
end
# def format_commit_message(message)
@ -38,11 +38,11 @@ module CommitHelper
def short_commit_message(message)
# Why 42? Because it is the Answer!
truncate(message, :length => 42, :omission => "...").encode_to_default
truncate(message, :length => 42, :omission => "...")
end
def commit_author_link(author)
name = author.name.encode_to_default
name = author.name
email = author.email
u = User.where(:email => email).first
u.present? ? link_to(name, user_path(u)) : mail_to(email, name)

View File

@ -8,11 +8,11 @@ module DiffHelper
res = "<table class='diff inline' cellspacing='0' cellpadding='0'>"
res += "<tbody>"
res += diff_display.render(Git::Diff::InlineCallback.new).encode_to_default
res += diff_display.render(Git::Diff::InlineCallback.new)
res += "</tbody>"
res += "</table>"
res.html_safe.encode_to_default
res.html_safe
end
end

View File

@ -26,15 +26,7 @@ module GitHelper
res = "#{link_to @project.name, tree_path(@project)} /"
end
res.encode_to_default.html_safe
end
def blob_file_path
if @commit_hash.present?
blob_commit_path(@project, @commit_hash, @path)
else
blob_path(@project, @treeish, @path)
end
res.html_safe
end
def render_line_numbers(n)
@ -45,22 +37,19 @@ module GitHelper
end
def render_blob(blob)
res = ""
blob.data.encode_to_default.split("\n").collect do |line|
"<div>#{line.present? ? h(line) : "<br>"}</div>"
end.join
blob.data.split("\n").collect do |line|
content_tag :div, line.present? ? h(line) : tag(:br)
end.join.html_safe
end
def choose_render_way(blob)
return :image if blob.mime_type.match(/image/)
return :binary if blob.binary?
:text
# return :text if blob.mime_type.match(/text|xml|json/)
# :binary
end
def force_encoding_to_site(string)
string.dup.encode_to_default
case
when blob.mime_type.match(/image/); :image
when blob.binary?; :binary
else
@text = @blob.data.split("\n")
:text
end
end
def iterate_path(path, &block)
@ -76,21 +65,16 @@ module GitHelper
# TODO This is very dirty hack. Maybe need to be changed.
def branch_selector_options(project)
tmp = params.dup
unless tmp['treeish'].present?
tmp.merge!('project_id' => project.id, 'treeish' => project.default_branch).delete('id')
end
tmp.delete('treeish') if tmp['commit_hash'].present?
res = {}
current = url_for(tmp).split('?', 2).first
tmp['commit_hash'] = truncate(tmp['commit_hash'], :length => 20) if tmp['commit_hash']
p = params.dup
p.delete(:path) if p[:path].present? # to root path
p.merge!(:project_id => project.id, :treeish => project.default_branch).delete(:id) unless p[:treeish].present?
current = url_for(p).split('?', 2).first
res = project.branches.inject(res) do |h, branch|
h[truncate(branch.name, :length => 20)] = url_for(tmp.merge('treeish' => branch.name)).split('?', 2).first
h
end
res.merge!(tmp['commit_hash'] || tmp['treeish'] => current)
res = []
res << [I18n.t('layout.git.repositories.commits'), [truncate(params[:treeish], :length => 20)]] unless (project.branches + project.tags).map(&:name).include?(params[:treeish] || project.default_branch)
res << [I18n.t('layout.git.repositories.branches'), project.branches.map{|b| [truncate(b.name, :length => 20), url_for(p.merge :treeish => b.name).split('?', 2).first]}]
res << [I18n.t('layout.git.repositories.tags'), project.tags.map{|t| [truncate(t.name, :length => 20), url_for(p.merge :treeish => t.name).split('?', 2).first]}]
options_for_select(res.sort, current).html_safe
grouped_options_for_select(res, current)
end
end

View File

@ -82,7 +82,7 @@ module WikiHelper
end
def author
@page.version.author.name.encode_to_default
@page.version.author.name
end
def author_email

View File

@ -62,7 +62,7 @@ class ActivityFeedObserver < ActiveRecord::Observer
:user => subscribe.user,
:kind => 'new_comment_commit_notification',
:data => {:user_name => record.user.name, :user_email => record.user.email, :user_id => record.user_id, :comment_body => record.body,
:commit_message => record.commentable.message.encode_to_default, :commit_id => record.commentable.id,
:commit_message => record.commentable.message, :commit_id => record.commentable.id,
:project_id => record.project.id, :comment_id => record.id, :project_name => record.project.name, :project_owner => record.project.owner.uname}
)
end

View File

@ -51,8 +51,6 @@ class Git::Repository
#
# Returns commits sha if committing was successful and false otherwise
def update_file(path, data, options = {})
path.force_encoding(Encoding::ASCII_8BIT) # some magic
head = options[:head].to_s || 'master'
actor = get_actor(options[:actor])
filename = File.split(path).last

View File

@ -22,6 +22,7 @@ class Group < ActiveRecord::Base
scope :by_owner, lambda {|owner| where(:owner_id => owner.id)}
scope :by_admin, lambda {|admin| joins(:relations).where(:'relations.role' => 'admin', :'relations.target_id' => admin.id, :'relations.target_type' => 'User')}
attr_accessible :description
attr_readonly :own_projects_count
delegate :ssh_key, :email, :to => :owner

View File

@ -118,11 +118,11 @@ class Project < ActiveRecord::Base
# ... and add it to result.
h[entry] = c
# find another files, that linked to this commit and set them their commit
c.diffs.map{|diff| diff.b_path.split(File::SEPARATOR, 2).first}.each do |name|
h.each_pair do |k, v|
h[k] = c if k.name == name and v.nil?
end
end
# c.diffs.map{|diff| diff.b_path.split(File::SEPARATOR, 2).first}.each do |name|
# h.each_pair do |k, v|
# h[k] = c if k.name == name and v.nil?
# end
# end
end
h
end

View File

@ -64,7 +64,7 @@ class GitPresenters::CommitAsMessagePresenter < ApplicationPresenter
@committer_link ||= if committer.is_a? User
link_to committer.uname, user_path(committer)
else
mail_to committer.email.encode_to_default, committer.name.encode_to_default
mail_to committer.email, committer.name
end
end
@ -73,7 +73,7 @@ class GitPresenters::CommitAsMessagePresenter < ApplicationPresenter
end
def prepare_message
(@caption, @content) = @commit.message.encode_to_default.split("\n\n", 2)
(@caption, @content) = @commit.message.split("\n\n", 2)
@caption = 'empty message' unless @caption.present?
if @caption.length > 72
tmp = '...' + @caption[69..-1]

View File

@ -12,7 +12,7 @@
(#{commit_author_link(committer)})
%br
%span.date= commit_date(elem[0].committed_date)
%span.message{:title => elem[0].message.encode_to_default}= short_commit_message(elem[0].message)
%span.message{:title => elem[0].message}= short_commit_message(elem[0].message)
%td.lines
= index
@ -20,7 +20,7 @@
%td.code.cm-s-default
%pre
%div= elem[1].first.encode_to_default
%div= elem[1].first
- elem[1][1..-1].each do |line|
%tr
@ -29,7 +29,7 @@
- index += 1
%td.code.cm-s-default
%pre
%div= line.encode_to_default
%div= line
:javascript
$(document).ready(function() {

View File

@ -4,43 +4,20 @@
= render :partial => 'git/shared/fork'
.both
= form_tag blob_file_path, :name => 'blob-editor', :method => :put do
.file
= text_area_tag :content, @blob.data.encode_to_default, :id => 'code'
= form_tag blob_path(@project, @treeish, @path), :name => 'blob-editor', :method => :put do
.file= text_area_tag :content, @blob.data, :id => 'code'
.both
= t("layout.enter_commit_message")
= text_area_tag :message, "Updated #{@blob.name.encode_to_default}", :class => 'commit-message'
= text_area_tag :message, "Updated #{@blob.name}", :class => 'commit-message'
%br
%br
= submit_tag t("layout.save"), :title => t("layout.save")
= t("layout.or")
= link_to t("layout.cancel"), blob_file_path, :class => 'button'
-##gollum-editor.edit{:'data-escaped-name' => @path.encode_to_default}
= form_tag blob_file_path, :name => 'blob-editor', :method => :put do
%fieldset#gollum-editor-fields
= text_area_tag :content, @blob.data.encode_to_default, :id => "gollum-editor-body"
#gollum-editor-edit-summary.singleline
= label_tag :message, t("wiki.edit_commit_message"), :class => "jaws"
= text_field_tag :message, t("wiki.commit_message_placeholder"), :id => "editor-commit-message-field"
%span.jaws
%br
= submit_tag t("wiki.save_button"), :id => "gollum-editor-submit", :title => t("wiki.save_changes")
= link_to t("layout.cancel"), blob_file_path, :class => 'minibutton', :id => 'gollum-editor-preview'
= link_to t("layout.cancel"), blob_path(@project, @treeish, @path), :class => 'button'
:javascript
$(function() {
var editor = CodeMirror.fromTextArea(document.getElementById('code'), {lineNumbers: true, mode: '#{@blob.raw_mime_type.content_type}', theme: 'eclipse'});
});
/ - content_for :javascripts do
/ = javascript_include_tag 'gollum/gollum.placeholder.js', 'blob.editor.js'
/
/ - content_for :stylesheets do
/ = stylesheet_link_tag 'gollum/editor.css'
});

View File

@ -6,21 +6,7 @@
- render_way = choose_render_way(@blob)
.file
.top
.l
= @blob.mode + ' | '
- if (render_way == :text)
- text = @blob.data.split("\n")
= "#{text.length} lines (#{text.select{|s| s.strip.length > 0}.length} sloc) | "
= "#{(@blob.size / 1024.0).round(3)} Kb"
.r
- if render_way == :text and can? :write, @project and @treeish.in? @project.branches.map(&:name)
= raw "#{link_to "Edit", edit_blob_path(@project, @treeish, @path) } | "
= raw "#{link_to "Raw", raw_path(@project, @treeish, @path)} | "
- if render_way == :text
= raw "#{link_to "Blame", blame_path(@project, @treeish, @path)} | "
= link_to "History", commits_path(@project, @treeish, @path)
.both
.top= render 'top', :render_way => render_way
.data
- case render_way
- when :image
@ -33,13 +19,12 @@
<center> <img src='?raw=true'/></center>
<br/>
- when :text
.gutter
= render_line_numbers(text.length)
.gutter= render_line_numbers(@text.length)
#output.formatted.cm-s-default
%pre#code
=#{render_blob(@blob)}
:preserve
#{h(@blob.data.encode_to_default).html_safe}
#{h(@blob.data).html_safe}
.both
- when :binary
%table.table.blob
@ -48,7 +33,7 @@
%td.blob
:plain
<br/>
<pre>#{ link_to @blob.basename.encode_to_default, raw_path(@project, @treeish, @path) }</pre>
<pre>#{ link_to @blob.basename, raw_path(@project, @treeish, @path) }</pre>
<br/>
:javascript
$(document).ready(function() {

View File

@ -0,0 +1,21 @@
.l
= @blob.mode
\|
- if render_way == :text
#{@text.length} lines (#{@text.select{|s| s.strip.length > 0}.length} sloc)
\|
= number_to_human_size @blob.size
.r
- if render_way == :text and can? :write, @project and @treeish.in? @project.branches.map(&:name)
= link_to "Edit", edit_blob_path(@project, @treeish, @path)
\|
- if render_way == :text and params[:action] != 'show'
= link_to "Normal", blob_path(@project, @treeish, @path)
\|
= link_to "Raw", raw_path(@project, @treeish, @path)
\|
- if render_way == :text and params[:action] != 'blame'
= link_to "Blame", blame_path(@project, @treeish, @path)
\|
= link_to "History", commits_path(@project, @treeish, @path)
.both

View File

@ -16,81 +16,10 @@
#repo-wrapper
%h3= t("layout.projects.files_in_project")
.files
.l
= render :partial => 'git/shared/whereami'
.l= render :partial => 'git/shared/whereami'
.both
- render_way = choose_render_way(@blob)
.file
.top
.l
= @blob.mode + ' | '
- if (render_way == :text)
- text = @blob.data.split("\n")
= "#{text.length} lines (#{text.select{|s| s.strip.length > 0}.length} sloc) | "
= "#{(@blob.size / 1024.0).round(3)} Kb"
.r
= raw "#{link_to "Normal", blob_path(@project, @treeish, @path) } | "
= raw "#{link_to "Raw", raw_path(@project, @treeish, @path)} | "
=# raw "#{link_to "Blame", blame_path(@project, @treeish, @path)} | "
= link_to "History", commits_path(@project, @treeish, @path)
.both
.blame_data
= render :partial => 'blame_table'
-#.block
= render :partial => "git/shared/navigation"
= render :partial => "git/shared/info"
-#- if @commit
.block
.content
.inner
= render :partial => "git/commits/commits", :object => [@commit]
-#.block
.content
.inner
%h3= render_path
.blob_header
.size #{(@blob.size / 1024.0).round(3)} Kb
.buttons
- if @commit_hash
#{link_to "Raw", raw_commit_path(@project, @commit_hash, @path)} #{link_to "Normal", blob_commit_path(@project, @commit_hash, @path)} #{link_to "History", commits_path(@project, @treeish, @path)}
- else
#{link_to "Raw", raw_path(@project, @treeish, @path)} #{link_to "Normal", blob_path(@project, @treeish, @path)} #{link_to "History", commits_path(@project, @treeish, @path)}
.clear
.blame_data
%table.table.blame
- index = 1
- @blame.each do |elem|
%tr
%td.message{ :rowspan => elem[1].length }
.commit
#{link_to shortest_hash_id(elem[0].id), commit_path(@project, elem[0].id)} by
#{elem[0].author.to_s.encode_to_default} #{elem[0].author != elem[0].committer ? "(#{elem[0].committer.to_s.encode_to_default})" : "" }
.message
%span.date= commit_date(elem[0].committed_date)
%span.message= short_commit_message(elem[0].message)
%td.lines
= index
- index += 1
%td.code
%pre
%div= elem[1].first.encode_to_default
- elem[1][1..-1].each do |line|
%tr
%td.lines
= index
- index += 1
%td.code
%pre
%div= line.encode_to_default
-#- content_for :sidebar, render(:partial => 'git/shared/sidebar')
.top= render 'top', :render_way => render_way
.blame_data= render 'blame_table'

View File

@ -1,21 +1 @@
= render :partial => "git/blobs/editor", :layout => 'projects/show'
-#.block
-# = render :partial => "git/shared/navigation"
-#
-# = render :partial => "git/shared/info"
-#
-#- if @commit
-# .block
-# .content
-# .inner
-# = render :partial => "git/commits/commits", :object => [@commit]
-#
-#.block
-# .content
-# .inner
-# %h3 #{render_path} (#{@blob.mime_type})
-#
-# = render :partial => 'editor'
-#
-#- content_for :sidebar, render(:partial => 'git/shared/sidebar')
-#

View File

@ -1,11 +1,10 @@
- commit_id = commit_diff.deleted_file ? @commit.parents.first.id : @commit.id
.file
%a{ :name => h(commit_diff.a_path.encode_to_default) }
%a{:name => h(commit_diff.a_path)}
.top
.l= h(commit_diff.a_path.encode_to_default)
.l= h(commit_diff.a_path)
- if commit_diff.b_path.present?
.r
= link_to("view file @ #{short_hash_id(@commit.id)}", blob_commit_path(@project, @commit.id, commit_diff.b_path.encode_to_default))
.r= link_to "view file @ #{short_hash_id(commit_id)}", blob_path(@project, commit_id, commit_diff.b_path)
.clear
.diff_data
= render_diff(commit_diff)
.diff_data= render_diff(commit_diff) unless (@git_repository.tree(commit_id) / commit_diff.b_path).binary?

View File

@ -9,37 +9,10 @@
- by_month.each_pair do |month, by_day|
- by_day.each_pair do |day, commits|
.date-block
.date
= raw l(commits.first.authored_date, :format => :date_block_format)
.date= raw l(commits.first.authored_date, :format => :date_block_format)
.messages
- commits.each_with_index do |commit|
- GitPresenters::CommitAsMessagePresenter.present(commit, :branch => @branch, :project => @project) do |presenter|
= render :partial => 'shared/feed_message', :locals => {:presenter => presenter, :item_no => counter}
- counter += 1
.both
-#%ul.list.commits
- commits.each do |commit|
%li.commit
%table
%tr
%td.committers
.author #{commit.author.to_s.encode_to_default}, #{commit_date(commit.authored_date)}
- if commit.committer != commit.author
.committer
(committed by: #{commit.committer.to_s.encode_to_default}, #{commit_date(commit.committed_date)})
%td.message
%p= link_to commit.message.encode_to_default, commit_path(@project, commit.id)
%td.trees
.commit
Commit:
%span{ :style => "float: right;"}
#{link_to short_hash_id(commit.id), commit_path(@project, commit.id)}
.tree
Tree:
%span{ :style => "float: right;"}
#{link_to short_hash_id(commit.tree.id), tree_path(@project, :treeish => commit.tree.id)}
- commit.parents.each do |parent|
.parent
Parent:
%span{ :style => "float: right;"}
#{link_to short_hash_id(parent.id), tree_path(@project, :treeish => parent.id)}
.both

View File

@ -1,10 +1,10 @@
.pagination.tmargin30
- if @page == 1
%span.previous_page.disabled « Previous
%span.previous_page.disabled= t('will_paginate.previous_label')
- else
%a.previous_page{ :rel => "prev", :href => commits_path(@project, :treeish => @treeish, :page => (@page - 1)) } « Previous
%a.previous_page{:rel => "prev", :href => commits_path(@project, :treeish => @treeish, :page => (@page - 1))}= t('will_paginate.previous_label')
- if @last_page
%span.next_page.disabled Next »
%span.next_page.disabled= t('will_paginate.next_label')
- else
%a.next_page{ :rel => "next", :href => commits_path(@project, :treeish => @treeish, :page => (@page + 1)) } Next »
%a.next_page{:rel => "next", :href => commits_path(@project, :treeish => @treeish, :page => (@page + 1))}= t('will_paginate.next_label')

View File

@ -2,16 +2,4 @@
= render :partial => 'projects/repo_block', :locals => {:project => @project}
= render :partial => 'git/commits/commits', :object => @commits
- if @render_paginate
= render :partial => 'git/commits/paginate'
-#.block
.content
.inner
= render :partial => "git/commits/commits", :object => @commits
- if @render_paginate
.actions-bar.wat-cf
.pagination
= render :partial => "git/commits/paginate"
-# content_for :sidebar, render(:partial => 'git/shared/sidebar')
= render 'git/commits/paginate' if @render_paginate

View File

@ -17,43 +17,3 @@
= render :partial => "comments/list", :locals => {:list => Project.commit_comments(@commit, @project), :project => @project, :commentable => @commit}
= render :partial => "comments/add", :locals => {:project => @project, :commentable => @commit}
-#.block
= render :partial => "git/shared/navigation"
= render :partial => "git/shared/info"
-#.block
.content
.inner
= render :partial => "git/commits/commits", :object => [@commit]
-#- begin
.block
.content
.inner
.patch_and_diff
= link_to "raw diff", commit_path(@project, @commit.id, :diff)
\|
= link_to "patch", commit_path(@project, @commit.id, :patch)
.clear
= render_commit_stats(@commit.stats)
= render :partial => "git/commits/commit_diff", :collection => @commit.diffs
-#- rescue Grit::Git::GitTimeout
.block
.content
.inner
%p= t 'layout.git.repositories.commit_diff_too_big'
-#- content_for :sidebar, render(:partial => 'git/shared/sidebar')
-#= render :partial => "comments/list", :locals => {:list => Project.commit_comments(@commit, @project), :project => @project, :commentable => @commit}
-#%p
%b
= t('layout.issues.subscribe')
\:
- if Subscribe.subscribed_to_commit?(@project, current_user, @commit)
= link_to t('layout.commits.unsubscribe_btn'), unsubscribe_commit_path(@project, @commit), :method => :delete
- else
= link_to t('layout.commits.subscribe_btn'), subscribe_commit_path(@project, @commit), :method => :post

View File

@ -1 +0,0 @@
= render :partial => "git/repositories/show", :layout => 'projects/show'

View File

@ -1,23 +0,0 @@
.content
.inner
%p
%b
= t("activerecord.models.project")
\:
= @project.name
%p
%b
= t("activerecord.attributes.project.repository")
\:
= git_repo_url @project.git_repo_name
- if @current_tag.present?
%p
%b Tag:
= link_to @current_tag.name, tree_path(@project, :treeish => @current_tag.name)
- if @current_branch.present?
%p
%b Branch:
= link_to @current_branch.name, tree_path(@project, :treeish => @current_branch.name)

View File

@ -1,29 +0,0 @@
.secondary-navigation
%ul.wat-cf
%li.first= link_to t("layout.projects.list"), projects_path
%li= link_to t("layout.projects.new"), new_project_path
%li= link_to t("layout.projects.show"), project_path(@project)
%li.active= link_to t("layout.git.repositories.source"), project_repo_path(@project)
- if can? :write, @project
%li= link_to t("layout.projects.build"), new_project_build_list_path(@project)
%ul#git_submenu.sub-wat-cf.wat-cf
%li= link_to t("layout.git.repositories.commits"), commits_path(@project, :treeish => @treeish)
%li
%a{ :href => "#", :onmouseover => "menu.open('branches')", :onmouseout => "menu.close_time()" } Branches
#branches{ :onmouseover => "menu.cancel_close_time()", :onmouseout => "menu.close_time()" }
- @branches.each do |branch|
- if branch.name == @treesh
%span.current= branch.name
- else
= link_to branch.name, tree_path(@project, :treeish => branch.name)
%li
%a{ :href => "#", :onmouseover => "menu.open('tags')", :onmouseout => "menu.close_time()" } Tags
#tags{ :onmouseover => "menu.cancel_close_time()", :onmouseout => "menu.close_time()" }
- @tags.each do |tag|
- if tag.name == @treeish
%span.current= tag.name
- else
= link_to tag.name, tree_path(@project, :treeish => tag.name)
.clear

View File

@ -1,4 +0,0 @@
.block.notice
%h3= t("layout.projects.current_project_header")
.content
%p= link_to @project.name, project_path(@project)

View File

@ -1,10 +1,10 @@
%p#file-name1
= link_to @project.name, tree_path(@project, :treeish => @treeish.encode_to_default)
= link_to @project.name, tree_path(@project, :treeish => @treeish)
= File::SEPARATOR
- if @path.present?
- paths = File.split(@path)
- if paths.size > 1 and paths.first != '.'
- iterate_path(paths.first) do |path, name|
= link_to(name, tree_path(@project, @treeish, path)).encode_to_default
= link_to(name, tree_path(@project, @treeish, path))
= File::SEPARATOR
= paths.last.encode_to_default
= paths.last

View File

@ -16,27 +16,22 @@
%tr
%td
.pic= image_tag 'folder.png'
.name
= link_to "..", tree_path(@project, @treeish, File.join([@path.dup.encode_to_default, ".."].compact).encode_to_default)
.name= link_to "..", tree_path(@project, @treeish, File.join([@path, ".."].compact))
%td== &nbsp;
%td== &nbsp;
%td== &nbsp;
- @project.tree_info(@tree, @treeish, @path).each_pair do |entry, commit|
%tr
%td
- entry_path = File.join([@path.present? ? @path : nil, entry.name].compact).encode_to_default
- entry_path = File.join([@path.present? ? @path : nil, entry.name].compact)
- if entry.is_a? Grit::Blob
.pic= image_tag 'code.png'
.name
= link_to(entry.name, blob_path(@project, @treeish, entry_path), :class => 'files-see').encode_to_default
.name= link_to(entry.name, blob_path(@project, @treeish, entry_path), :class => 'files-see')
- else
.pic= image_tag 'folder.png'
.name
= link_to(entry.name, tree_path(@project, @treeish, entry_path), :class => 'files-see').encode_to_default
.name= link_to(entry.name, tree_path(@project, @treeish, entry_path), :class => 'files-see')
%td
%span{:style => "display: none;"}= commit.committed_date || commit.authored_date#> Dec 31, 2011
= l(commit.committed_date || commit.authored_date, :format => :short) #31 декабря 2011
%td
= commit.short_message.encode_to_default #Redo autostart script to start from user
%td
= (commit.committer || commit.author).name.encode_to_default #chipiga
%span{:style => "display: none;"}= commit.committed_date || commit.authored_date
= l(commit.committed_date || commit.authored_date, :format => :short)
%td= commit.short_message
%td= (commit.committer || commit.author).name

View File

@ -12,8 +12,7 @@
%h3= t("layout.projects.files_in_project")
.files
.l
= render :partial => 'git/shared/whereami'
.l= render :partial => 'git/shared/whereami'
.both
%table#myTable.tablesorter.project{:cellpadding => "0", :cellspacing => "0"}

View File

@ -0,0 +1 @@
= render :partial => "git/trees/show", :layout => 'projects/show'

View File

@ -1,8 +1,8 @@
.lineForm.fork
= select_tag :branch, branch_selector_options(project), :id => 'branch_selector', :class => 'sel80'
%form{ :action => '', :method => :get, :id => 'branch_changer', :'data-action' => "#{controller_name}"}
%form{:action => '', :method => :get, :id => 'branch_changer', :'data-action' => "#{controller_name}"}
.fork
%p= t("layout.projects.#{params[:commit_hash].present? ? 'current_commit' : 'current_branch'}")+':'
%p #{t('layout.projects.current_branch')}:
.both
:javascript
@ -12,4 +12,4 @@
$form.attr('action', $(this).val());
$form.submit();
});
});
});

View File

@ -1,19 +0,0 @@
.activity
.top
.image
%img{:alt => "avatar", :src => presenter.image}
.text.imaged
%span.name= presenter.header
%br/
%span.date= presenter.date
%br/
%span.subject
= presenter.caption
- if presenter.expandable? and presenter.content?
%span.data-expander.collapsed{:id => "expand#{item_no}"} &nbsp;
/ = image_tag 'expand-gray.png', :class => 'activity-full', :id => 'expand1', :onclick => "showActivity(4)"
.both
- if presenter.content?
.fulltext{:class => presenter.expandable? ? "hidden" : '',
:id => presenter.expandable? ? "content-expand#{item_no}" : ''}
= presenter.content

View File

@ -1,18 +1,13 @@
- act = controller.action_name.to_sym
- if [:new, :create].include? act
.leftlist
= f.label :name, t("activerecord.attributes.project.name"), :class => :label
.rightlist
= f.text_field :name, :class => 'text_field', :disabled => f.object.try(:persisted?)
.leftlist= f.label :name, t("activerecord.attributes.project.name"), :class => :label
.rightlist= f.text_field :name, :class => 'text_field', :disabled => f.object.try(:persisted?)
.both
.leftlist
= f.label :description, t("activerecord.attributes.project.description"), :class => :label
.rightlist
= f.text_area :description, :class => 'text_field', :cols => 80
.leftlist= f.label :description, t("activerecord.attributes.project.description"), :class => :label
.rightlist= f.text_area :description, :class => 'text_field', :cols => 80
.both
- if ['new', 'create'].include? controller.action_name
.leftlist
= f.label :owner_id, t("activerecord.attributes.project.owner"), :class => :label
.leftlist= f.label :owner_id, t("activerecord.attributes.project.owner"), :class => :label
.rightlist
= label_tag t("activerecord.attributes.project.who_owns.me")
- if Group.can_own_project(current_user).count > 0
@ -27,13 +22,10 @@
= hidden_field_tag :who_owns, :me
.both
-#- if [:new, :create].include? act
-# .leftlist
-# = f.label :category_id, t("activerecord.attributes.project.category_id"), :class => :label
-# .rightlist
-# = f.grouped_collection_select :category_id, Category.roots, :children, :name, :id, :name, :include_blank => true
-# .leftlist= f.label :category_id, t("activerecord.attributes.project.category_id"), :class => :label
-# .rightlist= f.grouped_collection_select :category_id, Category.roots, :children, :name, :id, :name, :include_blank => true
-# .both
.leftlist
= f.label :visibility, t("activerecord.attributes.project.visibility"), :class => :label
.leftlist= f.label :visibility, t("activerecord.attributes.project.visibility"), :class => :label
.rightlist
=# f.select :visibility, Project::VISIBILITIES
- Project::VISIBILITIES.each do |visibility|
@ -45,30 +37,23 @@
= t("activerecord.attributes.project.visibilities.#{visibility}")
.both
- if [:edit, :update].include? act
.leftlist
Ветка по умолчанию:
.rightlist
= f.select :default_branch, options_from_collection_for_select(@project.branches, :name, :name, @project.default_branch), :class => 'sel80', :id => 'branch_selector'
.leftlist= t("activerecord.attributes.project.default_branch")
.rightlist= f.select :default_branch, options_from_collection_for_select(@project.branches, :name, :name, @project.default_branch), :class => 'sel80', :id => 'branch_selector'
.both
- if [:edit, :update].include? act
.leftlist
\ 
.rightlist
.check
%span#niceCheckbox1.niceCheck-main
= f.check_box :is_rpm#, :class => 'niceCheckbox1'
.forcheck
Проект является пакетом
%span#niceCheckbox1.niceCheck-main= f.check_box :is_rpm#, :class => 'niceCheckbox1'
.forcheck= t("activerecord.attributes.project.is_rpm")
.both
.both
- if [:new, :create].include? act
.leftlist
= f.label :srpm, t("activerecord.attributes.project.srpm"), :class => :label
.rightlist
= f.file_field :srpm, :class => 'file_field'
.leftlist= f.label :srpm, t("activerecord.attributes.project.srpm"), :class => :label
.rightlist= f.file_field :srpm, :class => 'file_field'
.both
.leftlist
\ 
.rightlist
= submit_tag t("layout.save"), :class => 'button'
.rightlist= submit_tag t("layout.save"), :class => 'button'
.both

View File

@ -1,13 +0,0 @@
%table.table
%tr
%th= t("activerecord.attributes.project.name")
%th= t("activerecord.attributes.project.owner")
%th.last &nbsp;
- @projects.each do |project|
%tr{:class => cycle("odd", "even")}
%td= link_to "#{project.name}", project
%td= link_to "#{project.owner.name} (#{project.owner.uname})", project.owner
%td
= link_to t("layout.edit"), edit_project_path(project) if can? :update, project
|
= link_to t("layout.delete"), project_path(project), :method => :delete, :confirm => t("layout.projects.confirm_delete") if can? :destroy, project

View File

@ -1,8 +1,6 @@
.description-top
= text_field_tag :url, git_repo_url(project.git_repo_name), :class => 'name',
:type => 'text',:spellcheck => 'false', :readonly => true
.role
= t("layout.read_write_access")
= text_field_tag :url, git_repo_url(project.git_repo_name), :class => 'name', :spellcheck => 'false', :readonly => true
.role= t("layout.read_write_access")
= render :partial => 'projects/branch_select', :locals => {:project => project}
.both
:javascript
@ -10,4 +8,4 @@
$('#url').live('click', function() {
$(this).select();
});
});
});

View File

@ -9,7 +9,6 @@
- if can? :edit, @project
%li{:class => (act == :edit && contr == :projects) ? 'active' : ''}
= link_to t("layout.projects.edit"), edit_project_path(@project)
- if can? :manage_collaborators, @project
%li{:class => (act == :sections && contr == :projects) ? 'active' : ''}
= link_to t("layout.projects.sections"), sections_project_path(@project)
- if can? :manage_collaborators, @project

View File

@ -5,9 +5,7 @@
= render :partial => "form", :locals => {:f => f}
.hr
.leftside
= t("layout.projects.delete_warning")
.rightside
= link_to t("layout.delete"), project_path(@project), :method => :delete, :confirm => t("layout.projects.confirm_delete"), :class => 'button' if can? :destroy, @project
.leftside= t("layout.projects.delete_warning")
.rightside= link_to t("layout.delete"), project_path(@project), :method => :delete, :confirm => t("layout.projects.confirm_delete"), :class => 'button' if can? :destroy, @project
.both

View File

@ -3,25 +3,20 @@
= form_for @project, :url => sections_project_path(@project), :method => :post, :html => { :class => :form, :multipart => true } do |f|
.leftside.w25
%span.niceCheck-main{:onclick => "changeCheck(this)"}
= f.check_box :has_issues
%span.niceCheck-main{:onclick => "changeCheck(this)"}= f.check_box :has_issues
.leftside.w420
= t("activerecord.attributes.project.has_issues")
%br
%span{:style => "font-size: 11px;"}
= t("layout.projects.has_issue_description")
%span{:style => "font-size: 11px;"}= t("layout.projects.has_issue_description")
.both
.leftside.w25
%span.niceCheck-main{:onclick => "changeCheck(this)"}
= f.check_box :has_wiki, :class => 'niceCheck-main'
%span.niceCheck-main{:onclick => "changeCheck(this)"}= f.check_box :has_wiki, :class => 'niceCheck-main'
.leftside.w420
= t("activerecord.attributes.project.has_wiki")
%br
%span{:style => "font-size: 11px;"}
= t("layout.projects.has_wiki_description")
%span{:style => "font-size: 11px;"}= t("layout.projects.has_wiki_description")
.both
.padd25
= submit_tag t("layout.save"), :class => 'button'
.padd25= submit_tag t("layout.save"), :class => 'button'
.both
:javascript

View File

@ -1,4 +1,4 @@
.blob_header
.size= h(diff.deleted_file ? diff.a_path : diff.b_path).encode_to_default
.size= h(diff.deleted_file ? diff.a_path : diff.b_path)
.clear
.diff_data.highlight= render_diff(diff)

View File

@ -10,14 +10,14 @@
- user = User.where(:email => v.author.email).first
.avatar
= link_to user_path_by_user(user) do
%img.mini-gravatar{:src => gravatar_url(v.author.email), :alt => "avatar: #{v.author.name.encode_to_default}"}
= image_tag avatar_url_by_email(v.author.email), :alt => "avatar: #{v.author.name}", :class => 'mini-gravatar'
.name
= link_to user_path_by_user(user) do
%span.username= user.present? ? "#{user.uname} (#{user.name})" : v.author.name.encode_to_default
%span.username= user.present? ? "#{user.uname} (#{user.name})" : v.author.name
.both
%td.td3
%span.wiki-gray= "#{l v.committed_date.to_date, :format => :long}:"
= v.message.encode_to_default
= v.message
- if @name
= raw "[#{link_to v.id[0..6], versioned_project_wiki_path(@project, escaped_name, v.id), :title => t("wiki.view_commit")}]"
- else
@ -38,4 +38,4 @@
cbx.removeAttr('checked');
}
}
});
});

View File

@ -1,24 +0,0 @@
.block
.secondary-navigation
%ul.wat-cf
%li.first= link_to t("layout.projects.list"), projects_path
%li= link_to t("layout.projects.new"), new_project_path
%li= link_to t("layout.projects.show"), project_path(@project)
%li= link_to t("layout.git.repositories.source"), project_repo_path(@project)
- if can? :write, @project
%li= link_to t("layout.projects.build"), new_project_build_list_path(@project)
%li= link_to t("layout.projects.issues"), project_issues_path(@project)
%li.active= link_to t("layout.projects.wiki"), project_wiki_index_path(@project)
.content
.inner
%p
%b
= t("activerecord.attributes.project.name")
\:
= @project.name
%p
%b
= t("activerecord.attributes.project.owner")
\:
= link_to @project.owner.try(:name), url_for(@project.owner)

View File

@ -2,7 +2,5 @@
# Load the rails application
require File.expand_path('../application', __FILE__)
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
# Initialize the rails application
Rosa::Application.initialize!

View File

@ -1,2 +0,0 @@
# -*- encoding : utf-8 -*-
require './lib/gollum1'

View File

@ -1,9 +0,0 @@
# -*- encoding : utf-8 -*-
require './lib/grit1'
GAP_REPO_PATH = '/tmp/gap_repo.git'
unless File.directory? GAP_REPO_PATH
Grit::Repo.init_bare(GAP_REPO_PATH)
# FileUtils.chmod "a-w", GAP_REPO_PATH
end

View File

@ -10,7 +10,13 @@ config = {:project_root => File.join(APP_CONFIG['root_path'], 'git_projects'), :
Rosa::Application.config.middleware.insert_after ::Rails::Rack::Logger, ::Grack::Handler, config
Rosa::Application.config.middleware.insert_before ::Grack::Handler, ::Grack::Auth
# Grit::Git.git_timeout = 60
Grit::Git.git_timeout = 60
# Grit.debug = true
GAP_REPO_PATH = '/tmp/gap_repo.git'
unless File.directory? GAP_REPO_PATH
Grit::Repo.init_bare(GAP_REPO_PATH)
# FileUtils.chmod "a-w", GAP_REPO_PATH
end
Dir[Rails.root.join("lib/ext/**/*.rb")].each {|f| require f}

View File

@ -40,7 +40,7 @@ en:
message: Message
author: Author
current_branch: Current branch
current_branch: Current branch/tag
current_commit: Current commit
files_in_project: Files in
@ -77,3 +77,5 @@ en:
who_owns:
me: I
group: Group
default_branch: Default branch
is_rpm: Project is a packet

View File

@ -40,7 +40,7 @@ ru:
message: Сообщение
author: Автор
current_branch: Текущая ветка
current_branch: Текущая ветка/тег
current_commit: Текущий коммит
files_in_project: Файлы в
@ -77,3 +77,5 @@ ru:
who_owns:
me: Я
group: Группа
default_branch: Ветка по умолчанию
is_rpm: Проект является пакетом

View File

@ -134,10 +134,10 @@ ru:
repositories:
empty: "Репозиторий пуст. Если вы клонировали(Fork) проект или импортировали пакет, данные скоро появятся"
source: Source
commits: Commits
commits: Коммиты
commit_diff_too_big: Извините, коммит слишком большой!
tags: Tags
branches: Branches
tags: Теги
branches: Ветки
project_versions: Версии
product_build_lists:

View File

@ -101,7 +101,6 @@ Rosa::Application.routes.draw do
resources :categories, :only => [:index, :show]
end
resources :projects, :only => [:new]
resources :projects, :except => [:show] do
resources :wiki do
collection do
@ -137,7 +136,6 @@ Rosa::Application.routes.draw do
post "labels/:label_id" => "issues#destroy_label", :as => :issues_delete_label
post "labels/:label_id/update" => "issues#update_label", :as => :issues_update_label
resource :repo, :controller => "git/repositories", :only => [:show]
resources :build_lists, :only => [:index, :new, :create] do
collection { post :search }
end
@ -156,7 +154,6 @@ Rosa::Application.routes.draw do
member do
post :fork
get :show, :controller => 'git/trees', :action => :show
get :sections
post :sections
delete :remove_user
@ -202,36 +199,28 @@ Rosa::Application.routes.draw do
match 'product_status', :to => 'product_build_lists#status_build'
# Tree
match '/projects/:project_id/git/tree/:treeish(/*path)', :controller => "git/trees", :action => :show, :treeish => /[0-9a-zA-Z_.\-]*/, :defaults => { :treeish => :master }, :as => :tree
get '/projects/:project_id' => "git/trees#show", :as => :project
get '/projects/:project_id/tree/:treeish(/*path)' => "git/trees#show", :defaults => {:treeish => :master}, :as => :tree
# Commits
match '/projects/:project_id/git/commits/:treeish(/*path)', :controller => "git/commits", :action => :index, :treeish => /[0-9a-zA-Z_.\-]*/, :defaults => { :treeish => :master }, :as => :commits, :format => false
match '/projects/:project_id/git/commit/:id(.:format)', :controller => "git/commits", :action => :show, :defaults => { :format => :html }, :as => :commit
# Commit Comments
match '/projects/:project_id/git/commit/:commit_id/comments/:id(.:format)', :controller => "comments", :action => :edit, :as => :edit_project_commit_comment, :via => :get
match '/projects/:project_id/git/commit/:commit_id/comments/:id(.:format)', :controller => "comments", :action => :update, :as => :project_commit_comment, :via => :put
match '/projects/:project_id/git/commit/:commit_id/comments/:id(.:format)', :controller => "comments", :action => :destroy, :via => :delete
match '/projects/:project_id/git/commit/:commit_id/comments(.:format)', :controller => "comments", :action => :create, :as => :project_commit_comments, :via => :post
# Commits subscribe
match '/projects/:project_id/git/commit/:commit_id/subscribe', :controller => "commit_subscribes", :action => :create, :defaults => { :format => :html }, :as => :subscribe_commit, :via => :post
match '/projects/:project_id/git/commit/:commit_id/unsubscribe', :controller => "commit_subscribes", :action => :destroy, :defaults => { :format => :html }, :as => :unsubscribe_commit, :via => :delete
get '/projects/:project_id/commits/:treeish(/*path)' => "git/commits#index", :defaults => {:treeish => :master}, :as => :commits, :format => false
get '/projects/:project_id/commit/:id(.:format)' => "git/commits#show", :as => :commit
# Commit comments
post '/projects/:project_id/commit/:commit_id/comments(.:format)' => "comments#create", :as => :project_commit_comments
get '/projects/:project_id/commit/:commit_id/comments/:id(.:format)' => "comments#edit", :as => :edit_project_commit_comment
put '/projects/:project_id/commit/:commit_id/comments/:id(.:format)' => "comments#update", :as => :project_commit_comment
delete '/projects/:project_id/commit/:commit_id/comments/:id(.:format)' => "comments#destroy"
# Commit subscribes
post '/projects/:project_id/commit/:commit_id/subscribe' => "commit_subscribes#create", :as => :subscribe_commit
delete '/projects/:project_id/commit/:commit_id/unsubscribe' => "commit_subscribes#destroy", :as => :unsubscribe_commit
# Editing files
match '/projects/:project_id/git/blob/:treeish/*path/edit', :controller => "git/blobs", :action => :edit, :treeish => /[0-9a-zA-Z_.\-]*/, :defaults => { :treeish => :master }, :as => :edit_blob, :via => :get
match '/projects/:project_id/git/blob/:treeish/*path', :controller => "git/blobs", :action => :update, :treeish => /[0-9a-zA-Z_.\-]*/, :defaults => { :treeish => :master }, :via => :put, :format => false
get '/projects/:project_id/blob/:treeish/*path/edit' => "git/blobs#edit", :defaults => {:treeish => :master}, :as => :edit_blob
put '/projects/:project_id/blob/:treeish/*path' => "git/blobs#update", :defaults => {:treeish => :master}, :format => false
# Blobs
match '/projects/:project_id/git/blob/:treeish/*path', :controller => "git/blobs", :action => :show, :treeish => /[0-9a-zA-Z_.\-]*/, :defaults => { :treeish => :master }, :as => :blob, :via => :get, :format => false
match '/projects/:project_id/git/commit/blob/:commit_hash/*path', :controller => "git/blobs", :action => :show, :project_id => /[0-9a-zA-Z_.\-]*/, :as => :blob_commit, :via => :get, :format => false
get '/projects/:project_id/blob/:treeish/*path' => "git/blobs#show", :defaults => {:treeish => :master}, :as => :blob, :format => false
# Blame
match '/projects/:project_id/git/blame/:treeish/*path', :controller => "git/blobs", :action => :blame, :treeish => /[0-9a-zA-Z_.\-]*/, :defaults => { :treeish => :master }, :as => :blame, :format => false
match '/projects/:project_id/git/commit/blame/:commit_hash/*path', :controller => "git/blobs", :action => :blame, :as => :blame_commit
get '/projects/:project_id/blame/:treeish/*path' => "git/blobs#blame", :defaults => {:treeish => :master}, :as => :blame, :format => false
# Raw
match '/projects/:project_id/git/raw/:treeish/*path', :controller => "git/blobs", :action => :raw, :treeish => /[0-9a-zA-Z_.\-]*/, :defaults => { :treeish => :master }, :as => :raw, :format => false
match '/projects/:project_id/git/commit/raw/:commit_hash/*path', :controller => "git/blobs", :action => :raw, :as => :raw_commit
get '/projects/:project_id/raw/:treeish/*path' => "git/blobs#raw", :defaults => {:treeish => :master}, :as => :raw, :format => false
root :to => "activity_feeds#index"
match '/forbidden', :to => 'platforms#forbidden', :as => 'forbidden'

View File

@ -286,11 +286,11 @@ ActiveRecord::Schema.define(:version => 20120321130436) do
t.text "description"
t.string "ancestry"
t.boolean "has_issues", :default => true
t.boolean "has_wiki", :default => false
t.string "srpm_file_name"
t.string "srpm_content_type"
t.integer "srpm_file_size"
t.datetime "srpm_updated_at"
t.boolean "has_wiki", :default => false
t.string "default_branch", :default => "master"
t.boolean "is_rpm", :default => true
end
@ -311,6 +311,7 @@ ActiveRecord::Schema.define(:version => 20120321130436) do
end
add_index "register_requests", ["email"], :name => "index_register_requests_on_email", :unique => true, :case_sensitive => false
add_index "register_requests", ["token"], :name => "index_register_requests_on_token", :unique => true, :case_sensitive => false
create_table "relations", :force => true do |t|
t.integer "object_id"
@ -370,7 +371,6 @@ ActiveRecord::Schema.define(:version => 20120321130436) do
t.string "email", :default => "", :null => false
t.string "encrypted_password", :limit => 128, :default => "", :null => false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.datetime "created_at"
t.datetime "updated_at"
@ -378,6 +378,7 @@ ActiveRecord::Schema.define(:version => 20120321130436) do
t.string "uname"
t.string "role"
t.string "language", :default => "en"
t.datetime "reset_password_sent_at"
t.integer "own_projects_count", :default => 0, :null => false
t.text "professional_experience"
t.string "site"

View File

@ -17,4 +17,6 @@ Add to /etc/rc.d/rc.sysinit
. /etc/rc.local
fi
==
=== Tips
gem install charlock_holmes -- --with-icu-dir=/opt/local
git config --global core.quotepath false

View File

@ -1,6 +1,27 @@
# -*- encoding : utf-8 -*-
require 'charlock_holmes/string'
# require 'iconv'
class String
def encode_to_default
force_encoding(Encoding.default_internal || Encoding::UTF_8)
def default_encoding!
if ascii_only?
force_encoding(Encoding.default_internal || Encoding::UTF_8)
else
force_encoding((detected = detect_encoding and detected[:encoding]) || Encoding.default_internal || Encoding::UTF_8).encode!
end
end
# def enforce_utf8(from = nil)
# begin
# is_utf8? ? self : ::Iconv.iconv('utf8', from, self).first
# rescue
# converter = ::Iconv.new('UTF-8//IGNORE//TRANSLIT', 'ASCII//IGNORE//TRANSLIT')
# # If Ruby 1.9, else another RubyEngine (ree, Ruby 1.8)
# begin
# converter.iconv(self).unpack('U*').select{|cp| cp < 127}.pack('U*').force_encoding('utf-8')
# rescue
# converter.iconv(self).unpack('U*').select{|cp| cp < 127}.pack('U*')
# end
# end
# end
end

View File

@ -1,27 +1,6 @@
# -*- encoding : utf-8 -*-
# # -*- encoding : utf-8 -*-
module Gollum
class Wiki
def page_with_forced_encoding(name, version = @ref)
page_without_forced_encoding(force_grit_encoding(name), version)
end
alias_method_chain :page, :forced_encoding
def file_with_forced_encoding(name, version = @ref)
file_without_forced_encoding(force_grit_encoding(name), version)
end
alias_method_chain :file, :forced_encoding
def write_page_with_forced_encoding(name, format, data, commit = {})
write_page_without_forced_encoding(force_grit_encoding(name), format, data, commit)
end
alias_method_chain :write_page, :forced_encoding
def update_page_with_forced_encoding(page, name, format, data, commit = {})
update_page_without_forced_encoding(page, force_grit_encoding(name), format, data, commit)
end
alias_method_chain :update_page, :forced_encoding
# Public: Applies a reverse diff for a given page. If only 1 SHA is given,
# the reverse diff will be taken from its parent (^SHA...SHA). If two SHAs
# are given, the reverse diff is taken from SHA1...SHA2.
@ -91,12 +70,5 @@ module Gollum
revert_page_with_committer(nil, sha1, sha2, commit)
end
alias_method_chain :revert_commit, :committer
private
def force_grit_encoding(str)
str.dup.force_encoding(Encoding::ASCII_8BIT)
end
end
end

View File

@ -1,11 +0,0 @@
# -*- encoding : utf-8 -*-
module Gollum
class Page
def name_with_encoding
name_without_encoding.encode_to_default
end
alias_method_chain :name, :encoding
end
end

View File

@ -1,4 +0,0 @@
# -*- encoding : utf-8 -*-
Dir.glob(File.join('.', 'lib', 'gollum', '*.rb')) do |file|
require file
end

View File

@ -1,56 +0,0 @@
# -*- encoding : utf-8 -*-
module Grit
class Diff
def self.list_from_string(repo, text)
lines = text.split("\n")
diffs = []
while !lines.empty?
m, a_path, b_path = *lines.shift.match(%r{^diff --git "{0,1}a/(.+?)"{0,1} "{0,1}b/(.+?)"{0,1}$})
if lines.first =~ /^old mode/
m, a_mode = *lines.shift.match(/^old mode (\d+)/)
m, b_mode = *lines.shift.match(/^new mode (\d+)/)
end
if lines.empty? || lines.first =~ /^diff --git/
diffs << Diff.new(repo, a_path, b_path, nil, nil, a_mode, b_mode, false, false, nil)
next
end
sim_index = 0
new_file = false
deleted_file = false
renamed_file = false
if lines.first =~ /^new file/
m, b_mode = lines.shift.match(/^new file mode (.+)$/)
a_mode = nil
new_file = true
elsif lines.first =~ /^deleted file/
m, a_mode = lines.shift.match(/^deleted file mode (.+)$/)
b_mode = nil
deleted_file = true
elsif lines.first =~ /^similarity index (\d+)\%/
sim_index = $1.to_i
renamed_file = true
2.times { lines.shift } # shift away the 2 `rename from/to ...` lines
end
m, a_blob, b_blob, b_mode = *lines.shift.match(%r{^index ([0-9A-Fa-f]+)\.\.([0-9A-Fa-f]+) ?(.+)?$})
b_mode.strip! if b_mode
diff_lines = []
while lines.first && lines.first !~ /^diff/
diff_lines << lines.shift
end
diff = diff_lines.join("\n")
diffs << Diff.new(repo, a_path, b_path, a_blob, b_blob, a_mode, b_mode, new_file, deleted_file, diff, renamed_file, sim_index)
end
diffs
end
end
end

View File

@ -1,17 +0,0 @@
# -*- encoding : utf-8 -*-
module Grit
class Repo
def diff_with_encoding(a, b, *paths)
diff = self.git.native('diff', {}, a, b, '--', *paths).encode_to_default
if diff =~ /diff --git "{0,1}a/
diff = diff.sub(/.*?(diff --git "{0,1}a)/m, '\1')
else
diff = ''
end
Diff.list_from_string(self, diff)
end
alias_method_chain :diff, :encoding
end
end

View File

@ -1,4 +0,0 @@
# -*- encoding : utf-8 -*-
require './lib/grit/repo.rb'
require './lib/grit/diff.rb'
require './lib/grit/blob.rb'

View File

@ -75,8 +75,8 @@ describe CommentsController do
stub_rsync_methods
@project = Factory(:project)
@issue = Factory(:issue, :project_id => @project.id)
@comment = Factory(:comment, :commentable => @issue)
@issue = Factory(:issue, :project_id => @project.id, :creator => Factory(:user))
@comment = Factory(:comment, :commentable => @issue, :project_id => @project.id)
@create_params = {:comment => {:body => 'I am a comment!'}, :project_id => @project.id, :issue_id => @issue.serial_id}
@update_params = {:comment => {:body => 'updated'}, :project_id => @project.id, :issue_id => @issue.serial_id}
@ -92,7 +92,7 @@ describe CommentsController do
set_session_for(@user)
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin')
@own_comment = Factory(:comment, :commentable => @issue, :user => @user)
@own_comment = Factory(:comment, :commentable => @issue, :user => @user, :project_id => @project.id)
end
it_should_behave_like 'user with create comment rights'
@ -108,7 +108,7 @@ describe CommentsController do
@project.update_attribute(:owner, @user)
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin')
@own_comment = Factory(:comment, :commentable => @issue, :user => @user)
@own_comment = Factory(:comment, :commentable => @issue, :user => @user, :project_id => @project.id)
end
it_should_behave_like 'user with create comment rights'
@ -123,7 +123,7 @@ describe CommentsController do
set_session_for(@user)
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'reader')
@own_comment = Factory(:comment, :commentable => @issue, :user => @user)
@own_comment = Factory(:comment, :commentable => @issue, :user => @user, :project_id => @project.id)
end
it_should_behave_like 'user with create comment rights'
@ -138,7 +138,7 @@ describe CommentsController do
set_session_for(@user)
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'writer')
@own_comment = Factory(:comment, :commentable => @issue, :user => @user)
@own_comment = Factory(:comment, :commentable => @issue, :user => @user, :project_id => @project.id)
end
it_should_behave_like 'user with create comment rights'

View File

@ -1,6 +1,72 @@
# -*- encoding : utf-8 -*-
require 'spec_helper'
shared_examples_for 'group user without update rights' do
it 'should be not able to perform update action' do
put :update, {:id => @group.id}.merge(@update_params)
response.should redirect_to(forbidden_path)
end
it 'should not be able to update group data' do
put :update, :id => @group.id, :group => {:description => 'new description'}
@group.reload.description.should_not == 'new description'
end
end
shared_examples_for 'group user without destroy rights' do
it 'should not be able to destroy group' do
delete :destroy, :id => @group.id
response.should redirect_to(forbidden_path)
end
it 'should not change groups count after destroy action' do
lambda { delete :destroy, :id => @group.id }.should change{ Group.count }.by(0)
end
end
shared_examples_for 'group admin' do
it_should_behave_like 'no group user'
it 'should be able to update group data' do
put :update, :id => @group.id, :group => {:description => 'new description'}
@group.reload.description.should == 'new description'
end
it 'should be able to perform update action' do
put :update, {:id => @group.id}.merge(@update_params)
response.should redirect_to(group_path(@group))
end
end
shared_examples_for 'no group user' do
it 'should be able to perform create action' do
post :create, @create_params
response.should redirect_to(group_path( Group.last.id ))
end
it 'should change objects count on create' do
lambda { post :create, @create_params }.should change{ Group.count }.by(1)
end
it 'should be able to perform autocomplete_group_uname action' do
get :autocomplete_group_uname
response.should be_success
end
end
shared_examples_for 'group owner' do
it_should_behave_like 'group admin'
it 'should be able to destroy group' do
delete :destroy, :id => @group.id
response.should redirect_to(groups_path)
end
it 'should change groups count after destroy action' do
lambda { delete :destroy, :id => @group.id }.should change{ Group.count }.by(-1)
end
end
describe GroupsController do
before(:each) do
stub_rsync_methods
@ -20,15 +86,21 @@ describe GroupsController do
put :update, {:id => @group.id}.merge(@update_params)
response.should redirect_to(new_user_session_path)
end
it 'should not be able to perform create action' do
post :create, @create_params
response.should redirect_to(new_user_session_path)
end
end
context 'for admin' do
context 'for global admin' do
before(:each) do
@admin = Factory(:admin)
set_session_for(@admin)
end
it_should_behave_like 'update_member_relation'
it_should_behave_like 'group owner'
it 'should be able to perform index action' do
get :index
@ -39,14 +111,41 @@ describe GroupsController do
put :update, {:id => @group.id}.merge(@update_params)
response.should redirect_to(group_path(@group))
end
end
it 'should be able to perform create action' do
post :create, @create_params
response.should redirect_to(group_path( Group.last.id ))
context 'for group admin' do
before(:each) do
@user = Factory(:user)
set_session_for(@user)
@group.objects.create(:object_type => 'User', :object_id => @user.id, :role => 'admin')
end
it 'should change objects count on create' do
lambda { post :create, @create_params }.should change{ Group.count }.by(1)
it_should_behave_like 'update_member_relation'
it_should_behave_like 'group admin'
it_should_behave_like 'group user without destroy rights'
end
context 'for group owner' do
before(:each) do
@user = Factory(:user)
set_session_for(@user)
@group.update_attribute(:owner, @user)
@group.objects.create(:object_type => 'User', :object_id => @user.id, :role => 'admin')
end
it_should_behave_like 'update_member_relation'
it_should_behave_like 'group owner'
end
context 'for group reader and writer user' do
before(:each) do
@user = Factory(:user)
set_session_for(@user)
@group.objects.create(:object_type => 'User', :object_id => @user.id, :role => 'reader')
end
it_should_behave_like 'no group user'
it_should_behave_like 'group user without destroy rights'
it_should_behave_like 'group user without update rights'
end
end

View File

@ -13,7 +13,7 @@ describe UserMailer do
any_instance_of(Project, :versions => ['v1.0', 'v2.0'])
@issue = Factory(:issue, :project_id => @project.id, :user_id => @issue_user.id)
@issue = Factory(:issue, :project_id => @project.id, :user_id => @issue_user.id, :creator => @issue_user)
@email = UserMailer.new_issue_notification(@issue, @issue_user).deliver
end
@ -52,7 +52,7 @@ describe UserMailer do
any_instance_of(Project, :versions => ['v1.0', 'v2.0'])
@issue = Factory(:issue, :project_id => @project.id, :user_id => @issue_user.id)
@issue = Factory(:issue, :project_id => @project.id, :user_id => @issue_user.id, :creator => @issue_user)
@email = UserMailer.issue_assign_notification(@issue, @user).deliver
end
@ -88,8 +88,8 @@ describe UserMailer do
any_instance_of(Project, :versions => ['v1.0', 'v2.0'])
@issue = Factory(:issue, :project_id => @project.id, :user_id => @issue_user.id)
@comment = Factory(:comment, :commentable => @issue, :user_id => @user.id)
@issue = Factory(:issue, :project_id => @project.id, :user_id => @issue_user.id, :creator => @issue_user)
@comment = Factory(:comment, :commentable => @issue, :user_id => @user.id, :project => @project)
@email = UserMailer.new_comment_notification(@comment, @issue_user).deliver
end

View File

@ -6,10 +6,10 @@ def set_commentable_data
@ability = Ability.new(@user)
@project = Factory(:project)
@issue = Factory(:issue, :project_id => @project.id)
@issue = Factory(:issue, :project_id => @project.id, :creator => @user)
@comment = Factory(:comment, :commentable => @issue, :user => @user)
@stranger_comment = Factory(:comment, :commentable => @issue, :user => @stranger)
@comment = Factory(:comment, :commentable => @issue, :user => @user, :project => @project)
@stranger_comment = Factory(:comment, :commentable => @issue, :user => @stranger, :project => @project)
any_instance_of(Project, :versions => ['v1.0', 'v2.0'])
end
@ -25,7 +25,7 @@ describe Comment do
end
it 'should create comment' do
@ability.should be_able_to(:create, Comment.new(:commentable => @issue, :user => @user))
@ability.should be_able_to(:create, @comment)
end
pending "sends an e-mail" do
@ -60,7 +60,8 @@ describe Comment do
end
it 'should create comment' do
@ability.should be_able_to(:create, Comment.new(:commentable => @issue, :user => @user))
@comment.user = @user
@ability.should be_able_to(:create, @comment)
end
it 'should update comment' do
@ -88,7 +89,7 @@ describe Comment do
end
it 'should create comment' do
@ability.should be_able_to(:create, Comment.new(:commentable => @issue, :user => @user))
@ability.should be_able_to(:create, @comment)
end
it 'should update comment' do
@ -113,7 +114,7 @@ describe Comment do
end
it 'should create comment' do
@ability.should be_able_to(:create, Comment.new(:commentable => @issue, :user => @user))
@ability.should be_able_to(:create, @comment)
end
it 'should update comment' do

View File

@ -1,6 +1,96 @@
# -*- encoding : utf-8 -*-
require 'spec_helper'
require "cancan/matchers"
describe Group do
pending "add some examples to (or delete) #{__FILE__}"
before(:each) do
stub_rsync_methods
@group = Factory(:group)
@ability = Ability.new(User.new)
end
context 'for guest' do
[:read, :update, :destroy, :manage_members, :autocomplete_group_uname].each do |action|
it "should not be able to #{action} group" do
@ability.should_not be_able_to(action, @group)
end
end
end
context 'for global admin' do
before(:each) do
@admin = Factory(:admin)
@ability = Ability.new(@admin)
end
[:read, :update, :destroy, :manage_members, :autocomplete_group_uname].each do |action|
it "should be able to #{action} group" do
@ability.should be_able_to(action, @group)
end
end
end
context 'for group admin' do
before(:each) do
@user = Factory(:user)
@another_user = Factory(:user)
@group.objects.create(:object_type => 'User', :object_id => @user.id, :role => 'admin')
@ability = Ability.new(@user)
end
[:read, :update, :manage_members, :autocomplete_group_uname].each do |action|
it "should be able to #{action} group" do
@ability.should be_able_to(action, @group)
end
end
it "should not be able to destroy group" do
@ability.should_not be_able_to(:destroy, @group)
end
context 'with mass assignment' do
it 'should not be able to update uname' do
@group.should_not allow_mass_assignment_of :uname => 'new_uname'
end
it 'should not be able to update owner' do
@group.should_not allow_mass_assignment_of :owner_type => 'User', :owner_id => @another_user.id
end
end
end
context 'for group owner' do
before(:each) do
@user = Factory(:user)
@group.update_attribute(:owner, @user)
@group.objects.create(:object_type => 'User', :object_id => @user.id, :role => 'admin')
@ability = Ability.new(@user)
end
[:read, :update, :destroy, :manage_members, :autocomplete_group_uname].each do |action|
it "should be able to #{action} group" do
@ability.should be_able_to(action, @group)
end
end
end
context 'for group reader and writer user' do
before(:each) do
@user = Factory(:user)
@group.objects.create(:object_type => 'User', :object_id => @user.id, :role => 'reader')
@ability = Ability.new(@user)
end
[:read, :autocomplete_group_uname].each do |action|
it "should be able to #{action} group" do
@ability.should be_able_to(action, @group)
end
end
[:update, :destroy, :manage_members].each do |action|
it "should not be able to #{action} group" do
@ability.should_not be_able_to(action, @group)
end
end
end
end