Skip to content
This repository has been archived by the owner on Jul 7, 2020. It is now read-only.

Commit

Permalink
Add RSpec view
Browse files Browse the repository at this point in the history
  • Loading branch information
iain committed Jan 15, 2012
1 parent 3f6dece commit de31b7e
Show file tree
Hide file tree
Showing 21 changed files with 955 additions and 23 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ gem 'sqlite3'

gem 'haml'
gem 'friendly_id'
gem 'simple_form', :git => 'git://github.com/plataformatec/simple_form.git'

group :assets do
gem 'compass', '~> 0.12.alpha.4'
Expand Down
9 changes: 9 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
GIT
remote: git://github.com/plataformatec/simple_form.git
revision: 9038c6b6d3498600464fd3bc6324413a81ede5bf
specs:
simple_form (2.0.0.dev)
actionpack (~> 3.0)
activemodel (~> 3.0)

GEM
remote: https://rubygems.org/
specs:
Expand Down Expand Up @@ -141,5 +149,6 @@ DEPENDENCIES
rspec-rails
sass-rails
shoulda-matchers
simple_form!
sqlite3
uglifier
5 changes: 5 additions & 0 deletions app/assets/javascripts/application.js.coffee
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#= require jquery
#= require jquery_ujs
#= require highcharts
#= require bootstrap-alerts
#= require bootstrap-dropdown
#= require bootstrap-tabs
#= require bootstrap-twipsy
#= require bootstrap-popover
#= require renders_charts
4 changes: 4 additions & 0 deletions app/assets/stylesheets/_layout.sass
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@

table.projects
@extend .zebra-striped

#rspec-frame
width: 100%
height: 800px
7 changes: 7 additions & 0 deletions app/controllers/projects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,11 @@ def show
end
end

def update
@project = Project.find(params[:id])
@project.update_attributes(params[:project])
redirect_to :back
end


end
7 changes: 7 additions & 0 deletions app/controllers/rspec_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class RspecController < ApplicationController

def show
@project = Project.find(params[:project_id])
end

end
11 changes: 8 additions & 3 deletions app/views/layouts/application.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@
.topbar-inner
.container
= link_to "Stots", root_path, :class => "brand"
%ul.nav
- projects.each do |project|
%li{content_for(:project) == project.to_param ? { :class => "active" } : {} }= link_to project.name, project
%ul.nav.secondary-nav{:data => { :dropdown => "dropdown" } }
%li.dropdown
= link_to "Projects", projects_path, :class => "dropdown-toggle"
%ul.dropdown-menu
- projects.each do |project|
%li{content_for(:project) == project.to_param ? { :class => "active" } : {} }= link_to project.name, project
%li.divider
%li= link_to "New project", new_project_path
#main.container
= yield
16 changes: 16 additions & 0 deletions app/views/projects/_header.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
- provide :project, project.to_param

%h1.well
= project.name
%small= project.slug

%ul.tabs
%li{tab == "overview" ? { :class => "active" } : {} }= link_to "Overview", project
%li= link_to "Coverage"
%li= link_to "Commits"
%li= link_to "Errors"
%li= link_to "Builds"
%li= link_to "Stats"
%li= link_to "Tracker"
%li{tab == "rspec" ? { :class => "active" } : {} }= link_to "RSpec", project_rspec_path(project)
%li= link_to "Cucumber"
17 changes: 1 addition & 16 deletions app/views/projects/show.html.haml
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
- provide :project, @project.to_param

%h1.well
= @project.name
%small= @project.slug

%ul.tabs
%li.active= link_to "Overview", "#"
%li= link_to "Coverage"
%li= link_to "Commits"
%li= link_to "Errors"
%li= link_to "Builds"
%li= link_to "Stats"
%li= link_to "Tracker"
%li= link_to "RSpec"
%li= link_to "Cucumber"
= render "header", :project => @project, :tab => "overview"

#foobar{:data => { :chart => project_path(@project, :format => :json) }}
16 changes: 16 additions & 0 deletions app/views/rspec/show.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
= render "projects/header", :project => @project, :tab => "rspec"

- if @project.rspec_url?
%iframe#rspec-frame{:src => @project.rspec_url}
- else

.alert-message.warning.fade.in{:data => { :alert => "alert" } }
= link_to "×", "#", :class => "close"
%p You haven't specified an RSpec URL yet

= simple_form_for @project, :wrapper => :inline do |f|
= f.input :rspec_url, :type => :url
.actions
= f.submit :class => "btn primary"
%button.btn{:type => "reset"} Cancel

172 changes: 172 additions & 0 deletions config/initializers/simple_form.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
# Use this setup block to configure all options available in SimpleForm.
SimpleForm.setup do |config|
# Wrappers are used by the form builder to generate a
# complete input. You can remove any component from the
# wrapper, change the order or even add your own to the
# stack. The options given below are used to wrap the
# whole input.
config.wrappers :class => :input, :hint_class => :field_with_hint, :error_class => :field_with_errors do |b|
## Extensions enabled by default
# Any of these extensions can be disabled for a
# given input by passing: `f.input EXTENSION_NAME => false`.
# You can make any of these extensions optional by
# renaming `b.use` to `b.optional`.

# Determines whether to use HTML5 (:email, :url, ...)
# and required attributes
b.use :html5

# Calculates placeholders automatically from I18n
# You can also pass a string as f.input :placeholder => "Placeholder"
b.use :placeholder

## Optional extensions
# They are disabled unless you pass `f.input EXTENSION_NAME => :lookup`
# to the input. If so, they will retrieve the values from the model
# if any exists. If you want to enable the lookup for any of those
# extensions by default, you can change `b.optional` to `b.use`.

