Commit 0955863489ee449389ec08afb498803bc6fbb59e

Authored by Adam Leonard
2 parents 7087e11f f6a67fba

Merge branch 'master' of dev.gitlabhq.com:gitlabhq into feature/issues_search

README.rdoc
... ... @@ -28,24 +28,33 @@ sqlite as default db
28 28  
29 29  
30 30 git clone git://github.com/gitlabhq/gitlabhq.git
  31 +
31 32 cd gitlabhq/
32 33  
33 34 # install this library first
34 35 sudo easy_install pygments
  36 +
  37 + # give your user access to remove git repo
  38 + # Ex.
  39 + # If you are going to use user 'gitlabhq' for rails server
  40 + # gitlabhq ALL = (git) NOPASSWD: /bin/rm" | sudo tee -a /etc/sudoers
  41 + #
  42 + echo "USERNAME ALL = (git) NOPASSWD: /bin/rm" | sudo tee -a /etc/sudoers
35 43  
36 44 sudo gem install bundler
  45 +
37 46 bundle
38 47  
39   - RAILS_ENV=production rake db:setup
  48 + bundle exec rake db:setup RAILS_ENV=production
40 49  
41 50 # create admin user
42 51 # login....admin@local.host
43 52 # pass.....5iveL!fe
44   - RAILS_ENV=production rake db:seed_fu
  53 + bundle exec rake db:seed_fu RAILS_ENV=production
45 54  
46 55 Install gitosis, edit conf/gitosis.yml & start server
47 56  
48   - rails s
  57 + rails s -e production
49 58  
50 59 == Install Gitosis
51 60 sudo aptitude install gitosis
... ... @@ -63,6 +72,7 @@ Install gitosis, edit conf/gitosis.yml & start server
63 72 ssh-keygen -t rsa
64 73  
65 74 sudo -H -u git gitosis-init < ~/.ssh/id_rsa.pub
  75 +
66 76 sudo chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update
67 77  
68 78  
... ... @@ -83,3 +93,8 @@ Install gitosis, edit conf/gitosis.yml &amp; start server
83 93  
84 94  
85 95 echo "gem: --no-rdoc --no-ri" > ~/.gemrc
  96 +
  97 +== Contribute
  98 +
  99 +We develop project on our private server.
  100 +Want to help? Contact us on twitter or email to become a team member.
... ...
app/assets/stylesheets/projects.css.scss
... ... @@ -638,3 +638,46 @@ tbody tr:nth-child(2n) td, tbody tr.even td {
638 638 display:none;
639 639 }
640 640 }
  641 +
  642 +.field_with_errors {
  643 + input[type="text"],
  644 + input[type="password"],
  645 + textarea
  646 + {
  647 + background: none repeat scroll 0 0 #FFBBBB
  648 + }
  649 +}
  650 +
  651 +.tag {
  652 + @include round-borders-all(4px);
  653 + padding:2px 4px;
  654 + border:none;
  655 +
  656 + &.high {
  657 + background: #D12F19;
  658 + color:white;
  659 + }
  660 +
  661 + &.today {
  662 + background: #44aa22;
  663 + color:white;
  664 + }
  665 +
  666 + &.yours {
  667 + background: #4466cc;
  668 + color:white;
  669 + }
  670 + &.notes {
  671 + background: #2c5c66;
  672 + color:white;
  673 + }
  674 +}
  675 +
  676 +#issues-table .issue {
  677 + &.critical {
  678 + td {
  679 + //background: #D12F19;
  680 + //color:#fff;
  681 + }
  682 + }
  683 +}
... ...
app/controllers/issues_controller.rb
... ... @@ -12,7 +12,7 @@ class IssuesController &lt; ApplicationController
12 12  
13 13 def index
14 14 @issues = case params[:f].to_i
15   - when 1 then @project.issues.all
  15 + when 1 then @project.issues
16 16 when 2 then @project.issues.closed
17 17 when 3 then @project.issues.opened.assigned(current_user)
18 18 else @project.issues.opened
... ...
app/controllers/team_members_controller.rb
... ... @@ -8,35 +8,16 @@ class TeamMembersController &lt; ApplicationController
8 8  
9 9 def show
10 10 @team_member = project.users_projects.find(params[:id])
11   -
12   - respond_to do |format|
13   - format.html # show.html.erb
14   - format.js
15   - end
16 11 end
17 12  
18 13 def new
19 14 @team_member = project.users_projects.new
20   -
21   - respond_to do |format|
22   - format.html # new.html.erb
23   - format.js
24   - end
25 15 end
26 16  
27 17 def create
28 18 @team_member = UsersProject.new(params[:team_member])
29 19 @team_member.project = project
30   -
31   - respond_to do |format|
32   - if @team_member.save
33   - format.html { redirect_to @team_member, notice: 'Team member was successfully created.' }
34   - format.js
35   - else
36   - format.html { render action: "new" }
37   - format.js
38   - end
39   - end
  20 + @team_member.save
40 21 end
41 22  
42 23 def update
... ... @@ -45,7 +26,12 @@ class TeamMembersController &lt; ApplicationController
45 26  
46 27 respond_to do |format|
47 28 format.js
48   - format.html { redirect_to team_project_path(@project)}
  29 + format.html do
  30 + unless @team_member.valid?
  31 + flash[:alert] = "User should have at least one role"
  32 + end
  33 + redirect_to team_project_path(@project)
  34 + end
49 35 end
50 36 end
51 37  
... ...
app/helpers/commits_helper.rb
... ... @@ -21,13 +21,4 @@ module CommitsHelper
21 21 link_to "More", project_commits_path(@project, :offset => offset.to_i + limit.to_i, :limit => limit),
22 22 :remote => true, :class => "lite_button vm", :style => "text-align:center; width:930px; ", :id => "more-commits-link"
23 23 end
24   -
25   - # Cause some errors with trucate & encoding use this method
26   - def truncate_commit_message(commit, size = 60)
27   - message = commit.message
28   - message.length > size ? (message[0..(size - 1)] + "...") : message
29   - # if special characters occurs
30   - rescue
31   - commit.message
32   - end
33 24 end
... ...
app/models/issue.rb
... ... @@ -18,11 +18,22 @@ class Issue &lt; ActiveRecord::Base
18 18 :presence => true,
19 19 :length => { :within => 0..2000 }
20 20  
  21 + scope :critical, where(:critical => true)
  22 + scope :non_critical, where(:critical => false)
  23 +
21 24 scope :opened, where(:closed => false)
22 25 scope :closed, where(:closed => true)
23 26 scope :assigned, lambda { |u| where(:assignee_id => u.id)}
24 27  
25 28 acts_as_list
  29 +
  30 + def today?
  31 + Date.today == created_at.to_date
  32 + end
  33 +
  34 + def new?
  35 + today? && created_at == updated_at
  36 + end
26 37 end
27 38 # == Schema Information
28 39 #
... ...
app/models/project.rb
... ... @@ -35,7 +35,8 @@ class Project &lt; ActiveRecord::Base
35 35 :presence => true
36 36  
37 37 validate :check_limit
38   -
  38 + validate :repo_name
  39 +
39 40 after_destroy :destroy_gitosis_project
40 41 after_save :update_gitosis_project
41 42  
... ... @@ -168,6 +169,12 @@ class Project &lt; ActiveRecord::Base
168 169 errors[:base] << ("Cant check your ability to create project")
169 170 end
170 171  
  172 + def repo_name
  173 + if path == "gitosis-admin"
  174 + errors.add(:path, " like 'gitosis-admin' is not allowed")
  175 + end
  176 + end
  177 +
171 178 def valid_repo?
172 179 repo
173 180 rescue
... ...
app/models/users_project.rb
... ... @@ -9,7 +9,8 @@ class UsersProject &lt; ActiveRecord::Base
9 9 validates_uniqueness_of :user_id, :scope => [:project_id]
10 10 validates_presence_of :user_id
11 11 validates_presence_of :project_id
12   -
  12 + validate :user_has_a_role_selected
  13 +
13 14 delegate :name, :email, :to => :user, :prefix => true
14 15  
15 16 def update_gitosis_project
... ... @@ -18,6 +19,10 @@ class UsersProject &lt; ActiveRecord::Base
18 19 end
19 20 end
20 21  
  22 + def user_has_a_role_selected
  23 + errors.add(:base, "Please choose at least one Role in the Access list") unless read || write || admin
  24 + end
  25 +
