Increased test coverage

This commit is contained in:
Dmitriy Zaporozhets 2012-11-21 07:14:05 +03:00
parent e9be4b375b
commit f614ae8ef7
7 changed files with 84 additions and 42 deletions

View file

@ -6,12 +6,12 @@
.right .right
- unless @project.empty_repo? - unless @project.empty_repo?
- if can? current_user, :download_code, @project - if can? current_user, :download_code, @project
= link_to archive_project_repository_path(@project), class: "btn grouped" do = link_to archive_project_repository_path(@project), class: "btn-small btn grouped" do
%i.icon-download-alt %i.icon-download-alt
Download Download
- if @project.merge_requests_enabled && can?(current_user, :write_merge_request, @project) - if @project.merge_requests_enabled && can?(current_user, :write_merge_request, @project)
= link_to new_project_merge_request_path(@project), title: "New Merge Request", class: "btn grouped" do = link_to new_project_merge_request_path(@project), title: "New Merge Request", class: "btn-small btn grouped" do
Merge Request Merge Request
- if @project.issues_enabled && can?(current_user, :write_issue, @project) - if @project.issues_enabled && can?(current_user, :write_issue, @project)
= link_to new_project_issue_path(@project), title: "New Issue", class: "btn grouped" do = link_to new_project_issue_path(@project), title: "New Issue", class: "btn-small btn grouped" do
Issue Issue

View file

@ -1,27 +1,27 @@
%h3= @snippet.new_record? ? "New Snippet" : "Edit Snippet ##{@snippet.id}" %h3.page_title
= @snippet.new_record? ? "New Snippet" : "Edit Snippet ##{@snippet.id}"
%hr %hr
= form_for [@project, @snippet] do |f| = form_for [@project, @snippet] do |f|
%table.no-borders -if @snippet.errors.any?
-if @snippet.errors.any? .alert-message.block-message.error
.alert-message.block-message.error %ul
%ul - @snippet.errors.full_messages.each do |msg|
- @snippet.errors.full_messages.each do |msg| %li= msg
%li= msg
.clearfix .clearfix
= f.label :title = f.label :title
.input= f.text_field :title, placeholder: "Example Snippet" .input= f.text_field :title, placeholder: "Example Snippet"
.clearfix .clearfix
= f.label :file_name = f.label :file_name
.input= f.text_field :file_name, placeholder: "example.rb" .input= f.text_field :file_name, placeholder: "example.rb"
.clearfix .clearfix
= f.label "Lifetime" = f.label "Lifetime"
.input= f.select :expires_at, lifetime_select_options, {}, {class: 'chosen span2'} .input= f.select :expires_at, lifetime_select_options, {}, {class: 'chosen span2'}
.clearfix .clearfix
= f.label :content, "Code" = f.label :content, "Code"
.input= f.text_area :content, class: "span8" .input= f.text_area :content, class: "span8"
.actions .form-actions
= f.submit 'Save', class: "primary btn" = f.submit 'Save', class: "primary btn"
= link_to "Cancel", project_snippets_path(@project), class: " btn" = link_to "Cancel", project_snippets_path(@project), class: " btn"
- unless @snippet.new_record? - unless @snippet.new_record?

View file

@ -5,7 +5,7 @@ require 'rspec'
require 'database_cleaner' require 'database_cleaner'
require 'spinach/capybara' require 'spinach/capybara'
%w(namespaces_stub gitolite_stub stubbed_repository valid_commit).each do |f| %w(gitolite_stub stubbed_repository valid_commit).each do |f|
require Rails.root.join('spec', 'support', f) require Rails.root.join('spec', 'support', f)
end end
@ -32,6 +32,11 @@ end
DatabaseCleaner.strategy = :truncation DatabaseCleaner.strategy = :truncation
Spinach.hooks.before_scenario do Spinach.hooks.before_scenario do
# Use tmp dir for FS manipulations
Gitlab.config.stub(git_base_path: Rails.root.join('tmp', 'test-git-base-path'))
FileUtils.rm_rf Gitlab.config.git_base_path
FileUtils.mkdir_p Gitlab.config.git_base_path
DatabaseCleaner.start DatabaseCleaner.start
end end

View file

@ -22,4 +22,12 @@ describe Group do
it { should validate_presence_of :path } it { should validate_presence_of :path }
it { should validate_uniqueness_of(:path) } it { should validate_uniqueness_of(:path) }
it { should validate_presence_of :owner } it { should validate_presence_of :owner }
describe :users do
it { group.users.should == [] }
end
describe :human_name do
it { group.human_name.should == group.name }
end
end end

View file

@ -32,4 +32,46 @@ describe Namespace do
it { should respond_to(:human_name) } it { should respond_to(:human_name) }
it { should respond_to(:to_param) } it { should respond_to(:to_param) }
end end
it { Namespace.global_id.should == 'GLN' }
describe :to_param do
it { namespace.to_param.should == namespace.path }
end
describe :human_name do
it { namespace.human_name.should == namespace.owner_name }
end
describe :search do
before do
@namespace = create :namespace
end
it { Namespace.search(@namespace.path).should == [@namespace] }
it { Namespace.search('unknown').should == [] }
end
describe :move_dir do
before do
@namespace = create :namespace
end
it "should raise error when called directly" do
expect { @namespace.move_dir }.to raise_error("Already exists")
end
it "should move dir if path changed" do
new_path = @namespace.path + "_new"
@namespace.stub(path_was: @namespace.path)
@namespace.stub(path: new_path)
@namespace.move_dir.should be_true
end
end
describe :rm_dir do
it "should remove dir" do
namespace.rm_dir.should be_true
end
end
end end

View file

@ -40,5 +40,10 @@ RSpec.configure do |config|
# !!! Observers disabled by default in tests # !!! Observers disabled by default in tests
ActiveRecord::Base.observers.disable(:all) ActiveRecord::Base.observers.disable(:all)
# ActiveRecord::Base.observers.enable(:all) # ActiveRecord::Base.observers.enable(:all)
# Use tmp dir for FS manipulations
Gitlab.config.stub(git_base_path: Rails.root.join('tmp', 'test-git-base-path'))
FileUtils.rm_rf Gitlab.config.git_base_path
FileUtils.mkdir_p Gitlab.config.git_base_path
end end
end end

View file

@ -1,18 +0,0 @@
require 'namespace'
require 'gitlab/project_mover'
class Namespace
def ensure_dir_exist
true
end
def move_dir
true
end
end
#class Gitlab::ProjectMover
#def execute
#true
#end
#end