Commit f614ae8ef71bf1de7deeeaadbdf9a4a8614771b1

Authored by Dmitriy Zaporozhets
1 parent e9be4b37

Increased test coverage

app/views/projects/_clone_panel.html.haml
... ... @@ -6,12 +6,12 @@
6 6 .right
7 7 - unless @project.empty_repo?
8 8 - if can? current_user, :download_code, @project
9   - = link_to archive_project_repository_path(@project), class: "btn grouped" do
  9 + = link_to archive_project_repository_path(@project), class: "btn-small btn grouped" do
10 10 %i.icon-download-alt
11 11 Download
12 12 - if @project.merge_requests_enabled && can?(current_user, :write_merge_request, @project)
13   - = link_to new_project_merge_request_path(@project), title: "New Merge Request", class: "btn grouped" do
  13 + = link_to new_project_merge_request_path(@project), title: "New Merge Request", class: "btn-small btn grouped" do
14 14 Merge Request
15 15 - if @project.issues_enabled && can?(current_user, :write_issue, @project)
16   - = link_to new_project_issue_path(@project), title: "New Issue", class: "btn grouped" do
  16 + = link_to new_project_issue_path(@project), title: "New Issue", class: "btn-small btn grouped" do
17 17 Issue
... ...
app/views/snippets/_form.html.haml
1   -%h3= @snippet.new_record? ? "New Snippet" : "Edit Snippet ##{@snippet.id}"
  1 +%h3.page_title
  2 + = @snippet.new_record? ? "New Snippet" : "Edit Snippet ##{@snippet.id}"
2 3 %hr
3 4 = form_for [@project, @snippet] do |f|
4   - %table.no-borders
5   - -if @snippet.errors.any?
6   - .alert-message.block-message.error
7   - %ul
8   - - @snippet.errors.full_messages.each do |msg|
9   - %li= msg
  5 + -if @snippet.errors.any?
  6 + .alert-message.block-message.error
  7 + %ul
  8 + - @snippet.errors.full_messages.each do |msg|
  9 + %li= msg
10 10  
11   - .clearfix
12   - = f.label :title
13   - .input= f.text_field :title, placeholder: "Example Snippet"
14   - .clearfix
15   - = f.label :file_name
16   - .input= f.text_field :file_name, placeholder: "example.rb"
17   - .clearfix
18   - = f.label "Lifetime"
19   - .input= f.select :expires_at, lifetime_select_options, {}, {class: 'chosen span2'}
20   - .clearfix
21   - = f.label :content, "Code"
22   - .input= f.text_area :content, class: "span8"
  11 + .clearfix
  12 + = f.label :title
  13 + .input= f.text_field :title, placeholder: "Example Snippet"
  14 + .clearfix
  15 + = f.label :file_name
  16 + .input= f.text_field :file_name, placeholder: "example.rb"
  17 + .clearfix
  18 + = f.label "Lifetime"
  19 + .input= f.select :expires_at, lifetime_select_options, {}, {class: 'chosen span2'}
  20 + .clearfix
  21 + = f.label :content, "Code"
  22 + .input= f.text_area :content, class: "span8"
23 23  
24   - .actions
  24 + .form-actions
25 25 = f.submit 'Save', class: "primary btn"
26 26 = link_to "Cancel", project_snippets_path(@project), class: " btn"
27 27 - unless @snippet.new_record?
... ...
features/support/env.rb
... ... @@ -5,7 +5,7 @@ require 'rspec'
5 5 require 'database_cleaner'
6 6 require 'spinach/capybara'
7 7  
8   -%w(namespaces_stub gitolite_stub stubbed_repository valid_commit).each do |f|
  8 +%w(gitolite_stub stubbed_repository valid_commit).each do |f|
9 9 require Rails.root.join('spec', 'support', f)
10 10 end
11 11  
... ... @@ -32,6 +32,11 @@ end
32 32 DatabaseCleaner.strategy = :truncation
33 33  
34 34 Spinach.hooks.before_scenario do
  35 + # Use tmp dir for FS manipulations
  36 + Gitlab.config.stub(git_base_path: Rails.root.join('tmp', 'test-git-base-path'))
  37 + FileUtils.rm_rf Gitlab.config.git_base_path
  38 + FileUtils.mkdir_p Gitlab.config.git_base_path
  39 +
35 40 DatabaseCleaner.start
36 41 end
37 42  
... ...
spec/models/group_spec.rb
... ... @@ -22,4 +22,12 @@ describe Group do
22 22 it { should validate_presence_of :path }
23 23 it { should validate_uniqueness_of(:path) }
24 24 it { should validate_presence_of :owner }
  25 +
  26 + describe :users do
  27 + it { group.users.should == [] }
  28 + end
  29 +
  30 + describe :human_name do
  31 + it { group.human_name.should == group.name }
  32 + end
25 33 end
... ...
spec/models/namespace_spec.rb
... ... @@ -32,4 +32,46 @@ describe Namespace do
32 32 it { should respond_to(:human_name) }
33 33 it { should respond_to(:to_param) }
34 34 end
  35 +
  36 + it { Namespace.global_id.should == 'GLN' }
  37 +
  38 + describe :to_param do
  39 + it { namespace.to_param.should == namespace.path }
  40 + end
  41 +
  42 + describe :human_name do
  43 + it { namespace.human_name.should == namespace.owner_name }
  44 + end
  45 +
  46 + describe :search do
  47 + before do
  48 + @namespace = create :namespace
  49 + end
  50 +
  51 + it { Namespace.search(@namespace.path).should == [@namespace] }
  52 + it { Namespace.search('unknown').should == [] }
  53 + end
  54 +
  55 + describe :move_dir do
  56 + before do
  57 + @namespace = create :namespace
  58 + end
  59 +
  60 + it "should raise error when called directly" do
  61 + expect { @namespace.move_dir }.to raise_error("Already exists")
  62 + end
  63 +
  64 + it "should move dir if path changed" do
  65 + new_path = @namespace.path + "_new"
  66 + @namespace.stub(path_was: @namespace.path)
  67 + @namespace.stub(path: new_path)
  68 + @namespace.move_dir.should be_true
  69 + end
  70 + end
  71 +
  72 + describe :rm_dir do
  73 + it "should remove dir" do
  74 + namespace.rm_dir.should be_true
  75 + end
  76 + end
35 77 end
... ...
spec/spec_helper.rb
... ... @@ -40,5 +40,10 @@ RSpec.configure do |config|
40 40 # !!! Observers disabled by default in tests
41 41 ActiveRecord::Base.observers.disable(:all)
42 42 # ActiveRecord::Base.observers.enable(:all)
  43 +
  44 + # Use tmp dir for FS manipulations
  45 + Gitlab.config.stub(git_base_path: Rails.root.join('tmp', 'test-git-base-path'))
  46 + FileUtils.rm_rf Gitlab.config.git_base_path
  47 + FileUtils.mkdir_p Gitlab.config.git_base_path
43 48 end
44 49 end
... ...
spec/support/namespaces_stub.rb
... ... @@ -1,18 +0,0 @@
1   -require 'namespace'
2   -require 'gitlab/project_mover'
3   -
4   -class Namespace
5   - def ensure_dir_exist
6   - true
7   - end
8   -
9   - def move_dir
10   - true
11   - end
12   -end
13   -
14   -#class Gitlab::ProjectMover
15   - #def execute
16   - #true
17   - #end
18   -#end