Skip to content
Snippets Groups Projects
Commit 6b030fd4 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

1.1pre1

parent 3a2b2733
No related branches found
No related tags found
No related merge requests found
Showing
with 308 additions and 21 deletions
Loading
Loading
@@ -13,6 +13,7 @@ Gitlab::Application.routes.draw do
get "errors/gitosis"
get "profile/password", :to => "profile#password"
put "profile/password", :to => "profile#password_update"
put "profile/edit", :to => "profile#social_update"
get "profile", :to => "profile#show"
#get "profile/:id", :to => "profile#show"
 
Loading
Loading
@@ -38,6 +39,8 @@ Gitlab::Application.routes.draw do
}
 
end
resources :snippets
resources :commits
resources :team_members
resources :issues do
Loading
Loading
class CreateSnippets < ActiveRecord::Migration
def change
create_table :snippets do |t|
t.string :title
t.text :content
t.integer :author_id, :null => false
t.integer :project_id, :null => false
t.timestamps
end
end
end
class AddContentTypeToSnippets < ActiveRecord::Migration
def change
add_column :snippets, :content_type, :string, :null => false, :default => "txt"
end
end
class AddFileNameToSnippets < ActiveRecord::Migration
def change
add_column :snippets, :file_name, :string
remove_column :snippets, :content_type
end
end
class AddSocialToUser < ActiveRecord::Migration
def change
add_column :users, :skype, :string
add_column :users, :linkedin, :string
add_column :users, :twitter, :string
end
end
class ChangeSocialFieldsInUsers < ActiveRecord::Migration
def up
remove_column :users, :skype
remove_column :users, :linkedin
remove_column :users, :twitter
add_column :users, :skype, :string, {:null => false, :default => ''}
add_column :users, :linkedin, :string, {:null => false, :default => ''}
add_column :users, :twitter, :string, {:null => false, :default => ''}
end
def down
end
end
Loading
Loading
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
 
ActiveRecord::Schema.define(:version => 20111015154310) do
ActiveRecord::Schema.define(:version => 20111021101550) do
 
create_table "issues", :force => true do |t|
t.string "title"
Loading
Loading
@@ -56,6 +56,16 @@ ActiveRecord::Schema.define(:version => 20111015154310) do
t.integer "owner_id"
end
 
create_table "snippets", :force => true do |t|
t.string "title"
t.text "content"
t.integer "author_id", :null => false
t.integer "project_id", :null => false
t.datetime "created_at"
t.datetime "updated_at"
t.string "file_name"
end
create_table "users", :force => true do |t|
t.string "email", :default => "", :null => false
t.string "encrypted_password", :limit => 128, :default => "", :null => false
Loading
Loading
@@ -72,6 +82,9 @@ ActiveRecord::Schema.define(:version => 20111015154310) do
t.string "name"
t.boolean "admin", :default => false, :null => false
t.integer "projects_limit", :default => 10
t.string "skype", :default => "", :null => false
t.string "linkedin", :default => "", :null => false
t.string "twitter", :default => "", :null => false
end
 
add_index "users", ["email"], :name => "index_users_on_email", :unique => true
Loading
Loading
Loading
Loading
@@ -11,6 +11,10 @@ module Color
colorize(text, "32m")
end
 
def yellow(text)
colorize(text, "93m")
end
def command(string)
`#{string}`
if $?.to_i > 0
Loading
Loading
Loading
Loading
@@ -27,13 +27,11 @@ class Gitosis
def configure
status = Timeout::timeout(20) do
File.open(File.join(Dir.tmpdir,"gitlabhq-gitosis.lock"), "w+") do |f|
begin
begin
f.flock(File::LOCK_EX)
pull
yield(self)
push
ensure
f.flock(File::LOCK_UN)
end
Loading
Loading
module Utils
def self.binary?(string)
string.each_byte do |x|
x.nonzero? or return true
module FileHelper
def binary?(string)
string.each_byte do |x|
x.nonzero? or return true
end
false
end
def image?
mime_type =~ /image/
end
def text?
mime_type =~ /application|text/ && !binary?(data)
end
end
module Colorize
def colorize
system_colorize(data, name)
end
def system_colorize(data, file_name)
ft = handle_file_type(file_name)
Pygments.highlight(data, :lexer => ft, :options => { :encoding => 'utf-8', :linenos => 'True' })
end
def handle_file_type(file_name, mime_type = nil)
if file_name =~ /(\.rb|\.ru|\.rake|Rakefile|\.gemspec|\.rbx|Gemfile)$/
:ruby
elsif file_name =~ /\.py$/
:python
elsif file_name =~ /(\.pl|\.scala|\.c|\.cpp|\.java|\.haml|\.html|\.sass|\.scss|\.xml|\.php|\.erb)$/
$1[1..-1].to_sym
elsif file_name =~ /\.js$/
:javascript
elsif file_name =~ /\.sh$/
:bash
elsif file_name =~ /\.coffee$/
:coffeescript
elsif file_name =~ /\.yml$/
:yaml
elsif file_name =~ /\.md$/
:minid
else
:text
end
end
false
end
end
Loading
Loading
@@ -35,6 +35,12 @@ Factory.add(:issue, Issue) do |obj|
obj.content = Faker::Lorem.sentences
end
 
Factory.add(:snippet, Snippet) do |obj|
obj.title = Faker::Lorem.sentence
obj.file_name = Faker::Lorem.sentence
obj.content = Faker::Lorem.sentences
end
Factory.add(:note, Note) do |obj|
obj.note = Faker::Lorem.sentence
end
Loading
Loading
Loading
Loading
@@ -38,5 +38,6 @@ end
# created_at :datetime
# updated_at :datetime
# closed :boolean default(FALSE), not null
# position :integer default(0)
#
 
require 'spec_helper'
describe Snippet do
describe "Associations" do
it { should belong_to(:project) }
it { should belong_to(:author) }
end
describe "Validation" do
it { should validate_presence_of(:title) }
it { should validate_presence_of(:author_id) }
it { should validate_presence_of(:project_id) }
it { should validate_presence_of(:file_name) }
it { should validate_presence_of(:content) }
end
end
# == Schema Information
#
# Table name: snippets
#
# id :integer not null, primary key
# title :string(255)
# content :text
# author_id :integer not null
# project_id :integer not null
# created_at :datetime
# updated_at :datetime
# file_name :string(255)
#
Loading
Loading
@@ -39,5 +39,8 @@ end
# name :string(255)
# admin :boolean default(FALSE), not null
# projects_limit :integer
# skype :string
# linkedin :string
# twitter :string
#
 
Loading
Loading
@@ -14,6 +14,22 @@ describe "Profile" do
it { page.should have_content(@user.email) }
end
 
describe "Profile update" do
before do
visit profile_path
fill_in "user_skype", :with => "testskype"
fill_in "user_linkedin", :with => "testlinkedin"
fill_in "user_twitter", :with => "testtwitter"
click_button "Save"
@user.reload
end
it { @user.skype.should == 'testskype' }
it { @user.linkedin.should == 'testlinkedin' }
it { @user.twitter.should == 'testtwitter' }
end
describe "Password update" do
before do
visit profile_password_path
Loading
Loading
Loading
Loading
@@ -82,12 +82,18 @@ describe "Projects" do
end
 
describe "GET /project_code/blob" do
it { blob_project_path(@project).should be_allowed_for @u1 }
it { blob_project_path(@project).should be_allowed_for @u3 }
it { blob_project_path(@project).should be_denied_for :admin }
it { blob_project_path(@project).should be_denied_for @u2 }
it { blob_project_path(@project).should be_denied_for :user }
it { blob_project_path(@project).should be_denied_for :visitor }
before do
@commit = @project.commit
@path = @commit.tree.contents.select { |i| i.is_a?(Grit::Blob)}.first.name
@blob_path = blob_project_path(@project, :commit_id => @commit.id, :path => @path)
end
it { @blob_path.should be_allowed_for @u1 }
it { @blob_path.should be_allowed_for @u3 }
it { @blob_path.should be_denied_for :admin }
it { @blob_path.should be_denied_for @u2 }
it { @blob_path.should be_denied_for :user }
it { @blob_path.should be_denied_for :visitor }
end
 
