Permalink
Browse files

Committing everything for CS demo: Devise, scaffold, Rspec, etc

  • Loading branch information...
Rian Rainey
Rian Rainey committed Nov 26, 2012
1 parent 5a4ccb9 commit 262e2524c65ad89be1035d62327881fdae33f8ad
Showing with 2,537 additions and 13 deletions.
  1. +5 −4 Gemfile
  2. +33 −0 Gemfile.lock
  3. +46 −0 Guardfile
  4. BIN app/assets/images/Header_CommunityandIntro.jpeg
  5. +3 −0 app/assets/javascripts/application.js
  6. +3 −0 app/assets/javascripts/roles.js.coffee
  7. +11 −0 app/assets/javascripts/script.js
  8. +3 −0 app/assets/javascripts/users.js.coffee
  9. +3 −0 app/assets/javascripts/workouts.js.coffee
  10. +2 −0 app/assets/stylesheets/application.css
  11. +34 −1 app/assets/stylesheets/custom.css.scss
  12. +3 −0 app/assets/stylesheets/roles.css.scss
  13. +3 −0 app/assets/stylesheets/users.css.scss
  14. +3 −0 app/assets/stylesheets/workouts.css.scss
  15. +86 −0 app/controllers/admin/roles_controller.rb
  16. +106 −0 app/controllers/admin/users_controller.rb
  17. +86 −0 app/controllers/admin/workouts_controller.rb
  18. +2 −0 app/controllers/static_pages_controller.rb
  19. +14 −0 app/controllers/users_controller.rb
  20. +10 −0 app/controllers/workouts_controller.rb
  21. +2 −0 app/helpers/roles_helper.rb
  22. +2 −0 app/helpers/users_helper.rb
  23. +2 −0 app/helpers/workouts_helper.rb
  24. +4 −0 app/models/role.rb
  25. +31 −0 app/models/user.rb
  26. +3 −0 app/models/workout.rb
  27. +21 −0 app/views/admin/roles/_form.html.erb
  28. +6 −0 app/views/admin/roles/edit.html.erb
  29. +30 −0 app/views/admin/roles/index.html.erb
  30. +5 −0 app/views/admin/roles/new.html.erb
  31. +5 −0 app/views/admin/roles/show.html.erb
  32. +39 −0 app/views/admin/users/_form.html.erb
  33. +6 −0 app/views/admin/users/edit.html.erb
  34. +39 −0 app/views/admin/users/index.html.erb
  35. +5 −0 app/views/admin/users/new.html.erb
  36. +19 −0 app/views/admin/users/show.html.erb
  37. +29 −0 app/views/admin/workouts/_form.html.erb
  38. +6 −0 app/views/admin/workouts/edit.html.erb
  39. +31 −0 app/views/admin/workouts/index.html.erb
  40. +5 −0 app/views/admin/workouts/new.html.erb
  41. +14 −0 app/views/admin/workouts/show.html.erb
  42. +12 −0 app/views/devise/confirmations/new.html.erb
  43. +5 −0 app/views/devise/mailer/confirmation_instructions.html.erb
  44. +8 −0 app/views/devise/mailer/reset_password_instructions.html.erb
  45. +7 −0 app/views/devise/mailer/unlock_instructions.html.erb
  46. +16 −0 app/views/devise/passwords/edit.html.erb
  47. +12 −0 app/views/devise/passwords/new.html.erb
  48. +25 −0 app/views/devise/registrations/edit.html.erb
  49. +18 −0 app/views/devise/registrations/new.html.erb
  50. +17 −0 app/views/devise/sessions/new.html.erb
  51. +25 −0 app/views/devise/shared/_links.erb
  52. +12 −0 app/views/devise/unlocks/new.html.erb
  53. +6 −0 app/views/layouts/_admin_sidebar.erb
  54. +39 −3 app/views/layouts/_header.html.erb
  55. +28 −0 app/views/layouts/admin.html.erb
  56. +6 −2 app/views/layouts/application.html.erb
  57. +2 −3 app/views/static_pages/home.html.erb
  58. +19 −0 app/views/users/show.html.erb
  59. +31 −0 app/views/workouts/index.html.erb
  60. +3 −0 config/application.rb
  61. +3 −0 config/environments/development.rb
  62. +3 −0 config/environments/production.rb
  63. +232 −0 config/initializers/devise.rb
  64. +58 −0 config/locales/devise.en.yml
  65. +20 −0 config/routes.rb
  66. +11 −0 db/migrate/20121112011304_create_users.rb
  67. +10 −0 db/migrate/20121112012923_create_workouts.rb
  68. +5 −0 db/migrate/20121117060434_add_role_to_users.rb
  69. +8 −0 db/migrate/20121117061340_create_roles.rb
  70. +5 −0 db/migrate/20121117061919_add_name_to_roles.rb
  71. +5 −0 db/migrate/20121117151944_add_role_id_to_users.rb
  72. +12 −0 db/migrate/20121118145658_add_roles_users_table.rb
  73. +9 −0 db/migrate/20121120030738_remove_role_from_users.rb
  74. +9 −0 db/migrate/20121120030853_remove_role_id_from_users.rb
  75. +53 −0 db/migrate/20121123025145_add_devise_to_users.rb
  76. +54 −0 db/schema.rb
  77. +7 −0 logfile
  78. +164 −0 spec/controllers/roles_controller_spec.rb
  79. +164 −0 spec/controllers/users_controller_spec.rb
  80. +164 −0 spec/controllers/workouts_controller_spec.rb
  81. +15 −0 spec/helpers/roles_helper_spec.rb
  82. +15 −0 spec/helpers/users_helper_spec.rb
  83. +15 −0 spec/helpers/workouts_helper_spec.rb
  84. +5 −0 spec/models/role_spec.rb
  85. +17 −0 spec/models/user_spec.rb
  86. +5 −0 spec/models/workout_spec.rb
  87. +11 −0 spec/requests/roles_spec.rb
  88. +11 −0 spec/requests/users_spec.rb
  89. +11 −0 spec/requests/workouts_spec.rb
  90. +53 −0 spec/routing/roles_routing_spec.rb
  91. +53 −0 spec/routing/users_routing_spec.rb
  92. +53 −0 spec/routing/workouts_routing_spec.rb
  93. +15 −0 spec/views/roles/edit.html.erb_spec.rb
  94. +15 −0 spec/views/roles/index.html.erb_spec.rb
  95. +15 −0 spec/views/roles/new.html.erb_spec.rb
  96. +12 −0 spec/views/roles/show.html.erb_spec.rb
  97. +22 −0 spec/views/users/edit.html.erb_spec.rb
  98. +26 −0 spec/views/users/index.html.erb_spec.rb
  99. +22 −0 spec/views/users/new.html.erb_spec.rb
  100. +19 −0 spec/views/users/show.html.erb_spec.rb
  101. +20 −0 spec/views/workouts/edit.html.erb_spec.rb
  102. +23 −0 spec/views/workouts/index.html.erb_spec.rb
  103. +20 −0 spec/views/workouts/new.html.erb_spec.rb
  104. +17 −0 spec/views/workouts/show.html.erb_spec.rb
