Skip to content
Snippets Groups Projects
Commit 9ba12248 authored by gitlabhq's avatar gitlabhq
Browse files

init commit

parent 93efff94
No related branches found
No related tags found
No related merge requests found
Showing
with 642 additions and 0 deletions
require 'spec_helper'
describe "Projects" do
before { login_as :user }
describe "GET /projects" do
before do
visit projects_path
end
it "should be on projects page" do
current_path.should == projects_path
end
it "should have link to new project" do
page.should have_content("New Project")
end
end
describe "GET /projects/new" do
before do
visit projects_path
click_link "New Project"
end
it "should be correct path" do
current_path.should == new_project_path
end
it "should have labels for new project" do
page.should have_content("Name")
page.should have_content("Path")
page.should have_content("Description")
end
end
describe "POST /projects" do
before do
visit new_project_path
fill_in 'Name', :with => 'NewProject'
fill_in 'Code', :with => 'NPR'
fill_in 'Path', :with => '/tmp/legit_test/legit'
expect { click_button "Create Project" }.to change { Project.count }.by(1)
@project = Project.last
end
it "should be correct path" do
current_path.should == project_path(@project)
end
it "should show project" do
page.should have_content(@project.name)
page.should have_content(@project.path)
page.should have_content(@project.description)
end
it "should init repo instructions" do
page.should have_content("git remote")
page.should have_content(@project.url_to_repo)
end
end
describe "GET /projects/show" do
before do
@project = Factory :project
@project.add_access(@user, :read)
visit project_path(@project)
end
it "should be correct path" do
current_path.should == project_path(@project)
end
it_behaves_like :tree_view
end
describe "GET /projects/team" do
before do
@project = Factory :project
@project.add_access(@user, :read)
visit team_project_path(@project,
:path => ValidCommit::BLOB_FILE_PATH,
:commit_id => ValidCommit::ID)
end
it "should be correct path" do
current_path.should == team_project_path(@project)
end
it "should have as as team member" do
page.should have_content(@user.name)
end
end
describe "GET /projects/:id/edit" do
before do
@project = Factory :project
@project.add_access(@user, :admin, :read)
visit edit_project_path(@project)
end
it "should be correct path" do
current_path.should == edit_project_path(@project)
end
it "should have labels for new project" do
page.should have_content("Name")
page.should have_content("Path")
page.should have_content("Description")
end
end
describe "PUT /projects/:id" do
before do
@project = Factory :project
@project.add_access(@user, :admin, :read)
visit edit_project_path(@project)
fill_in 'Name', :with => 'Awesome'
fill_in 'Path', :with => 'legit'
fill_in 'Description', :with => 'Awesome project'
click_button "Update Project"
@project = @project.reload
end
it "should be correct path" do
current_path.should == project_path(@project)
end
it "should show project" do
page.should have_content("Awesome")
end
it_behaves_like :tree_view
end
#describe "DELETE /projects/:id", :js => true do
#before do
#@project = Factory :project
#@project.add_access(@user, :read, :admin)
#visit projects_path
#end
#it "should be correct path" do
#expect { click_link "Destroy" }.to change {Project.count}.by(1)
#end
#end
end
require 'spec_helper'
describe "Projects" do
before { login_as :user }
describe "GET /projects/tree" do
describe "head" do
before do
@project = Factory :project
@project.add_access(@user, :read)
visit tree_project_path(@project)
end
it "should be correct path" do
current_path.should == tree_project_path(@project)
end
it_behaves_like :tree_view
end
describe ValidCommit::ID do
before do
@project = Factory :project
@project.add_access(@user, :read)
visit tree_project_path(@project, :commit_id => ValidCommit::ID)
end
it "should be correct path" do
current_path.should == tree_project_path(@project)
end
it_behaves_like :tree_view
it_behaves_like :project_side_pane
end
describe "branch passed" do
before do
@project = Factory :project
@project.add_access(@user, :read)
visit tree_project_path(@project, :branch => "master")
end
it "should be correct path" do
current_path.should == tree_project_path(@project)
end
it_behaves_like :tree_view
it_behaves_like :project_side_pane
end
# TREE FILE PREVIEW
describe "file preview" do
before do
@project = Factory :project
@project.add_access(@user, :read)
visit tree_project_path(@project, :path => ".rvmrc")
end
it "should be correct path" do
current_path.should == tree_project_path(@project)
end
it "should contain file view" do
page.should have_content("rvm use 1.9.2@legit")
end
end
end
# RAW FILE
describe "GET /projects/blob" do
before do
@project = Factory :project
@project.add_access(@user, :read)
visit blob_project_path(@project,
:path => ValidCommit::BLOB_FILE_PATH,
:commit_id => ValidCommit::ID)
end
it "should be correct path" do
current_path.should == blob_project_path(@project)
end
it "raw file response" do
page.source.should == ValidCommit::BLOB_FILE
end
end
end
require 'spec_helper'
describe "Projects", "Wall" do
let(:project) { Factory :project }
before do
login_as :user
project.add_access(@user, :read, :write)
end
describe "View notes on wall" do
before do
Factory :note, :project => project, :note => "Project specs", :author => @user
visit wall_project_path(project)
end
it { page.should have_content("Project specs") }
it { page.should have_content(@user.name) }
it { page.should have_content("less than a minute ago") }
end
describe "add new note", :js => true do
before do
visit wall_project_path(project)
fill_in "note_note", :with => "my post on wall"
click_button "Add note"
end
it "should conatin new note" do
page.should have_content("my post on wall")
end
end
end
require 'spec_helper'
describe "TeamMembers" do
before do
login_as :user
@project = Factory :project
@project.add_access(@user, :read, :admin)
end
describe "New Team member", :js => true do
before do
@user_1 = Factory :user
visit team_project_path(@project)
click_link "Add new"
end
it "should open new team member popup" do
page.should have_content("Add new member to project")
end
describe "fill in" do
before do
check "team_member_read"
click_link "Select user"
click_link @user_1.name
#select @user_1.name, :from => "team_member_user_id"
end
it { expect { click_button "Save" }.to change {UsersProject.count}.by(1) }
it "should add new member to table" do
click_button "Save"
page.should_not have_content("Add new member")
page.should have_content @user_1.name
end
end
end
describe "Cancel membership" do
it "should cancel membership" do
visit team_project_path(@project)
expect { click_link "Cancel" }.to change { UsersProject.count }.by(-1)
end
end
end
require 'spec_helper'
describe "Top Panel", :js => true do
before { login_as :user }
describe "Search autocomplete" do
before do
visit projects_path
fill_in "search", :with => "Ke"
sleep(2)
find(:xpath, "//ul[contains(@class,'ui-autocomplete')]/li/a[.=\"Keys\"]").click
end
it "should be on projects page" do
current_path.should == keys_path
end
end
describe "with project" do
before do
@project = Factory :project
@project.add_access(@user, :read)
visit project_path(@project)
fill_in "search", :with => "Commi"
sleep(2)
find(:xpath, "//ul[contains(@class,'ui-autocomplete')]/li/a[.=\"#{@project.code} / Commits\"]").click
end
it "should be on projects page" do
current_path.should == project_commits_path(@project)
end
end
end
require 'spec_helper'
describe "Users Security" do
describe "Project" do
before do
@u1 = Factory :user
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 }
end
describe "GET /keys" do
it { keys_path.should be_allowed_for @u1 }
it { keys_path.should be_allowed_for :admin }
it { keys_path.should be_allowed_for :user }
it { keys_path.should be_denied_for :visitor }
end
describe "GET /profile" do
it { profile_path.should be_allowed_for @u1 }
it { profile_path.should be_allowed_for :admin }
it { profile_path.should be_allowed_for :user }
it { profile_path.should be_denied_for :visitor }
end
describe "GET /profile/password" do
it { profile_password_path.should be_allowed_for @u1 }
it { profile_password_path.should be_allowed_for :admin }
it { profile_password_path.should be_allowed_for :user }
it { profile_password_path.should be_denied_for :visitor }
end
end
end
File added
require 'simplecov'
SimpleCov.start 'rails'
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'capybara/rails'
require 'capybara/rspec'
require 'capybara/dsl'
require 'factories'
require 'monkeypatch'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
RSpec.configure do |config|
# == Mock Framework
#
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
#
# config.mock_with :mocha
# config.mock_with :flexmock
# config.mock_with :rr
config.mock_with :rspec
config.include LoginMacros
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = false
config.before :each, :type => :integration do
DeviseSessionMock.disable
end
config.before do
if example.metadata[:js]
DatabaseCleaner.strategy = :truncation
else
DatabaseCleaner.strategy = :transaction
end
DatabaseCleaner.start
end
config.after do
DatabaseCleaner.clean
end
end
module JsPatch
def confirm_js_popup
page.evaluate_script("window.alert = function(msg) { return true; }")
page.evaluate_script("window.confirm = function(msg) { return true; }")
end
end
module LoginMacros
def login_as role
@user = User.create(:email => "user#{User.count}@mail.com",
:name => "John Smith",
:password => "123456",
:password_confirmation => "123456")
if role == :admin
@user.admin = true
@user.save!
end
visit new_user_session_path
fill_in "Email", :with => @user.email
fill_in "Password", :with => "123456"
click_button "Sign in"
end
def login_with(user)
visit new_user_session_path
fill_in "Email", :with => user.email
fill_in "Password", :with => "123456"
click_button "Sign in"
end
def logout
click_link "Logout" rescue nil
end
end
RSpec::Matchers.define :be_valid_commit do
match do |actual|
actual != nil
actual.id == ValidCommit::ID
actual.message == ValidCommit::MESSAGE
actual.author.name == ValidCommit::AUTHOR_FULL_NAME
end
end
RSpec::Matchers.define :be_allowed_for do |user|
match do |url|
include UrlAccess
url_allowed?(user, url)
end
end
RSpec::Matchers.define :be_denied_for do |user|
match do |url|
include UrlAccess
url_denied?(user, url)
end
end
module UrlAccess
def url_allowed?(user, url)
emulate_user(user)
visit url
result = (current_path == url)
end
def url_denied?(user, url)
emulate_user(user)
visit url
result = (current_path != url)
end
def emulate_user(user)
user = case user
when :user then Factory(:user)
when :visitor then nil
when :admin then Factory(:admin)
else user
end
login_with(user) if user
end
end
shared_examples_for :project_side_pane do
subject { page }
it { should have_content((@project || project).name) }
it { should have_content("Commits") }
it { should have_content("Team") }
it { should have_content("Tree") }
end
shared_examples_for :tree_view do
subject { page }
it "should have Tree View of project" do
should have_content("app")
should have_content("history")
should have_content("Gemfile")
end
end
module ValidCommit
ID = "eaffbe556ec3a8dc84ef15892a9f12d84dde7e1d"
MESSAGE = "style"
AUTHOR_FULL_NAME = "Dmitriy Zaporozhets"
FILES = [".gitignore", ".rspec", ".rvmrc", "Gemfile", "Gemfile.lock", "LICENSE", "README.rdoc", "Rakefile", "app", "config.ru", "config", "db", "doc", "lib", "log", "public", "script", "spec", "vendor"]
FILES_COUNT = 19
C_FILE_PATH = "app/models"
C_FILES = [".gitkeep", "project.rb", "user.rb"]
BLOB_FILE = <<-blob
<div class="span-14 colborder">
<h2>Tree / <%= link_to "Commits", project_commits_path(@project) %></h2>
<%= render :partial => "tree", :locals => {:repo => @repo, :commit => @commit, :tree => @commit.tree} %>
</div>
<div class="span-8 right">
<%= render "side_panel" %>
</div>
blob
BLOB_FILE_PATH = "app/views/projects/show.html.erb"
end
/* -----------------------------------------------------------------------
Blueprint CSS Framework 1.0.1
http://blueprintcss.org
* Copyright (c) 2007-Present. See LICENSE for more info.
* See README for instructions on how to use Blueprint.
* For credits and origins, see AUTHORS.
* This is a compressed file. See the sources in the 'src' directory.
----------------------------------------------------------------------- */
/* ie.css */
body {text-align:center;}
.container {text-align:left;}
* html .column, * html .span-1, * html .span-2, * html .span-3, * html .span-4, * html .span-5, * html .span-6, * html .span-7, * html .span-8, * html .span-9, * html .span-10, * html .span-11, * html .span-12, * html .span-13, * html .span-14, * html .span-15, * html .span-16, * html .span-17, * html .span-18, * html .span-19, * html .span-20, * html .span-21, * html .span-22, * html .span-23, * html .span-24 {display:inline;overflow-x:hidden;}
* html legend {margin:0px -8px 16px 0;padding:0;}
sup {vertical-align:text-top;}
sub {vertical-align:text-bottom;}
html>body p code {*white-space:normal;}
hr {margin:-8px auto 11px;}
img {-ms-interpolation-mode:bicubic;}
.clearfix, .container {display:inline-block;}
* html .clearfix, * html .container {height:1%;}
fieldset {padding-top:0;}
legend {margin-top:-0.2em;margin-bottom:1em;margin-left:-0.5em;}
textarea {overflow:auto;}
label {vertical-align:middle;position:relative;top:-0.25em;}
input.text, input.title, textarea {background-color:#fff;border:1px solid #bbb;}
input.text:focus, input.title:focus {border-color:#666;}
input.text, input.title, textarea, select {margin:0.5em 0;}
input.checkbox, input.radio {position:relative;top:.25em;}
form.inline div, form.inline p {vertical-align:middle;}
form.inline input.checkbox, form.inline input.radio, form.inline input.button, form.inline button {margin:0.5em 0;}
button, input.button {position:relative;top:0.25em;}
\ No newline at end of file
vendor/assets/stylesheets/blueprint/plugins/buttons/icons/cross.png

655 B

vendor/assets/stylesheets/blueprint/plugins/buttons/icons/key.png

455 B

vendor/assets/stylesheets/blueprint/plugins/buttons/icons/tick.png

537 B

Buttons
* Gives you great looking CSS buttons, for both <a> and <button>.
* Demo: particletree.com/features/rediscovering-the-button-element
Credits
----------------------------------------------------------------
* Created by Kevin Hale [particletree.com]
* Adapted for Blueprint by Olav Bjorkoy [bjorkoy.com]
Usage
----------------------------------------------------------------
1) Add this plugin to lib/settings.yml.
See compress.rb for instructions.
2) Use the following HTML code to place the buttons on your site:
<button type="submit" class="button positive">
<img src="css/blueprint/plugins/buttons/icons/tick.png" alt=""/> Save
</button>
<a class="button" href="/password/reset/">
<img src="css/blueprint/plugins/buttons/icons/key.png" alt=""/> Change Password
</a>
<a href="#" class="button negative">
<img src="css/blueprint/plugins/buttons/icons/cross.png" alt=""/> Cancel
</a>
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