# Calculates maxlength from length validations for string inputs
b.optional :maxlength

# Calculates pattern from format validations for string inputs
b.optional :pattern

# Calculates min and max from length validations for numeric inputs
b.optional :min_max

# Calculates readonly automatically from readonly attributes
b.optional :readonly

## Inputs
b.use :label_input
b.use :hint, :tag => :span, :class => :hint
b.use :error, :tag => :span, :class => :error
end

config.wrappers :inline, :class => 'clearfix', :error_class => :error do |b|
b.use :html5
b.use :maxlength
b.use :min_max
b.use :readonly
b.use :pattern
b.use :placeholder
b.use :label
b.use :tag => 'div', :class => 'input' do |ba|
ba.use :input
ba.use :error, :tag => :span, :class => :'help-inline'
ba.use :hint, :tag => :span, :class => :'help-block'
end
end

config.wrappers :stacked, :class => "clearfix", :error_class => :error do |b|
b.use :html5
b.use :maxlength
b.use :min_max
b.use :readonly
b.use :pattern
b.use :placeholder
b.use :label
b.use :hint, :tag => :span, :class => :'help-block'
b.use :tag => 'div', :class => 'input' do |input|
input.use :input
input.use :error, :tag => :span, :class => :'help-inline'
end
end

config.wrappers :prepend, :class => "clearfix", :error_class => :error do |b|
b.use :placeholder
b.use :label
b.use :hint, :tag => :span, :class => :'help-block'
b.use :tag => 'div', :class => 'input' do |input|
input.use :tag => 'div', :class => 'input-prepend' do |prepend|
prepend.use :input
end
input.use :error, :tag => :span, :class => :'help-inline'
end
end

config.wrappers :append, :class => "clearfix", :error_class => :error do |b|
b.use :placeholder
b.use :label
b.use :hint, :tag => :span, :class => :'help-block'
b.use :tag => 'div', :class => 'input' do |input|
input.use :tag => 'div', :class => 'input-append' do |append|
append.use :input
end
input.use :error, :tag => :span, :class => :'help-inline'
end
end

# Method used to tidy up errors.
# config.error_method = :first

# Default tag used for error notification helper.
# config.error_notification_tag = :p

# CSS class to add for error notification helper.
# config.error_notification_class = :error_notification

# ID to add for error notification helper.
# config.error_notification_id = nil

# Series of attempts to detect a default label method for collection.
# config.collection_label_methods = [ :to_label, :name, :title, :to_s ]

# Series of attempts to detect a default value method for collection.
# config.collection_value_methods = [ :id, :to_s ]

# You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
# config.collection_wrapper_tag = nil

# You can define the class to use on all collection wrappers. Defaulting to none.
# config.collection_wrapper_class = nil

# You can wrap each item in a collection of radio/check boxes with a tag, defaulting to span.
# config.item_wrapper_tag = :span

# How the label text should be generated altogether with the required text.
# config.label_text = lambda { |label, required| "#{required} #{label}" }

# You can define the class to use on all labels. Default is nil.
# config.label_class = nil

# You can define the class to use on all forms. Default is simple_form.
# config.form_class = :simple_form

# Whether attributes are required by default (or not). Default is true.
# config.required_by_default = true

# Tell browsers whether to use default HTML5 validations (novalidate option).
# Default is enabled.
config.browser_validations = true

# Collection of methods to detect if a file type was given.
# config.file_methods = [ :mounted_as, :file?, :public_filename ]

# Custom mappings for input types. This should be a hash containing a regexp
# to match as key, and the input type that will be used when the field name
# matches the regexp as value.
# config.input_mappings = { /count/ => :integer }

# Default priority for time_zone inputs.
# config.time_zone_priority = nil

# Default priority for country inputs.
# config.country_priority = nil

# Default size for text inputs.
# config.default_input_size = 50

# When false, do not use translations for labels.
# config.translate_labels = true

# Automatically discover new inputs in Rails' autoload path.
# config.inputs_discovery = true

# Cache simple form inputs discovery
# config.cache_discovery = !Rails.env.development?

# Default class for buttons
config.button_class = 'btn'
end
24 changes: 24 additions & 0 deletions config/locales/simple_form.en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
en:
simple_form:
"yes": 'Yes'
"no": 'No'
required:
text: 'required'
mark: '*'
# You can uncomment the line below if you need to overwrite the whole required html.
# When using html, text and mark won't be used.
# html: '<abbr title="required">*</abbr>'
error_notification:
default_message: "Some errors were found, please take a look:"
# Labels and hints examples
# labels:
# password: 'Password'
# user:
# new:
# email: 'E-mail para efetuar o sign in.'
# edit:
# email: 'E-mail.'
# hints:
# username: 'User name to sign in.'
# password: 'No special characters, please.'

9 changes: 8 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
Stots::Application.routes.draw do

root :to => "projects#index"
resources :projects

resources :projects do

get "rspec" => "rspec#show"

end

end
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class AddRspecAndCucumberPathsToProjects < ActiveRecord::Migration
def change
add_column :projects, :rspec_url, :string

add_column :projects, :cucumber_url, :string

end
end
8 changes: 5 additions & 3 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20120115162215) do
ActiveRecord::Schema.define(:version => 20120115181329) do

create_table "projects", :force => true do |t|
t.string "project"
t.string "name"
t.string "slug"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "rspec_url"
t.string "cucumber_url"
end

add_index "projects", ["slug"], :name => "index_projects_on_slug"
Expand Down
Loading

0 comments on commit de31b7e

Please sign in to comment.