describe "GET /project_code/edit" do
Loading
Loading
@@ -107,5 +113,14 @@ describe "Projects" do
it { project_issues_path(@project).should be_denied_for :user }
it { project_issues_path(@project).should be_denied_for :visitor }
end
describe "GET /project_code/snippets" do
it { project_snippets_path(@project).should be_allowed_for @u1 }
it { project_snippets_path(@project).should be_allowed_for @u3 }
it { project_snippets_path(@project).should be_denied_for :admin }
it { project_snippets_path(@project).should be_denied_for @u2 }
it { project_snippets_path(@project).should be_denied_for :user }
it { project_snippets_path(@project).should be_denied_for :visitor }
end
end
end
Loading
Loading
@@ -72,7 +72,10 @@ describe "Projects" do
current_path.should == project_path(@project)
end
 
it_behaves_like :tree_view
it "should beahave like dashboard" do
page.should have_content("History")
end
end
 
describe "GET /projects/team" do
Loading
Loading
@@ -134,8 +137,6 @@ describe "Projects" do
it "should show project" do
page.should have_content("Awesome")
end
it_behaves_like :tree_view
end
 
#describe "DELETE /projects/:id", :js => true do
Loading
Loading
require 'spec_helper'
describe "Snippets" do
let(:project) { Factory :project }
before do
login_as :user
project.add_access(@user, :read, :write)
end
describe "GET /snippets" do
before do
@snippet = Factory :snippet,
:author => @user,
:project => project
visit project_snippets_path(project)
end
subject { page }
it { should have_content(@snippet.title) }
it { should have_content(@snippet.project.name) }
it { should have_content(@snippet.author.name) }
describe "Destroy" do
before do
# admin access to remove snippet
@user.users_projects.destroy_all
project.add_access(@user, :read, :write, :admin)
visit project_snippets_path(project)
end
it "should remove entry" do
expect {
click_link "destroy_snippet_#{@snippet.id}"
}.to change { Snippet.count }.by(-1)
end
end
end
describe "New snippet" do
before do
visit project_snippets_path(project)
click_link "New Snippet"
end
it "should open new snippet popup" do
page.current_path.should == new_project_snippet_path(project)
end
describe "fill in" do
before do
fill_in "snippet_title", :with => "login function"
fill_in "snippet_file_name", :with => "test.rb"
fill_in "snippet_content", :with => "def login; end"
end
it { expect { click_button "Save" }.to change {Snippet.count}.by(1) }
it "should add new snippet to table" do
click_button "Save"
page.current_path.should == project_snippet_path(project, Snippet.last)
page.should have_content "login function"
page.should have_content "test.rb"
end
end
end
describe "Edit snippet" do
before do
@snippet = Factory :snippet,
:author => @user,
:project => project
visit project_snippets_path(project)
click_link "Edit"
end
it "should open edit page" do
page.current_path.should == edit_project_snippet_path(project, @snippet)
end
describe "fill in" do
before do
fill_in "snippet_title", :with => "login function"
fill_in "snippet_file_name", :with => "test.rb"
fill_in "snippet_content", :with => "def login; end"
end
it { expect { click_button "Save" }.to_not change {Snippet.count} }
it "should update snippet fields" do
click_button "Save"
page.current_path.should == project_snippet_path(project, @snippet)
page.should have_content "login function"
page.should have_content "test.rb"
end
end
end
end
Loading
Loading
@@ -7,6 +7,15 @@ describe "TeamMembers" do
@project.add_access(@user, :read, :admin)
end
 
describe "View profile" do
it "should be available" do
visit(team_project_path(@project))
find(:xpath, "//table[@id='team-table']//a[1]").click
page.should have_content @user.skype
page.should_not have_content 'Twitter'
end
end
describe "New Team member", :js => true do
before do
@user_1 = Factory :user
Loading
Loading
Loading
Loading
@@ -7,10 +7,10 @@ describe "Users Security" do
end
 
describe "GET /login" do
it { new_user_session_path.should be_denied_for @u1 }
it { new_user_session_path.should be_denied_for :admin }
it { new_user_session_path.should be_denied_for :user }
it { new_user_session_path.should be_allowed_for :visitor }
#it { new_user_session_path.should be_denied_for @u1 }
#it { new_user_session_path.should be_denied_for :admin }
#it { new_user_session_path.should be_denied_for :user }
it { new_user_session_path.should_not be_404_for :visitor }
end
 
describe "GET /keys" do
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment