Permalink
Browse files

first fixtures

  • Loading branch information...
fguillen committed Dec 12, 2008
1 parent f270a94 commit f0d2a1517ddf41d5c0c234fb3a16f090a8ea9f6d
Showing with 8,684 additions and 223 deletions.
  1. +1 −0 .gitignore
  2. +3 −0 .gitmodules
  3. +3 −0 app/controllers/application.rb
  4. +42 −0 app/controllers/sessions_controller.rb
  5. +25 −71 app/controllers/users_controller.rb
  6. +2 −0 app/helpers/sessions_helper.rb
  7. +91 −0 app/helpers/users_helper.rb
  8. +5 −0 app/models/attend.rb
  9. +7 −0 app/models/comment.rb
  10. +3 −0 app/models/event.rb
  11. +17 −0 app/models/paper.rb
  12. +3 −0 app/models/paper_type.rb
  13. +6 −0 app/models/payment.rb
  14. +3 −0 app/models/role.rb
  15. +2 −0 app/models/room.rb
  16. +5 −0 app/models/speaker.rb
  17. +76 −0 app/models/user.rb
  18. +24 −0 app/models/user_mailer.rb
  19. +11 −0 app/models/user_observer.rb
  20. +4 −0 app/models/vote.rb
  21. +16 −0 app/views/sessions/new.html.erb
  22. +3 −0 app/views/user_mailer/activation.erb
  23. +8 −0 app/views/user_mailer/signup_notification.erb
  24. +8 −0 app/views/users/_user_bar.html.erb
  25. +1 −0 app/views/users/index.html.erb
  26. +16 −8 app/views/users/new.html.erb
  27. +4 −0 config/environment.rb
  28. +1 −0 config/initializers/i18n.rb
  29. +55 −0 config/locales/de-DE.yml
  30. +56 −0 config/locales/en-US.yml
  31. +9 −52 config/routes.rb
  32. BIN db/development.sqlite3
  33. +12 −3 db/migrate/20081207124433_create_users.rb
  34. +2 −1 db/migrate/20081207124519_create_payments.rb
  35. +3 −1 db/migrate/20081207124529_create_events.rb
  36. +2 −1 db/migrate/20081207124534_create_roles.rb
  37. +2 −1 db/migrate/20081207124540_create_configurations.rb
  38. +7 −1 db/migrate/20081207124613_create_papers.rb
  39. +2 −1 db/migrate/20081207125053_create_speakers.rb
  40. +2 −1 db/migrate/20081207125103_create_rooms.rb
  41. +3 −1 db/migrate/20081207125110_create_comments.rb
  42. +2 −1 db/migrate/20081207125238_create_paper_types.rb
  43. +3 −1 db/migrate/20081207125657_create_votes.rb
  44. +2 −1 db/migrate/20081207125808_create_attends.rb
  45. +13 −0 db/migrate/20081212174835_paper_status.rb
  46. +116 −1 db/schema.rb
  47. BIN db/test.sqlite3
  48. +189 −0 lib/authenticated_system.rb
  49. +20 −0 lib/authenticated_test_helper.rb
  50. +90 −0 spec/controllers/access_control_spec.rb
  51. +102 −0 spec/controllers/authenticated_system_spec.rb
  52. +139 −0 spec/controllers/sessions_controller_spec.rb
  53. +191 −0 spec/controllers/users_controller_spec.rb
  54. +38 −0 spec/fixtures/users.yml
  55. +141 −0 spec/helpers/users_helper_spec.rb
  56. +7 −0 spec/models/i18n_spec.rb
  57. +233 −0 spec/models/user_spec.rb
  58. +22 −0 stories/rest_auth_stories.rb
  59. +81 −0 stories/rest_auth_stories_helper.rb
  60. +49 −0 stories/steps/ra_navigation_steps.rb
  61. +179 −0 stories/steps/ra_resource_steps.rb
  62. +171 −0 stories/steps/ra_response_steps.rb
  63. +153 −0 stories/steps/user_steps.rb
  64. +182 −0 stories/users/accounts.story
  65. +134 −0 stories/users/sessions.story
  66. +9 −6 test/fixtures/attends.yml
  67. +8 −6 test/fixtures/comments.yml
  68. +7 −6 test/fixtures/configurations.yml
  69. +8 −6 test/fixtures/events.yml
  70. +10 −0 test/fixtures/paper_status.yml
  71. +9 −6 test/fixtures/paper_types.yml
  72. +15 −6 test/fixtures/papers.yml
  73. +5 −6 test/fixtures/payments.yml
  74. +9 −6 test/fixtures/roles.yml
  75. +5 −6 test/fixtures/rooms.yml
  76. +5 −6 test/fixtures/speakers.yml
  77. +20 −6 test/fixtures/users.yml
  78. +12 −6 test/fixtures/votes.yml
  79. +5 −4 test/unit/attend_test.rb
  80. +2 −1 test/unit/vote_test.rb
  81. +215 −0 vendor/plugins/rathole/README
  82. +22 −0 vendor/plugins/rathole/Rakefile
  83. +12 −0 vendor/plugins/rathole/init.rb
  84. +13 −0 vendor/plugins/rathole/lib/rathole.rb
  85. +24 −0 vendor/plugins/rathole/lib/rathole/extensions/active_record/connection_adapters/mysql_adapter.rb
  86. +24 −0 vendor/plugins/rathole/lib/rathole/extensions/active_record/connection_adapters/sqlite_adapter.rb
  87. +138 −0 vendor/plugins/rathole/lib/rathole/extensions/fixtures.rb
  88. +3 −0 vendor/plugins/rathole/test/fixtures/models/fruit.rb
  89. +4 −0 vendor/plugins/rathole/test/fixtures/models/monkey.rb
  90. +4 −0 vendor/plugins/rathole/test/fixtures/models/pirate.rb
  91. +30 −0 vendor/plugins/rathole/test/fixtures/schema.rb
  92. +8 −0 vendor/plugins/rathole/test/fixtures/yaml/fruits.yml
  93. +16 −0 vendor/plugins/rathole/test/fixtures/yaml/monkeys.yml
  94. +7 −0 vendor/plugins/rathole/test/fixtures/yaml/monkeys_pirates.yml
  95. +9 −0 vendor/plugins/rathole/test/fixtures/yaml/pirates.yml
  96. +46 −0 vendor/plugins/rathole/test/helper.rb
  97. +70 −0 vendor/plugins/rathole/test/rathole/extensions/fixtures_test.rb
  98. +12 −0 vendor/plugins/rathole/test/rathole_test.rb
  99. +1 −0 vendor/plugins/resful_authentication
  100. +21 −0 vendor/plugins/restful-authentication/.gitignore
  101. +68 −0 vendor/plugins/restful-authentication/CHANGELOG
  102. +224 −0 vendor/plugins/restful-authentication/README.textile
  103. +32 −0 vendor/plugins/restful-authentication/Rakefile
  104. +15 −0 vendor/plugins/restful-authentication/TODO
  105. +1 −0 vendor/plugins/restful-authentication/generators/authenticated/USAGE
  106. +478 −0 vendor/plugins/restful-authentication/generators/authenticated/authenticated_generator.rb
  107. +54 −0 vendor/plugins/restful-authentication/generators/authenticated/lib/insert_routes.rb
  108. +8 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/_model_partial.html.erb
  109. +3 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/activation.erb
  110. +189 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/authenticated_system.rb
  111. +22 −0 ...or/plugins/restful-authentication/generators/authenticated/templates/authenticated_test_helper.rb
  112. +43 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/controller.rb
  113. +2 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/helper.rb
  114. +16 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/login.html.erb
  115. +25 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/mailer.rb
  116. +26 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/migration.rb
  117. +83 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/model.rb
  118. +85 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/model_controller.rb
  119. +93 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/model_helper.rb
  120. +158 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/model_helper_spec.rb
  121. +11 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/observer.rb
  122. +19 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/signup.html.erb
  123. +8 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/signup_notification.erb
  124. +38 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/site_keys.rb
  125. +90 −0 ...restful-authentication/generators/authenticated/templates/spec/controllers/access_control_spec.rb
  126. +102 −0 ...l-authentication/generators/authenticated/templates/spec/controllers/authenticated_system_spec.rb
  127. +139 −0 ...ul-authentication/generators/authenticated/templates/spec/controllers/sessions_controller_spec.rb
  128. +198 −0 ...stful-authentication/generators/authenticated/templates/spec/controllers/users_controller_spec.rb
  129. +60 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/spec/fixtures/users.yml
  130. +141 −0 ...ugins/restful-authentication/generators/authenticated/templates/spec/helpers/users_helper_spec.rb
  131. +290 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/spec/models/user_spec.rb
  132. +22 −0 ...or/plugins/restful-authentication/generators/authenticated/templates/stories/rest_auth_stories.rb
  133. +81 −0 ...ins/restful-authentication/generators/authenticated/templates/stories/rest_auth_stories_helper.rb
  134. +49 −0 ...ns/restful-authentication/generators/authenticated/templates/stories/steps/ra_navigation_steps.rb
  135. +179 −0 ...gins/restful-authentication/generators/authenticated/templates/stories/steps/ra_resource_steps.rb
  136. +171 −0 ...gins/restful-authentication/generators/authenticated/templates/stories/steps/ra_response_steps.rb
  137. +153 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/stories/steps/user_steps.rb
  138. +186 −0 ...or/plugins/restful-authentication/generators/authenticated/templates/stories/users/accounts.story
  139. +134 −0 ...or/plugins/restful-authentication/generators/authenticated/templates/stories/users/sessions.story
  140. +82 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/test/functional_test.rb
  141. +31 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/test/mailer_test.rb
  142. +93 −0 ...r/plugins/restful-authentication/generators/authenticated/templates/test/model_functional_test.rb
  143. +164 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/test/unit_test.rb
  144. +1 −0 vendor/plugins/restful-authentication/init.rb
  145. +1 −0 vendor/plugins/restful-authentication/install.rb
  146. +40 −0 vendor/plugins/restful-authentication/lib/authentication.rb
  147. +82 −0 vendor/plugins/restful-authentication/lib/authentication/by_cookie_token.rb
  148. +64 −0 vendor/plugins/restful-authentication/lib/authentication/by_password.rb
  149. +14 −0 vendor/plugins/restful-authentication/lib/authorization.rb
  150. +63 −0 vendor/plugins/restful-authentication/lib/authorization/aasm_roles.rb
  151. +62 −0 vendor/plugins/restful-authentication/lib/authorization/stateful_roles.rb
  152. +14 −0 vendor/plugins/restful-authentication/lib/trustification.rb
  153. +20 −0 vendor/plugins/restful-authentication/lib/trustification/email_validation.rb
  154. +2 −0 vendor/plugins/restful-authentication/notes/AccessControl.txt
  155. +5 −0 vendor/plugins/restful-authentication/notes/Authentication.txt
  156. +154 −0 vendor/plugins/restful-authentication/notes/Authorization.txt
  157. +78 −0 vendor/plugins/restful-authentication/notes/RailsPlugins.txt
  158. BIN vendor/plugins/restful-authentication/notes/SecurityFramework.graffle
  159. BIN vendor/plugins/restful-authentication/notes/SecurityFramework.png
  160. +163 −0 vendor/plugins/restful-authentication/notes/SecurityPatterns.txt
  161. +126 −0 vendor/plugins/restful-authentication/notes/Tradeoffs.txt
  162. +49 −0 vendor/plugins/restful-authentication/notes/Trustification.txt
  163. +3 −0 vendor/plugins/restful-authentication/rails/init.rb
  164. +33 −0 vendor/plugins/restful-authentication/restful-authentication.gemspec
  165. +33 −0 vendor/plugins/restful-authentication/tasks/auth.rake
  166. +1 −0 vendor/plugins/restful_authentication_i18n