View
@@ -3,15 +3,16 @@ source 'https://rubygems.org'
gem 'rails', '3.2.8'
gem 'bootstrap-sass', '2.0.4'
+gem 'pg'
-# Bundle edge Rails instead:
-# gem 'rails', :git => 'git://github.com/rails/rails.git'
+gem 'bootstrap-wysihtml5-rails'
-#gem 'sqlite3'
-gem 'pg'
+gem 'devise'
group :development do
gem 'rspec-rails'
+ gem 'annotate'
+ gem 'guard-rspec'
end
group :test do
View
@@ -29,8 +29,13 @@ GEM
i18n (~> 0.6)
multi_json (~> 1.0)
addressable (2.3.2)
+ annotate (2.5.0)
+ rake
arel (3.0.2)
+ bcrypt-ruby (3.0.1)
bootstrap-sass (2.0.4.0)
+ bootstrap-wysihtml5-rails (0.3.1.10)
+ railties (>= 3.0)
builder (3.0.4)
capybara (1.1.2)
mime-types (>= 1.16)
@@ -41,18 +46,31 @@ GEM
xpath (~> 0.1.4)
childprocess (0.3.6)
ffi (~> 1.0, >= 1.0.6)
+ coderay (1.0.8)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
railties (~> 3.2.0)
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.4.0)
+ 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)
execjs (1.4.0)
multi_json (~> 1.0)
ffi (1.1.5)
+ guard (1.5.1)
+ listen (>= 0.4.2)
+ lumberjack (>= 1.0.2)
+ pry (>= 0.9.10)
+ thor (>= 0.14.6)
+ guard-rspec (1.2.1)
+ guard (>= 1.1)
hike (1.2.1)
i18n (0.6.1)
journey (1.0.4)
@@ -62,15 +80,23 @@ GEM
json (1.7.5)
libwebsocket (0.1.5)
addressable
+ listen (0.5.3)
+ lumberjack (1.0.2)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
+ method_source (0.8.1)
mime-types (1.19)
multi_json (1.3.6)
nokogiri (1.5.5)
+ orm_adapter (0.4.0)
pg (0.14.1)
polyglot (0.3.3)
+ pry (0.9.10)
+ coderay (~> 1.0.5)
+ method_source (~> 0.8)
+ slop (~> 3.3.1)
rack (1.4.1)
rack-cache (1.2)
rack (>= 0.4)
@@ -120,6 +146,7 @@ GEM
libwebsocket (~> 0.1.3)
multi_json (~> 1.0)
rubyzip
+ slop (3.3.3)
sprockets (2.1.3)
hike (~> 1.2)
rack (~> 1.0)
@@ -133,16 +160,22 @@ GEM
uglifier (1.3.0)
execjs (>= 0.3.0)
multi_json (~> 1.0, >= 1.0.2)
+ warden (1.2.1)
+ rack (>= 1.0)
xpath (0.1.4)
nokogiri (~> 1.3)
PLATFORMS
ruby
DEPENDENCIES
+ annotate
bootstrap-sass (= 2.0.4)
+ bootstrap-wysihtml5-rails
capybara
coffee-rails (~> 3.2.1)
+ devise
+ guard-rspec
jquery-rails
pg
rails (= 3.2.8)
View
@@ -0,0 +1,46 @@
+# A sample Guardfile
+# More info at https://github.com/guard/guard#readme
+
+guard 'rspec', :version => 2 do
+ watch(%r{^spec/.+_spec\.rb$})
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
+ watch('spec/spec_helper.rb') { "spec" }
+
+ # Rails example
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
+ watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
+ watch('config/routes.rb') { "spec/routing" }
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
+
+ # Capybara request specs
+ watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
+
+ # Turnip features and steps
+ watch(%r{^spec/acceptance/(.+)\.feature$})
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
+end
+
+
+guard 'rspec', :version => 2 do
+ watch(%r{^spec/.+_spec\.rb$})
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
+ watch('spec/spec_helper.rb') { "spec" }
+
+ # Rails example
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
+ watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
+ watch('config/routes.rb') { "spec/routing" }
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
+
+ # Capybara request specs
+ watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
+
+ # Turnip features and steps
+ watch(%r{^spec/acceptance/(.+)\.feature$})
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
+end
+
Binary file not shown.
@@ -12,4 +12,7 @@
//
//= require jquery
//= require jquery_ujs
+//= require bootstrap
+//= require bootstrap-wysihtml5
//= require_tree .
+
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
@@ -0,0 +1,11 @@
+$(document).ready(function(){
+
+ wysihtmlfive();
+});
+
+// Apply wysihtml5 to appropriate text areas
+function wysihtmlfive() {
+ $('.wysihtml5').each(function(i, elem) {
+ $(elem).wysihtml5();
+ });
+}
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
@@ -9,5 +9,7 @@
* compiled file, but it's generally better to create a new file per style scope.
*
*= require_self
+ *= require bootstrap-wysihtml5
*= require_tree .
*/
+
@@ -1,8 +1,12 @@
// This one line includes the entire Bootstrap CSS Framework. @requires bootstrap-sass gem
@import "bootstrap";
+@import "bootstrap-responsive";
// Variables
$lightgray: #999;
+$primary-color: #51a351;
+$primary-color-secondary: #51a351;
+$btn-primary-color: $primary-color;
@mixin box_sizing {
-moz-box-sizing: border-box;
@@ -58,6 +62,10 @@ p {
line-height: 1.7em;
}
+a {
+ color: $btn-primary-color;
+}
+
/* header */
#logo {
float: left;
@@ -84,7 +92,7 @@ footer {
a {
color: #555;
&:hover {
- color: #F00;
+ color: $btn-primary-color;
}
}
small {
@@ -160,7 +168,32 @@ input, textarea, select, .uneditable-input {
@extend .error;
}
+.alert-notice {
+ background-color: #dff0d8;
+ border-color: #d6e9c6;
+ color: #468847;
+}
+
+/* Buttons */
+.btn-primary {
+ background-color: #5bb65b;
+ background-image: -moz-linear-gradient(top, #62c462, $btn-primary-color);
+ background-image: -ms-linear-gradient(top, #62c462, $btn-primary-color);
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#62c462), to($btn-primary-color));
+ background-image: -webkit-linear-gradient(top, #62c462, $btn-primary-color);
+ background-image: -o-linear-gradient(top, #62c462, $btn-primary-color);
+ background-image: linear-gradient(top, #62c462, $btn-primary-color);
+ background-repeat: repeat-x;
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FF62C462', endColorstr='#FF51A351', GradientType=0);
+ border-color: $btn-primary-color $btn-primary-color #387038;
+ border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) fadein(rgba(0, 0, 0, 0.1), 15%);
+ *background-color: $btn-primary-color;
+ filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
+}
+.btn-primary:hover, .btn-primary:active, .btn-primary.active, .btn-primary.disabled, .btn-primary[disabled] {
+ background-color: $btn-primary-color;
+}
@@ -0,0 +1,3 @@
+// Place all the styles related to the Roles controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
@@ -0,0 +1,3 @@
+// Place all the styles related to the Users controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
@@ -0,0 +1,3 @@
+// Place all the styles related to the Workouts controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
@@ -0,0 +1,86 @@
+class Admin::RolesController < ApplicationController
+ # GET /roles
+ # GET /roles.json
+
+ layout 'admin'
+
+ def index
+ @roles = Role.all
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.json { render json: @roles }
+ end
+ end
+
+ # GET /roles/1
+ # GET /roles/1.json
+ def show
+ @role = Role.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.json { render json: @role }
+ end
+ end
+
+ # GET /roles/new
+ # GET /roles/new.json
+ def new
+ @role = Role.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.json { render json: @role }
+ end
+ end
+
+ # GET /roles/1/edit
+ def edit
+ @role = Role.find(params[:id])
+ end
+
+ # POST /roles
+ # POST /roles.json
+ def create
+ @role = Role.new(params[:role])
+
+ respond_to do |format|
+ if @role.save
+ format.html { redirect_to admin_role_path(@role), notice: 'Role was successfully created.' }
+ format.json { render json: @role, status: :created, location: @role }
+ else
+ format.html { render action: "new" }
+ format.json { render json: @role.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /roles/1
+ # PUT /roles/1.json
+ def update
+ @role = Role.find(params[:id])
+
+ respond_to do |format|
+ if @role.update_attributes(params[:role])
+ format.html { redirect_to admin_roles_url, notice: 'Role was successfully updated.' }
+ format.json { head :no_content }
+ else
+ format.html { render action: "edit" }
+ format.json { render json: @role.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /roles/1
+ # DELETE /roles/1.json
+ def destroy
+ @role = Role.find(params[:id])
+ @role.destroy
+
+ respond_to do |format|
+ format.html { redirect_to admin_roles_url }
+ format.json { head :no_content }
+ end
+ end
+end
Oops, something went wrong.

0 comments on commit 262e252

Please sign in to comment.