Permalink
Browse files

rspec, devise

  • Loading branch information...
1 parent 3ff4d6d commit 0773854f387f6d85f3ae382d228ee51c4df5e566 @randx randx committed Nov 1, 2012
View
1 .rspec
@@ -0,0 +1 @@
+--color
View
19 Gemfile
@@ -8,13 +8,27 @@ gem 'mysql2'
# Settings
gem 'settingslogic'
-gem 'rake'
+# Auth
+gem 'devise'
+
+# Web server
gem 'thin'
+
+# Haml
gem 'haml-rails'
+
+# Jobs
gem 'resque'
-gem 'foreman'
+
+# Format dates
gem 'stamp'
+
+# Pagination
gem 'will_paginate', '~> 3.0'
+
+# Other
+gem 'rake'
+gem 'foreman'
gem 'jquery-rails'
group :assets do
@@ -28,4 +42,5 @@ end
group :development do
gem 'pry'
+ gem 'rspec-rails'
end
View
@@ -29,6 +29,7 @@ GEM
i18n (~> 0.6)
multi_json (~> 1.0)
arel (3.0.2)
+ bcrypt-ruby (3.0.1)
bootstrap-sass (2.0.4.0)
builder (3.0.4)
coderay (1.0.8)
@@ -40,6 +41,12 @@ GEM
execjs
coffee-script-source (1.4.0)
daemons (1.1.9)
+ devise (2.1.2)
+ bcrypt-ruby (~> 3.0)
+ orm_adapter (~> 0.1)
+ railties (~> 3.1)
+ warden (~> 1.2.1)
+ diff-lcs (1.1.3)
erubis (2.7.0)
eventmachine (1.0.0)
execjs (1.4.0)
@@ -68,6 +75,7 @@ GEM
mime-types (1.19)
multi_json (1.3.6)
mysql2 (0.3.11)
+ orm_adapter (0.4.0)
polyglot (0.3.3)
pry (0.9.10)
coderay (~> 1.0.5)
@@ -108,6 +116,19 @@ GEM
redis-namespace (~> 1.0)
sinatra (>= 0.9.2)
vegas (~> 0.1.2)
+ rspec (2.11.0)
+ rspec-core (~> 2.11.0)
+ rspec-expectations (~> 2.11.0)
+ rspec-mocks (~> 2.11.0)
+ rspec-core (2.11.1)
+ rspec-expectations (2.11.3)
+ diff-lcs (~> 1.1.3)
+ rspec-mocks (2.11.3)
+ rspec-rails (2.11.0)
+ actionpack (>= 3.0)
+ activesupport (>= 3.0)
+ railties (>= 3.0)
+ rspec (~> 2.11.0)
sass (3.2.1)
sass-rails (3.2.5)
railties (~> 3.2.0)
@@ -141,6 +162,8 @@ GEM
multi_json (~> 1.0, >= 1.0.2)
vegas (0.1.11)
rack (>= 1.0.0)
+ warden (1.2.1)
+ rack (>= 1.0)
will_paginate (3.0.3)
PLATFORMS
@@ -149,6 +172,7 @@ PLATFORMS
DEPENDENCIES
bootstrap-sass (= 2.0.4)
coffee-rails (~> 3.2.1)
+ devise
foreman
haml-rails
jquery-rails
@@ -157,6 +181,7 @@ DEPENDENCIES
rails (= 3.2.8)
rake
resque
+ rspec-rails
sass-rails (~> 3.2.3)
settingslogic
stamp
View
@@ -0,0 +1,2 @@
+web: bundle exec rails s -p $PORT
+worker: bundle exec rake environment resque:work QUEUE=* VVERBOSE=1
@@ -0,0 +1,46 @@
+class ProjectsController < ApplicationController
+ before_filter :authenticate_user!, except :index
+
+ def index
+ @projects = Project.all
+ end
+
+ def show
+ @project = Project.find(params[:id])
+ end
+
+ def new
+ @project = Project.new
+ end
+
+ def edit
+ @project = Project.find(params[:id])
+ end
+
+ def create
+ @project = Project.new(params[:project])
+
+ if @project.save
+ redirect_to @project, notice: 'Project was successfully created.'
+ else
+ render action: "new"
+ end
+ end
+
+ def update
+ @project = Project.find(params[:id])
+
+ if @project.update_attributes(params[:project])
+ redirect_to @project, notice: 'Project was successfully updated.'
+ else
+ render action: "edit"
+ end
+ end
+
+ def destroy
+ @project = Project.find(params[:id])
+ @project.destroy
+
+ redirect_to projects_url
+ end
+end
@@ -0,0 +1,2 @@
+module ProjectsHelper
+end
View
@@ -0,0 +1,41 @@
+class Build < ActiveRecord::Base
+ belongs_to :project
+
+ def failed?
+ status == 'fail'
+ end
+
+ def success?
+ status == 'success'
+ end
+
+ def running?
+ status == 'running'
+ end
+
+ def success!
+ update_status 'success'
+ end
+
+ def fail!
+ update_status 'fail'
+ end
+
+ def running!
+ update_status 'running'
+ end
+
+ def update_status status
+ update_attributes(status: status)
+ end
+
+ def write_trace(trace)
+ self.reload
+ update_attributes(trace: ansi_color_codes(trace))
+ end
+
+ def ansi_color_codes(string)
+ string.gsub("\e[0m", '</span>').
+ gsub(/\e\[(\d+)m/, "<span class=\"color\\1\">")
+ end
+end
View
@@ -0,0 +1,35 @@
+require_relative 'build'
+
+class Project < ActiveRecord::Base
+ attr_accessible :name, :path, :scripts
+
+ validates_presence_of :name, :path, :scripts
+
+ has_many :builds
+
+ def register_build opts={}
+ default_opts = {
+ project_id: self.id,
+ status: 'running'
+ }
+
+ allowed_opts = {}
+ allowed_opts[:commit_ref] = opts[:after]
+
+ @build = Build.create(default_opts.merge!(allowed_opts))
+ end
+
+ def status
+ if last_build
+ last_build.status
+ end
+ end
+
+ def last_build
+ builds.last
+ end
+
+ def human_status
+ status
+ end
+end
View
@@ -0,0 +1,11 @@
+class User < ActiveRecord::Base
+ # Include default devise modules. Others available are:
+ # :token_authenticatable, :confirmable,
+ # :lockable, :timeoutable and :omniauthable
+ devise :database_authenticatable, :registerable,
+ :recoverable, :rememberable, :trackable, :validatable
+
+ # Setup accessible (or protected) attributes for your model
+ attr_accessible :email, :password, :password_confirmation, :remember_me
+ # attr_accessible :title, :body
+end
@@ -0,0 +1,19 @@
+= form_for @project do |f|
+ - if @project.errors.any?
+ #error_explanation
+ %h2= "#{pluralize(@project.errors.count, "error")} prohibited this project from being saved:"
+ %ul
+ - @project.errors.full_messages.each do |msg|
+ %li= msg
+
+ .field
+ = f.label :name
+ = f.text_field :name
+ .field
+ = f.label :path
+ = f.text_field :path
+ .field
+ = f.label :scripts
+ = f.text_area :scripts
+ .actions
+ = f.submit 'Save'
@@ -0,0 +1,7 @@
+%h1 Editing project
+
+= render 'form'
+
+= link_to 'Show', @project
+\|
+= link_to 'Back', projects_path
@@ -0,0 +1,23 @@
+%h1 Listing projects
+
+%table
+ %tr
+ %th Name
+ %th Path
+ %th Scripts
+ %th
+ %th
+ %th
+
+ - @projects.each do |project|
+ %tr
+ %td= project.name
+ %td= project.path
+ %td= project.scripts
+ %td= link_to 'Show', project
+ %td= link_to 'Edit', edit_project_path(project)
+ %td= link_to 'Destroy', project, method: :delete, data: { confirm: 'Are you sure?' }
+
+%br
+
+= link_to 'New Project', new_project_path
@@ -0,0 +1,5 @@
+%h1 New project
+
+= render 'form'
+
+= link_to 'Back', projects_path
@@ -0,0 +1,15 @@
+%p#notice= notice
+
+%p
+ %b Name:
+ = @project.name
+%p
+ %b Path:
+ = @project.path
+%p
+ %b Scripts:
+ = @project.scripts
+
+= link_to 'Edit', edit_project_path(@project)
+\|
+= link_to 'Back', projects_path
View
@@ -4,9 +4,9 @@
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
- Bundler.require(*Rails.groups(:assets => %w(development test)))
+ # Bundler.require(*Rails.groups(:assets => %w(development test)))
# If you want your assets lazily compiled in production, use this line
- # Bundler.require(:default, :assets, Rails.env)
+ Bundler.require(:default, :assets, Rails.env)
end
module GitlabCi
@@ -5,7 +5,7 @@ production:
adapter: mysql2
encoding: utf8
reconnect: false
- database: gitlabhq_production
+ database: gitlab_ci_production
pool: 5
username: root
password: "secure password"
@@ -19,7 +19,7 @@ development:
adapter: mysql2
encoding: utf8
reconnect: false
- database: gitlabhq_development
+ database: gitlab_ci_development
pool: 5
username: root
password: "secure password"
@@ -32,7 +32,7 @@ test: &test
adapter: mysql2
encoding: utf8
reconnect: false
- database: gitlabhq_test
+ database: gitlab_ci_test
pool: 5
username: root
password: "secure password"
@@ -15,7 +15,7 @@
config.assets.compress = true
# Don't fallback to assets pipeline if a precompiled asset is missed
- config.assets.compile = false
+ config.assets.compile = true
# Generate digests for assets URLs
config.assets.digest = true
Oops, something went wrong.

0 comments on commit 0773854

Please sign in to comment.