View
@@ -1,2 +1,3 @@
log
db/*sqlite
+config/initializers/site_keys.rb
View
@@ -0,0 +1,3 @@
+[submodule "vendor/plugins/restful_authentication_i18n"]
+ path = vendor/plugins/restful_authentication_i18n
+ url = git://github.com/dcrec1/restful-authentication-i18n.git
@@ -2,6 +2,9 @@
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
+ # restful_authentication
+ include AuthenticatedSystem
+
helper :all # include all helpers, all the time
# See ActionController::RequestForgeryProtection for details
@@ -0,0 +1,42 @@
+# This controller handles the login/logout function of the site.
+class SessionsController < ApplicationController
+
+
+ # render new.rhtml
+ def new
+ end
+
+ def create
+ logout_keeping_session!
+ user = User.authenticate(params[:login], params[:password])
+ if user
+ # Protects against session fixation attacks, causes request forgery
+ # protection if user resubmits an earlier form using back
+ # button. Uncomment if you understand the tradeoffs.
+ # reset_session
+ self.current_user = user
+ new_cookie_flag = (params[:remember_me] == "1")
+ handle_remember_cookie! new_cookie_flag
+ redirect_back_or_default('/')
+ flash[:notice] = "Logged in successfully"
+ else
+ note_failed_signin
+ @login = params[:login]
+ @remember_me = params[:remember_me]
+ render :action => 'new'
+ end
+ end
+
+ def destroy
+ logout_killing_session!
+ flash[:notice] = "You have been logged out."
+ redirect_back_or_default('/')
+ end
+
+protected
+ # Track failed login attempts
+ def note_failed_signin
+ flash[:error] = "Couldn't log you in as '#{params[:login]}'"
+ logger.warn "Failed login for '#{params[:login]}' from #{request.remote_ip} at #{Time.now.utc}"
+ end
+end
@@ -1,85 +1,39 @@
class UsersController < ApplicationController
- # GET /users
- # GET /users.xml
- def index
- @users = User.find(:all)
- respond_to do |format|
- format.html # index.html.erb
- format.xml { render :xml => @users }
- end
- end
-
- # GET /users/1
- # GET /users/1.xml
- def show
- @user = User.find(params[:id])
+
- respond_to do |format|
- format.html # show.html.erb
- format.xml { render :xml => @user }
- end
- end
-
- # GET /users/new
- # GET /users/new.xml
+ # render new.rhtml
def new
@user = User.new
-
- respond_to do |format|
- format.html # new.html.erb
- format.xml { render :xml => @user }
- end
end
-
- # GET /users/1/edit
- def edit
- @user = User.find(params[:id])
- end
-
- # POST /users
- # POST /users.xml
+
def create
+ logout_keeping_session!
@user = User.new(params[:user])
-
- respond_to do |format|
- if @user.save
- flash[:notice] = 'User was successfully created.'
- format.html { redirect_to(@user) }
- format.xml { render :xml => @user, :status => :created, :location => @user }
- else
- format.html { render :action => "new" }
- format.xml { render :xml => @user.errors, :status => :unprocessable_entity }
- end
- end
- end
-
- # PUT /users/1
- # PUT /users/1.xml
- def update
- @user = User.find(params[:id])
-
- respond_to do |format|
- if @user.update_attributes(params[:user])
- flash[:notice] = 'User was successfully updated.'
- format.html { redirect_to(@user) }
- format.xml { head :ok }
- else
- format.html { render :action => "edit" }
- format.xml { render :xml => @user.errors, :status => :unprocessable_entity }
- end
+ success = @user && @user.save
+ if success && @user.errors.empty?
+ redirect_back_or_default('/')
+ flash[:notice] = "Thanks for signing up! We're sending you an email with your activation code."
+ else
+ flash[:error] = "We couldn't set up that account, sorry. Please try again, or contact an admin (link is above)."
+ render :action => 'new'
end
end
- # DELETE /users/1
- # DELETE /users/1.xml
- def destroy
- @user = User.find(params[:id])
- @user.destroy
-
- respond_to do |format|
- format.html { redirect_to(users_url) }
- format.xml { head :ok }
+ def activate
+ logout_keeping_session!
+ user = User.find_by_activation_code(params[:activation_code]) unless params[:activation_code].blank?
+ case
+ when (!params[:activation_code].blank?) && user && !user.active?
+ user.activate!
+ flash[:notice] = "Signup complete! Please sign in to continue."
+ redirect_to '/login'
+ when params[:activation_code].blank?
+ flash[:error] = "The activation code was missing. Please follow the URL from your email."
+ redirect_back_or_default('/')
+ else
+ flash[:error] = "We couldn't find a user with that activation code -- check your email? Or maybe you've already activated -- try signing in."
+ redirect_back_or_default('/')
end
end
end
@@ -0,0 +1,2 @@
+module SessionsHelper
+end
@@ -1,2 +1,93 @@
module UsersHelper
+
+ #
+ # Use this to wrap view elements that the user can't access.
+ # !! Note: this is an *interface*, not *security* feature !!
+ # You need to do all access control at the controller level.
+ #
+ # Example:
+ # <%= if_authorized?(:index, User) do link_to('List all users', users_path) end %> |
+ # <%= if_authorized?(:edit, @user) do link_to('Edit this user', edit_user_path) end %> |
+ # <%= if_authorized?(:destroy, @user) do link_to 'Destroy', @user, :confirm => 'Are you sure?', :method => :delete end %>
+ #
+ #
+ def if_authorized?(action, resource, &block)
+ if authorized?(action, resource)
+ yield action, resource
+ end
+ end
+
+ #
+ # Link to user's page ('users/1')
+ #
+ # By default, their login is used as link text and link title (tooltip)
+ #
+ # Takes options
+ # * :content_text => 'Content text in place of user.login', escaped with
+ # the standard h() function.
+ # * :content_method => :user_instance_method_to_call_for_content_text
+ # * :title_method => :user_instance_method_to_call_for_title_attribute
+ # * as well as link_to()'s standard options
+ #
+ # Examples:
+ # link_to_user @user
+ # # => <a href="/users/3" title="barmy">barmy</a>
+ #
+ # # if you've added a .name attribute:
+ # content_tag :span, :class => :vcard do
+ # (link_to_user user, :class => 'fn n', :title_method => :login, :content_method => :name) +
+ # ': ' + (content_tag :span, user.email, :class => 'email')
+ # end
+ # # => <span class="vcard"><a href="/users/3" title="barmy" class="fn n">Cyril Fotheringay-Phipps</a>: <span class="email">barmy@blandings.com</span></span>
+ #
+ # link_to_user @user, :content_text => 'Your user page'
+ # # => <a href="/users/3" title="barmy" class="nickname">Your user page</a>
+ #
+ def link_to_user(user, options={})
+ raise "Invalid user" unless user
+ options.reverse_merge! :content_method => :login, :title_method => :login, :class => :nickname
+ content_text = options.delete(:content_text)
+ content_text ||= user.send(options.delete(:content_method))
+ options[:title] ||= user.send(options.delete(:title_method))
+ link_to h(content_text), user_path(user), options
+ end
+
+ #
+ # Link to login page using remote ip address as link content
+ #
+ # The :title (and thus, tooltip) is set to the IP address
+ #
+ # Examples:
+ # link_to_login_with_IP
+ # # => <a href="/login" title="169.69.69.69">169.69.69.69</a>
+ #
+ # link_to_login_with_IP :content_text => 'not signed in'
+ # # => <a href="/login" title="169.69.69.69">not signed in</a>
+ #
+ def link_to_login_with_IP content_text=nil, options={}
+ ip_addr = request.remote_ip
+ content_text ||= ip_addr
+ options.reverse_merge! :title => ip_addr
+ if tag = options.delete(:tag)
+ content_tag tag, h(content_text), options
+ else
+ link_to h(content_text), login_path, options
+ end
+ end
+
+ #
+ # Link to the current user's page (using link_to_user) or to the login page
+ # (using link_to_login_with_IP).
+ #
+ def link_to_current_user(options={})
+ if current_user
+ link_to_user current_user, options
+ else
+ content_text = options.delete(:content_text) || 'not signed in'
+ # kill ignored options from link_to_user
+ [:content_method, :title_method].each{|opt| options.delete(opt)}
+ link_to_login_with_IP content_text, options
+ end
+ end
+
end
View
@@ -1,2 +1,7 @@
class Attend < ActiveRecord::Base
+ belongs_to :user
+ belongs_to :paper
+
+ validates_presence_of :user_id
+ validates_presence_of :paper_id
end
View
@@ -1,2 +1,9 @@
class Comment < ActiveRecord::Base
+ belongs_to :paper
+ belongs_to :user
+
+ validates_presence_of :paper_id
+ validates_presence_of :user_id
+ validates_presence_of :text
+
end
View
@@ -1,2 +1,5 @@
class Event < ActiveRecord::Base
+ has_many :payments
+
+ validates_numericality_of :price_cents
end
View
@@ -1,2 +1,19 @@
class Paper < ActiveRecord::Base
+ has_many :speakers
+ has_many :user_speakers, :through => :speakers, :source => :user
+ has_many :comments
+ has_many :resources
+
+ belongs_to :paper_type
+ belongs_to :paper_status
+ belongs_to :room
+
+ validates_presence_of :name
+ validates_presence_of :description
+ validates_presence_of :paper_type_id
+ validates_presence_of :paper_status_id
+ validates_numericality_of :minutes
+
+
+
end
View
@@ -1,2 +1,5 @@
class PaperType < ActiveRecord::Base
+ has_many :papers
+
+ validates_presence_of :name
end
View
@@ -1,2 +1,8 @@
class Payment < ActiveRecord::Base
+ belongs_to :event
+ belongs_to :user
+
+ validates_presence_of :event_id
+ validates_presence_of :user_id
+
end
View
@@ -1,2 +1,5 @@
class Role < ActiveRecord::Base
+ has_many :users
+
+ validates_presence_of :name
end
View
@@ -1,2 +1,4 @@
class Room < ActiveRecord::Base
+
+ validates_presence_of :name
end
View
@@ -1,2 +1,7 @@
class Speaker < ActiveRecord::Base
+ belongs_to :user
+ belongs_to :paper
+
+ validates_presence_of :user_id
+ validates_presence_of :paper_id
end
Oops, something went wrong.

0 comments on commit f0d2a15

Please sign in to comment.