21 26 end
22 27 # == Schema Information
23 28 #
... ...
app/views/commits/_commits.html.haml
... ... @@ -11,7 +11,7 @@
11 11 = image_tag "no_avatar.png", :class => "left", :width => 40, :style => "padding-right:5px;"
12 12 %p
13 13 %strong
14   - = truncate_commit_message(commit)
  14 + = truncate(commit.safe_message, :length => 60)
15 15 = link_to "Browse Code", tree_project_path(@project, :commit_id => commit.id), :class => "lite_button", :style => "float:right"
16 16 = link_to truncate(commit.id.to_s, :length => 16), project_commit_path(@project, :id => commit.id), :class => "lite_button", :style => "width:120px;float:right"
17 17 %span
... ...
app/views/commits/_diff.html.haml
1   -.file_stats
2   - - @commit.diffs.each do |diff|
3   - - if diff.deleted_file
4   - %span.removed_file
5   - %a{:href => "##{diff.a_path}"}
6   - = diff.a_path
7   - = image_tag "blueprint_delete.png"
8   - - elsif diff.renamed_file
9   - %span.moved_file
10   - %a{:href => "##{diff.b_path}"}
11   - = diff.a_path
12   - = "->"
13   - = diff.b_path
14   - = image_tag "blueprint_notice.png"
15   - - elsif diff.new_file
16   - %span.new_file
17   - %a{:href => "##{diff.b_path}"}
18   - = diff.b_path
19   - = image_tag "blueprint_add.png"
20   - - else
21   - %span.edit_file
22   - %a{:href => "##{diff.b_path}"}
23   - = diff.b_path
24   - = image_tag "blueprint_info.png"
  1 +.file_stats= render "commits/diff_head"
  2 +
25 3 - @commit.diffs.each do |diff|
26 4 - next if diff.diff.empty?
27 5 - file = (@commit.tree / diff.b_path)
... ... @@ -31,24 +9,12 @@
31 9 - if diff.deleted_file
32 10 %strong{:id => "#{diff.b_path}"}= diff.a_path
33 11 - else
34   - %strong{:id => "#{diff.b_path}"}= diff.b_path
  12 + = link_to tree_file_project_path(@project, @commit.id, diff.b_path) do
  13 + %strong{:id => "#{diff.b_path}"}= diff.b_path
35 14 %br/
36 15 .diff_file_content
37 16 - if file.text?
38   - - lines_arr = diff.diff.lines.to_a
39   - - line_old = lines_arr[2].match(/-(\d)/)[0].to_i.abs rescue 0
40   - - line_new = lines_arr[2].match(/\+(\d)/)[0].to_i.abs rescue 0
41   - - lines = lines_arr[3..-1].join
42   - - lines.each_line do |line|
43   - = diff_line(line, line_new, line_old)
44   - - if line[0] == "+"
45   - - line_new += 1
46   - - elsif
47   - - line[0] == "-"
48   - - line_old += 1
49   - - else
50   - - line_new += 1
51   - - line_old += 1
  17 + = render :partial => "commits/text_file", :locals => { :diff => diff }
52 18 - elsif file.image?
53 19 .diff_file_content_image
54 20 %img{:src => "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"}
... ...
app/views/commits/_diff_head.html.haml 0 → 100644
... ... @@ -0,0 +1,24 @@
  1 +- @commit.diffs.each do |diff|
  2 + - if diff.deleted_file
  3 + %span.removed_file
  4 + %a{:href => "##{diff.a_path}"}
  5 + = diff.a_path
  6 + = image_tag "blueprint_delete.png"
  7 + - elsif diff.renamed_file
  8 + %span.moved_file
  9 + %a{:href => "##{diff.b_path}"}
  10 + = diff.a_path
  11 + = "->"
  12 + = diff.b_path
  13 + = image_tag "blueprint_notice.png"
  14 + - elsif diff.new_file
  15 + %span.new_file
  16 + %a{:href => "##{diff.b_path}"}
  17 + = diff.b_path
  18 + = image_tag "blueprint_add.png"
  19 + - else
  20 + %span.edit_file
  21 + %a{:href => "##{diff.b_path}"}
  22 + = diff.b_path
  23 + = image_tag "blueprint_info.png"
  24 +
... ...
app/views/commits/_text_file.html.haml 0 → 100644
... ... @@ -0,0 +1,21 @@
  1 +- line_old = 0
  2 +- line_new = 0
  3 +- lines_arr = diff.diff.lines.to_a
  4 +- lines_arr.each do |line|
  5 + - next if line.match(/^--- a/)
  6 + - next if line.match(/^\+\+\+ b/)
  7 + - if line.match(/^@@ -/)
  8 + - line_old = line.match(/\-[0-9]*/)[0].to_i.abs rescue 0
  9 + - line_new = line.match(/\+[0-9]*/)[0].to_i.abs rescue 0
  10 + - next
  11 +
  12 + = diff_line(line, line_new, line_old)
  13 + - if line[0] == "+"
  14 + - line_new += 1
  15 + - elsif
  16 + - line[0] == "-"
  17 + - line_old += 1
  18 + - else
  19 + - line_new += 1
  20 + - line_old += 1
  21 +
... ...
app/views/commits/show.html.haml
1 1 %h3
2   - = "[ #{@commit.committer} ] #{truncate_commit_message(@commit, 80)}"
  2 + = "[ #{@commit.committer} ] #{truncate(@commit.safe_message)}"
3 3 -#= link_to 'Back', project_commits_path(@project), :class => "button"
4 4 %table.round-borders
5 5 %tr
... ... @@ -16,7 +16,7 @@
16 16 %td= @commit.committed_date
17 17 %tr
18 18 %td Message
19   - %td= @commit.message
  19 + %td= @commit.safe_message
20 20 %tr
21 21 %td Tree
22 22 %td= link_to 'Browse Code', tree_project_path(@project, :commit_id => @commit.id)
... ...
app/views/issues/_form.html.haml
... ... @@ -5,17 +5,21 @@
5 5 - @issue.errors.full_messages.each do |msg|
6 6 %li= msg
7 7  
8   - .span-6
  8 + .span-8
9 9 = f.label :title
10 10 = f.text_field :title, :style => "width:450px"
11   - .span-6
  11 + .span-8
12 12 = f.label :content
13 13 = f.text_area :content, :style => "width:450px; height:130px"
14   - .span-6.append-bottom
  14 + .span-8.append-bottom
15 15 = f.label :assignee_id
16 16 = f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { :include_blank => "Select user" })
  17 + .span-1
  18 + = f.label :critical, "Critical"
  19 + %br
  20 + = f.check_box :critical
17 21 - unless @issue.new_record?
18   - .span-3.right
  22 + .span-2.right
19 23 = f.label :closed
20 24 %br
21 25 = f.check_box :closed
... ...
app/views/issues/_issues.html.haml
1 1 %table.round-borders#issues-table
2 2 %tr
  3 + - if can?(current_user, :admin_issue, @project) && !params[:f] || params[:f] == "0"
  4 + %th
3 5 %th Assignee
4 6 %th ID
5 7 %th Title
6 8 %th Closed?
7 9 %th
8 10  
9   - - @issues.each do |issue|
  11 + - @issues.critical.each do |issue|
  12 + = render(:partial => 'show', :locals => {:issue => issue})
  13 +
  14 + - @issues.non_critical.each do |issue|
10 15 = render(:partial => 'show', :locals => {:issue => issue})
... ...
app/views/issues/_show.html.haml
1   -%tr{ :id => dom_id(issue), :class => "issue", :url => project_issue_path(@project, issue) }
  1 +%tr{ :id => dom_id(issue), :class => "issue #{issue.critical ? "critical" : ""}", :url => project_issue_path(@project, issue) }
  2 + - if can?(current_user, :admin_issue, @project) && !params[:f] || params[:f] == "0"
  3 + %td
  4 + = image_tag "move.png" , :class => [:handle, :left]
2 5 %td
3   - = image_tag "move.png" , :class => [:handle, :left]
4 6 = image_tag gravatar_icon(issue.assignee.email), :class => "left", :width => 40, :style => "padding:0 5px;"
5 7 = truncate issue.assignee.name, :lenght => 20
6 8 %td ##{issue.id}
7   - %td= html_escape issue.title
  9 + %td
  10 + = html_escape issue.title
  11 + %br
  12 + - if issue.critical
  13 + %span.tag.high critical
  14 + - if issue.today?
  15 + %span.tag.today today
  16 + -#- if issue.author == current_user
  17 + -#%span.tag.yours yours
  18 + -#- if issue.notes.count > 0
  19 + -#%span.tag.notes
  20 + -#= issue.notes.count
  21 + -#notes
8 22 %td
9 23 - if can? current_user, :write_issue, @project
10 24 = form_for([@project, issue], :remote => true) do |f|
... ...
app/views/projects/_recent_commits.html.haml
... ... @@ -6,7 +6,7 @@
6 6 = image_tag "no_avatar.png", :class => "left", :width => 40, :style => "padding-right:5px;"
7 7 %p{:style => "margin-bottom: 3px;"}
8 8 %strong
9   - = link_to truncate_commit_message(commit, 60), project_commit_path(@project, :id => commit.id)
  9 + = link_to truncate(commit.safe_message, :length => 60), project_commit_path(@project, :id => commit.id)
10 10  
11 11 %span
12 12 %span.author
... ...
app/views/projects/_recent_messages.html.haml
... ... @@ -19,7 +19,7 @@
19 19 - css_class = "dash_commit"
20 20 - commit = parent
21 21 - item_code = commit.author.email
22   - - link_item_name = truncate_commit_message(commit, 50)
  22 + - link_item_name = truncate(commit.safe_message, :length => 50)
23 23 - link_to_item = project_commit_path(@project, :id => commit.id)
24 24 - else
25 25 - css_class = "dash_wall"
... ...
app/views/projects/_tree.html.haml
... ... @@ -30,15 +30,15 @@
30 30 %th Last Update
31 31 %th
32 32 Last commit
33   - = link_to "history", project_commits_path(@project, :path => params[:path]), :class => "right"
  33 + = link_to "history", project_commits_path(@project, :path => params[:path], :branch => params[:branch],:tag => params[:tag]), :class => "right"
34 34 - if params[:path]
35 35 - file = File.join(params[:path], "..")
36 36 %tr{ :class => "tree-item", :url => tree_file_project_path(@project, @commit.id, file) }
37 37 %td.tree-item-file-name
38 38 = image_tag "dir.png"
39 39 = link_to "..", tree_file_project_path(@project, @commit.id, file, :branch => @branch, :tag => @tag), :remote => :true
40   - %td
41   - %td
  40 + %td
  41 + %td
42 42  
43 43 - contents.select{ |i| i.is_a?(Grit::Tree)}.each do |content|
44 44 = render :partial => "projects/tree_item", :locals => { :content => content }
... ... @@ -52,7 +52,7 @@
52 52 });
53 53  
54 54 - if params[:path] && request.xhr?
55   - :javascript
  55 + :javascript
56 56 $(window).unbind('popstate');
57 57 $(window).bind('popstate', function() {
58 58 if(location.pathname.search("tree") != -1) {
... ...
app/views/projects/_tree_file.html.haml
... ... @@ -4,7 +4,7 @@
4 4 %strong
5 5 = name
6 6 = link_to "raw", blob_project_path(@project, :commit_id => @commit.id, :path => params[:path] ), :class => "right", :target => "_blank"
7   - = link_to "history", project_commits_path(@project, :path => params[:path]), :class => "right", :style => "margin-right:10px;"
  7 + = link_to "history", project_commits_path(@project, :path => params[:path], :branch => params[:branch], :tag => params[:tag] ), :class => "right", :style => "margin-right:10px;"
8 8 %br/
9 9 - if file.text?
10 10 .view_file_content
... ... @@ -14,6 +14,6 @@
14 14 .view_file_content_image
15 15 %img{ :src => "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"}
16 16 - else
17   - %p
  17 + %p
18 18 %center No preview for this file type
19 19  
... ...
app/views/projects/_tree_item.html.haml
... ... @@ -12,4 +12,4 @@
12 12 = time_ago_in_words(content_commit.committed_date)
13 13 ago
14 14 %td
15   - = link_to truncate_commit_message(content_commit, 40), project_commit_path(@project, content_commit)
  15 + = link_to truncate(content_commit.safe_message, :length => 40), project_commit_path(@project, content_commit)
... ...
config/initializers/grit_ext.rb
... ... @@ -6,3 +6,7 @@ Grit::Blob.class_eval do
6 6 include Utils::FileHelper
7 7 include Utils::Colorize
8 8 end
  9 +
  10 +Grit::Commit.class_eval do
  11 + include CommitExt
  12 +end
... ...
db/fixtures/development/001_admin.rb
1   -# Admin account
2 1 admin = User.create(
3 2 :email => "admin@local.host",
4 3 :name => "Administrator",
... ... @@ -9,3 +8,12 @@ admin = User.create(
9 8 admin.projects_limit = 10000
10 9 admin.admin = true
11 10 admin.save!
  11 +
  12 +if admin.valid?
  13 +puts %q[
  14 +Administrator account created:
  15 +
  16 +login.........admin@local.host
  17 +password......5iveL!fe
  18 +]
  19 +end
... ...
db/fixtures/production/001_admin.rb
... ... @@ -8,3 +8,12 @@ admin = User.create(
8 8 admin.projects_limit = 10000
9 9 admin.admin = true
10 10 admin.save!
  11 +
  12 +if admin.valid?
  13 +puts %q[
  14 +Administrator account created:
  15 +
  16 +login.........admin@local.host
  17 +password......5iveL!fe
  18 +]
  19 +end
... ...
db/migrate/20111025134235_add_high_label_to_issue.rb 0 → 100644
... ... @@ -0,0 +1,5 @@
  1 +class AddHighLabelToIssue < ActiveRecord::Migration
  2 + def change
  3 + add_column :issues, :critical, :boolean, :default => false, :null => false
  4 + end
  5 +end
... ...
db/schema.rb
... ... @@ -11,7 +11,7 @@
11 11 #
12 12 # It's strongly recommended to check this file into your version control system.
13 13  
14   -ActiveRecord::Schema.define(:version => 20111021101550) do
  14 +ActiveRecord::Schema.define(:version => 20111025134235) do
15 15  
16 16 create_table "issues", :force => true do |t|
17 17 t.string "title"
... ... @@ -23,6 +23,7 @@ ActiveRecord::Schema.define(:version =&gt; 20111021101550) do
23 23 t.datetime "updated_at"
24 24 t.boolean "closed", :default => false, :null => false
25 25 t.integer "position", :default => 0
  26 + t.boolean "critical", :default => false, :null => false
26 27 end
27 28  
28 29 create_table "keys", :force => true do |t|
... ...
install.rb
... ... @@ -1,32 +0,0 @@
1   -root_path = File.expand_path(File.dirname(__FILE__))
2   -require File.join(root_path, "lib", "color")
3   -include Color
4   -
5   -#
6   -# ruby ./update.rb development # or test or production (default)
7   -#
8   -envs = ["production", "test", "development"]
9   -env = if envs.include?(ARGV[0])
10   - ARGV[0]
11   - else
12   - "production"
13   - end
14   -
15   -puts green " == Install for ENV=#{env} ..."
16   -
17   -# bundle install
18   -`bundle install`
19   -
20   -# migrate db
21   -`bundle exec rake db:create RAILS_ENV=#{env}`
22   -`bundle exec rake db:schema:load RAILS_ENV=#{env}`
23   -`bundle exec rake db:seed_fu RAILS_ENV=#{env}`
24   -
25   -puts green %q[
26   -Administrator account created:
27   -
28   -login.........admin@local.host
29   -password......5iveL!fe
30   -]
31   -
32   -puts green " == Done! Now you can start server"
lib/commit_ext.rb 0 → 100644
... ... @@ -0,0 +1,11 @@
  1 +module CommitExt
  2 + def safe_message
  3 + message.encode("UTF-8",
  4 + :invalid => :replace,
  5 + :undef => :replace,
  6 + :universal_newline => true,
  7 + :replace => "")
  8 + rescue
  9 + "-- invalid encoding for commit message"
  10 + end
  11 +end
... ...
lib/gitosis.rb
... ... @@ -42,7 +42,7 @@ class Gitosis
42 42 end
43 43  
44 44 def destroy_project(project)
45   - FileUtils.rm_rf(project.path_to_repo)
  45 + `sudo -u git rm -rf #{project.path_to_repo}`
46 46  
47 47 conf = IniFile.new(File.join(@local_dir,'gitosis','gitosis.conf'))
48 48  
... ...
spec/models/project_spec.rb
... ... @@ -4,11 +4,15 @@ describe Project do
4 4 describe "Associations" do
5 5 it { should have_many(:users) }
6 6 it { should have_many(:users_projects) }
  7 + it { should have_many(:issues) }
  8 + it { should have_many(:notes) }
  9 + it { should have_many(:snippets) }
7 10 end
8 11  
9 12 describe "Validation" do
10 13 it { should validate_presence_of(:name) }
11 14 it { should validate_presence_of(:path) }
  15 + it { should validate_presence_of(:code) }
12 16 end
13 17  
14 18 describe "Respond to" do
... ... @@ -31,6 +35,11 @@ describe Project do
31 35 it { should respond_to(:commit) }
32 36 end
33 37  
  38 + it "should not allow 'gitosis-admin' as repo name" do
  39 + should allow_value("blah").for(:path)
  40 + should_not allow_value("gitosis-admin").for(:path)
  41 + end
  42 +
34 43 it "should return valid url to repo" do
35 44 project = Project.new(:path => "somewhere")
36 45 project.url_to_repo.should == "git@localhost:somewhere.git"
... ...
spec/requests/team_members_spec.rb
... ... @@ -10,7 +10,9 @@ describe &quot;TeamMembers&quot; do
10 10 describe "View profile" do
11 11 it "should be available" do
12 12 visit(team_project_path(@project))
13   - find(:xpath, "//table[@id='team-table']//a[1]").click
  13 + within "#team-table" do
  14 + click_link(@user.name)
  15 + end
14 16 page.should have_content @user.skype
15 17 page.should_not have_content 'Twitter'
16 18 end
... ... @@ -29,19 +31,37 @@ describe &quot;TeamMembers&quot; do
29 31  
30 32 describe "fill in" do
31 33 before do
32   - check "team_member_read"
33 34 click_link "Select user"
34 35 click_link @user_1.name
35   - #select @user_1.name, :from => "team_member_user_id"
  36 +
  37 + within "#team_member_new" do
  38 + check "team_member_read"
  39 + check "team_member_write"
  40 + end
36 41 end
37 42  
38   - it { expect { click_button "Save" }.to change {UsersProject.count}.by(1) }
  43 + it { expect { click_button "Save";sleep(1) }.to change {UsersProject.count}.by(1) }
39 44  
40 45 it "should add new member to table" do
41 46 click_button "Save"
  47 + @member = UsersProject.last
42 48  
43   - page.should_not have_content("Add new member")
44 49 page.should have_content @user_1.name
  50 +
  51 + @member.read.should be_true
  52 + @member.write.should be_true
  53 + @member.admin.should be_false
  54 + end
  55 +
  56 + it "should not allow creation without access selected" do
  57 + within "#team_member_new" do
  58 + uncheck "team_member_read"
  59 + uncheck "team_member_write"
  60 + uncheck "team_member_admin"
  61 + end
  62 +
  63 + expect { click_button "Save" }.to_not change {UsersProject.count}
  64 + page.should have_content("Please choose at least one Role in the Access list")
45 65 end
46 66 end
47 67 end
... ...
update.rb
... ... @@ -1,44 +0,0 @@
1   -root_path = File.expand_path(File.dirname(__FILE__))
2   -require File.join(root_path, "lib", "color")
3   -include Color
4   -
5   -def version
6   - File.read("VERSION")
7   -end
8   -
9   -#
10   -# ruby ./update.rb development # or test or production (default)
11   -#
12   -envs = ["production", "test", "development"]
13   -env = if envs.include?(ARGV[0])
14   - ARGV[0]
15   - else
16   - "production"
17   - end
18   -
19   -puts yellow "== RAILS ENV | #{env}"
20   -current_version = version
21   -puts yellow "Your version is #{current_version}"
22   -puts yellow "Check for new version: $ git pull origin 1x"
23   -`git pull origin 1x` # pull from origin
24   -
25   -# latest version
26   -if version == current_version
27   - puts yellow "You have a latest version"
28   -else
29   - puts green "Update to #{version}"
30   -
31   -`bundle install`
32   -
33   - # migrate db
34   -if env == "development"
35   -`bundle exec rake db:migrate RAILS_ENV=development`
36   -`bundle exec rake db:migrate RAILS_ENV=test`
37   -else
38   -`bundle exec rake db:migrate RAILS_ENV=#{env}`
39   -end
40   -
41   - puts green "== Done! Now you can start/restart server"
42   -end
43   -
44   -