Commit 9304d049 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Fixed some tests and snippet colorize

parent 470aa767
......@@ -74,6 +74,6 @@ class Admin::GroupsController < AdminController
private
def group
@group = Group.find_by_code(params[:id])
@group = Group.find_by_path(params[:id])
end
end
......@@ -50,7 +50,7 @@ class GroupsController < ApplicationController
protected
def group
@group ||= Group.find_by_code(params[:id])
@group ||= Group.find_by_path(params[:id])
end
def projects
......
......@@ -86,7 +86,7 @@ class Project < ActiveRecord::Base
def create_by_user(params, user)
namespace_id = params.delete(:namespace_id)
namespace_id ||= user.namespace_id
namespace_id ||= user.namespace.try(:id)
project = Project.new params
......@@ -222,6 +222,8 @@ class Project < ActiveRecord::Base
end
end
def move_repo
# For compatibility with old code
def code
path
end
end
......@@ -15,8 +15,12 @@
%span.options
= link_to "raw", raw_project_snippet_path(@project, @snippet), class: "btn very_small", target: "_blank"
.file_content.code
%div{class: current_user.dark_scheme ? "black" : ""}
= raw @snippet.colorize(options: { linenos: 'True'})
- unless @snippet.content.empty?
%div{class: current_user.dark_scheme ? "black" : "white"}
= preserve do
= raw Pygments.highlight(@snippet.content, formatter: :gitlab)
- else
%h4.nothing_here_message Empty file
%div
......
......@@ -9,7 +9,7 @@ class AdminGroups < Spinach::FeatureSteps
And 'submit form with new group info' do
fill_in 'group_name', :with => 'gitlab'
fill_in 'group_code', :with => 'gitlab'
fill_in 'group_path', :with => 'gitlab'
click_button "Save group"
end
......
......@@ -4,8 +4,6 @@ class CreateProject < Spinach::FeatureSteps
And 'fill project form with valid data' do
fill_in 'project_name', :with => 'NewProject'
fill_in 'project_code', :with => 'NPR'
fill_in 'project_path', :with => 'newproject'
click_button "Create project"
end
......
......@@ -40,8 +40,7 @@ module Gitlab
post do
params[:code] ||= params[:name]
params[:path] ||= params[:name]
attrs = attributes_for_keys [:code,
:path,
attrs = attributes_for_keys [:path,
:name,
:description,
:default_branch,
......
......@@ -2,9 +2,7 @@ require 'spec_helper'
describe "Admin::Projects" do
before do
@project = create(:project,
name: "LeGiT",
code: "LGT")
@project = create(:project)
login_as :admin
end
......@@ -29,7 +27,7 @@ describe "Admin::Projects" do
end
it "should have project info" do
page.should have_content(@project.code)
page.should have_content(@project.path)
page.should have_content(@project.name)
end
end
......@@ -48,19 +46,16 @@ describe "Admin::Projects" do
describe "Update project" do
before do
fill_in "project_name", with: "Big Bang"
fill_in "project_code", with: "BB1"
click_button "Save Project"
@project.reload
end
it "should show page with new data" do
page.should have_content("BB1")
page.should have_content("Big Bang")
end
it "should change project entry" do
@project.name.should == "Big Bang"
@project.code.should == "BB1"
end
end
end
......@@ -77,8 +72,6 @@ describe "Admin::Projects" do
it "should have labels for new project" do
page.should have_content("Project name is")
page.should have_content("Git Clone")
page.should have_content("URL")
end
end
......@@ -86,8 +79,6 @@ describe "Admin::Projects" do
before do
visit new_admin_project_path
fill_in 'project_name', with: 'NewProject'
fill_in 'project_code', with: 'NPR'
fill_in 'project_path', with: 'gitlabhq_1'
expect { click_button "Create project" }.to change { Project.count }.by(1)
@project = Project.last
end
......
......@@ -28,7 +28,7 @@ describe Gitlab::API do
describe "GET /projects/:id/issues" do
it "should return project issues" do
get api("/projects/#{project.code}/issues", user)
get api("/projects/#{project.path}/issues", user)
response.status.should == 200
json_response.should be_an Array
json_response.first['title'].should == issue.title
......@@ -37,7 +37,7 @@ describe Gitlab::API do
describe "GET /projects/:id/issues/:issue_id" do
it "should return a project issue by id" do
get api("/projects/#{project.code}/issues/#{issue.id}", user)
get api("/projects/#{project.path}/issues/#{issue.id}", user)
response.status.should == 200
json_response['title'].should == issue.title
end
......@@ -45,7 +45,7 @@ describe Gitlab::API do
describe "POST /projects/:id/issues" do
it "should create a new project issue" do
post api("/projects/#{project.code}/issues", user),
post api("/projects/#{project.path}/issues", user),
title: 'new issue', labels: 'label, label2'
response.status.should == 201
json_response['title'].should == 'new issue'
......@@ -56,7 +56,7 @@ describe Gitlab::API do
describe "PUT /projects/:id/issues/:issue_id" do
it "should update a project issue" do
put api("/projects/#{project.code}/issues/#{issue.id}", user),
put api("/projects/#{project.path}/issues/#{issue.id}", user),
title: 'updated title', labels: 'label2', closed: 1
response.status.should == 200
json_response['title'].should == 'updated title'
......@@ -67,7 +67,7 @@ describe Gitlab::API do
describe "DELETE /projects/:id/issues/:issue_id" do
it "should delete a project issue" do
delete api("/projects/#{project.code}/issues/#{issue.id}", user)
delete api("/projects/#{project.path}/issues/#{issue.id}", user)
response.status.should == 405
end
end
......
......@@ -11,14 +11,14 @@ describe Gitlab::API do
describe "GET /projects/:id/merge_requests" do
context "when unauthenticated" do
it "should return authentication error" do
get api("/projects/#{project.code}/merge_requests")
get api("/projects/#{project.path}/merge_requests")
response.status.should == 401
end
end
context "when authenticated" do
it "should return an array of merge_requests" do
get api("/projects/#{project.code}/merge_requests", user)
get api("/projects/#{project.path}/merge_requests", user)
response.status.should == 200
json_response.should be_an Array
json_response.first['title'].should == merge_request.title
......@@ -28,7 +28,7 @@ describe Gitlab::API do
describe "GET /projects/:id/merge_request/:merge_request_id" do
it "should return merge_request" do
get api("/projects/#{project.code}/merge_request/#{merge_request.id}", user)
get api("/projects/#{project.path}/merge_request/#{merge_request.id}", user)
response.status.should == 200
json_response['title'].should == merge_request.title
end
......@@ -36,7 +36,7 @@ describe Gitlab::API do
describe "POST /projects/:id/merge_requests" do
it "should return merge_request" do
post api("/projects/#{project.code}/merge_requests", user),
post api("/projects/#{project.path}/merge_requests", user),
title: 'Test merge_request', source_branch: "stable", target_branch: "master", author: user
response.status.should == 201
json_response['title'].should == 'Test merge_request'
......@@ -45,7 +45,7 @@ describe Gitlab::API do
describe "PUT /projects/:id/merge_request/:merge_request_id" do
it "should return merge_request" do
put api("/projects/#{project.code}/merge_request/#{merge_request.id}", user), title: "New title"
put api("/projects/#{project.path}/merge_request/#{merge_request.id}", user), title: "New title"
response.status.should == 200
json_response['title'].should == 'New title'
end
......@@ -53,7 +53,7 @@ describe Gitlab::API do
describe "POST /projects/:id/merge_request/:merge_request_id/comments" do
it "should return comment" do
post api("/projects/#{project.code}/merge_request/#{merge_request.id}/comments", user), note: "My comment"
post api("/projects/#{project.path}/merge_request/#{merge_request.id}/comments", user), note: "My comment"
response.status.should == 201
json_response['note'].should == 'My comment'
end
......
This diff is collapsed.
......@@ -8,8 +8,6 @@ describe "Projects" do
visit new_project_path
fill_in 'project_name', with: 'Awesome'
find("#project_path").value.should == 'awesome'
find("#project_code").value.should == 'awesome'
end
end
......@@ -53,7 +51,6 @@ describe "Projects" do
visit edit_project_path(@project)
fill_in 'project_name', with: 'Awesome'
fill_in 'project_code', with: 'gitlabhq'
click_button "Save"
@project = @project.reload
end
......
......@@ -28,4 +28,10 @@ module StubbedRepository
end
end
class Namespace
def ensure_dir_exist
true
end
end
Project.send(:include, StubbedRepository)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment