You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by as...@apache.org on 2008/05/03 02:14:05 UTC
svn commit: r652957 [1/4] - in /ode/sandbox/singleshot: ./ app/controllers/
app/helpers/ app/models/ config/ db/ db/migrate/ lib/tasks/
public/javascripts/ spec/controllers/ vendor/plugins/rspec_on_rails/
vendor/plugins/rspec_on_rails/generators/ vendo...
Author: assaf
Date: Fri May 2 17:14:01 2008
New Revision: 652957
URL: http://svn.apache.org/viewvc?rev=652957&view=rev
Log:
ApplicationController now handles authentication for session, HTTP Basic and access key.
Added specification for session/HTTP Basic authentication.
Access key authentication only for GET requests.
Removed TimeZone handling for now, reintroduce when upgrading to Rails 2.1.
Added RSpec for Rails 1.1.3 into vendor/plugins.
Changed to use Sqlite3 as the development/test database.
Upgraded to Rails 2.0.2 scripts.
Added rake setup for setting up the development/test environment.
Added:
ode/sandbox/singleshot/db/schema.rb
ode/sandbox/singleshot/lib/tasks/setup.rb
ode/sandbox/singleshot/spec/controllers/authentication_spec.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/MIT-LICENSE
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/README
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/Rakefile
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/CHANGES
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/rspec_generator.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/templates/
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/templates/all_stories.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/templates/previous_failures.txt
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/templates/rcov.opts
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/templates/script/
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/templates/script/spec
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/templates/script/spec_server
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/templates/spec.opts
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/templates/spec_helper.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/templates/stories_helper.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_controller/
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_controller/USAGE
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_controller/rspec_controller_generator.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/controller_spec.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/helper_spec.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/view_spec.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_model/
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_model/USAGE
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_model/rspec_model_generator.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_model/templates/
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_model/templates/model_spec.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/rspec_scaffold_generator.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/controller_spec.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/edit_erb_spec.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/helper_spec.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/index_erb_spec.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/new_erb_spec.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/routing_spec.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/show_erb_spec.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/init.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/lib/
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/lib/autotest/
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/lib/autotest/discover.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/lib/autotest/rails_rspec.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/lib/spec/
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/lib/spec/rails/
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/lib/spec/rails.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/lib/spec/rails/example/
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/lib/spec/rails/example.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/lib/spec/rails/example/assigns_hash_proxy.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/lib/spec/rails/example/controller_example_group.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/lib/spec/rails/example/functional_example_group.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/lib/spec/rails/example/helper_example_group.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/lib/spec/rails/example/ivar_proxy.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/lib/spec/rails/example/model_example_group.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/lib/spec/rails/example/rails_example_group.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/lib/spec/rails/example/render_observer.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/lib/spec/rails/example/view_example_group.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/action_controller/
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/action_controller/base.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/action_controller/rescue.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/action_controller/test_response.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/action_view/
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/action_view/base.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/active_record/
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/active_record/base.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/object.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/spec/
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/spec/example/
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/spec/example/configuration.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/spec/matchers/
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/spec/matchers/have.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/assert_select.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/have_text.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/redirect_to.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/render_template.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/lib/spec/rails/story_adapter.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/lib/spec/rails/version.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec/
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec/rails/
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec/rails/autotest/
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec/rails/autotest/mappings_spec.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec/rails/autotest/rails_rspec_spec.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec/rails/example/
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec/rails/example/assigns_hash_proxy_spec.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec/rails/example/configuration_spec.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec/rails/example/controller_isolation_spec.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec/rails/example/controller_spec_spec.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec/rails/example/example_group_factory_spec.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec/rails/example/helper_spec_spec.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec/rails/example/ivar_proxy_spec.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec/rails/example/model_spec_spec.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec/rails/example/shared_behaviour_spec.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec/rails/example/test_unit_assertion_accessibility_spec.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec/rails/example/view_spec_spec.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec/rails/extensions/
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec/rails/extensions/action_controller_rescue_action_spec.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec/rails/extensions/action_view_base_spec.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec/rails/extensions/active_record_spec.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec/rails/matchers/
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec/rails/matchers/assert_select_spec.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec/rails/matchers/description_generation_spec.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec/rails/matchers/errors_on_spec.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec/rails/matchers/have_text_spec.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec/rails/matchers/redirect_to_spec.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec/rails/matchers/render_spec.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec/rails/mocks/
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec/rails/mocks/mock_model_spec.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec/rails/sample_spec.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec/rails/spec_server_spec.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec/rails/spec_spec.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec/rails_suite.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec/spec_helper.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/controllers/
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/controllers/action_view_base_spec_controller.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/controllers/controller_spec_controller.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/controllers/redirect_spec_controller.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/controllers/render_spec_controller.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/controllers/rjs_spec_controller.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/helpers/
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/helpers/explicit_helper.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/helpers/more_explicit_helper.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/helpers/plugin_application_helper.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/helpers/view_spec_helper.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/views/
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/views/controller_spec/
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/views/controller_spec/_partial.rhtml
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/views/controller_spec/action_setting_flash_after_session_reset.rhtml
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/views/controller_spec/action_setting_flash_before_session_reset.rhtml
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/views/controller_spec/action_setting_the_assigns_hash.rhtml
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/views/controller_spec/action_with_errors_in_template.rhtml
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/views/controller_spec/action_with_template.rhtml
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/views/render_spec/
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/views/render_spec/_a_partial.rhtml
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/views/render_spec/some_action.js.rjs
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/views/render_spec/some_action.rhtml
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/views/render_spec/some_action.rjs
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/views/rjs_spec/
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/views/rjs_spec/_replacement_partial.rhtml
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/views/rjs_spec/hide_div.rjs
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/views/rjs_spec/hide_page_element.rjs
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/views/rjs_spec/insert_html.rjs
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/views/rjs_spec/replace.rjs
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/views/rjs_spec/replace_html.rjs
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/views/rjs_spec/replace_html_with_partial.rjs
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/views/rjs_spec/visual_effect.rjs
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/views/rjs_spec/visual_toggle_effect.rjs
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/views/tag_spec/
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/views/tag_spec/no_tags.rhtml
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/views/tag_spec/single_div_with_no_attributes.rhtml
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/views/tag_spec/single_div_with_one_attribute.rhtml
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/_partial.rhtml
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/_partial_used_twice.rhtml
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/_partial_with_local_variable.rhtml
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/_partial_with_sub_partial.rhtml
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/_spacer.rhtml
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/accessor.rhtml
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/entry_form.rhtml
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/explicit_helper.rhtml
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/foo/
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/foo/show.rhtml
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/implicit_helper.rhtml
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/multiple_helpers.rhtml
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/template_with_partial.rhtml
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/template_with_partial_using_collection.rhtml
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/template_with_partial_with_array.rhtml
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/stories/
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/stories/all.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/stories/helper.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/stories/steps/
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/stories/steps/people.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/stories/transactions_should_rollback
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/stories/transactions_should_rollback.rb
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/tasks/
ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/tasks/rspec.rake
Modified:
ode/sandbox/singleshot/Rakefile
ode/sandbox/singleshot/app/controllers/application.rb
ode/sandbox/singleshot/app/helpers/application_helper.rb
ode/sandbox/singleshot/app/models/person.rb
ode/sandbox/singleshot/app/models/stakeholder.rb
ode/sandbox/singleshot/app/models/task.rb
ode/sandbox/singleshot/config/boot.rb
ode/sandbox/singleshot/config/database.yml
ode/sandbox/singleshot/config/environment.rb
ode/sandbox/singleshot/config/routes.rb
ode/sandbox/singleshot/db/migrate/001_create_people.rb
ode/sandbox/singleshot/public/javascripts/application.js
Modified: ode/sandbox/singleshot/Rakefile
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/Rakefile?rev=652957&r1=652956&r2=652957&view=diff
==============================================================================
--- ode/sandbox/singleshot/Rakefile (original)
+++ ode/sandbox/singleshot/Rakefile Fri May 2 17:14:01 2008
@@ -8,3 +8,16 @@
require 'rake/rdoctask'
require 'tasks/rails'
+require 'lib/tasks/setup.rb'
+
+
+task 'setup' do |task|
+ task.install_gem 'rspec', '~>1.1.3'
+ task.install_gem 'rails', '~>2.0.2'
+ task.install_gem 'sqlite3-ruby', '~>1.2'
+
+ # Create development and test databases.
+ ['db:create', 'db:migrate', 'db:test:clone'].each do |task|
+ task.invoke
+ end
+end
Modified: ode/sandbox/singleshot/app/controllers/application.rb
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/controllers/application.rb?rev=652957&r1=652956&r2=652957&view=diff
==============================================================================
--- ode/sandbox/singleshot/app/controllers/application.rb (original)
+++ ode/sandbox/singleshot/app/controllers/application.rb Fri May 2 17:14:01 2008
@@ -5,33 +5,24 @@
helper :all # include all helpers, all the time
- # Turn sessions off for JSON, XML, Atom, etc. We only use sessions for login/flash in HTML pages
- # and XHR requests, so only turn them on for these cases. This also forces HTTP Basic authentication
- # on all other request types.
- session :off, :if=>lambda { |req| !(req.format.html? || req.xhr?) }
-
# --- Authentication ---
- # Raise to return 403 (Forbidden) with optional error message.
- class NotAuthorized < Exception
- end
- rescue_responses[NotAuthorized.name] = :forbidden
+ # Turn sessions off for everything but HTML and AJAX. This also forces HTTP Basic Authentication
+ # on all other type of requests (JSON, iCal, etc).
+ session :off, :if=>lambda { |req| !(req.format.html? || req.xhr?) }
- # Returns Person object for currently authenticated user.
- attr_reader :authenticated
+ before_filter :authenticate
- # Use as filter to authenticate using either HTTP Basic Authentication or sessions.
- # Authenticates using HTTP Basic if authentication header provided, and forces HTTP Basic
- # if sessions are disabled (e.g. JSON and XML content types). Otherwise, authenticates
- # using sessions and stores the authenticated person's identifier in person_id.
+ # Authentication filter, added by default on all actions in all controllers.
+ # Uses HTTP Basic Authentication or, when processing HTML/AJAX requests, sessions.
def authenticate
if ActionController::HttpAuthentication::Basic.authorization(request) || !session_enabled?
authenticate_or_request_with_http_basic request.domain do |login, password|
@authenticated = Person.authenticate(login, password)
end
else
- @authenticated = Person.find(session[:person_id]) rescue nil
+ @authenticated ||= Person.find(session[:person_id]) rescue nil
unless @authenticated
flash[:return_to] = request.url
redirect_to session_url
@@ -39,18 +30,23 @@
end
end
- # Authenticate using access_key parameter for cases where we cannot use sessions,
- # HTTP Basic or any other mechanism, for example, for accessing feeds and iCalendar.
- # This authentication only works for GET requests.
- def authenticate_using_access_key
- @authenticated = Person.find_by_access_key(params[:access_key]) if request.get?
- raise ActiveRecord::RecordNotFound unless @authenticated
+ # Access key authentication, used for feeds, iCal and other type of requets that
+ # do not support HTTP authentication or sessions. Can only be used for GET requests.
+ #
+ # To apply as a filter (must come before authenticate):
+ # prepend_before_filter :authenticate_with_access_key, :only=>[:feed]
+ def authenticate_with_access_key
+ raise ActionController::MethodNotAllowed, 'GET' unless request.get?
+ @authenticated = Person.find_by_access_key(params[:access_key]) or raise ActiveRecord::RecordNotFound
end
- # Returns query string parameters for authentication, see #authenticate_using_access_key.
- def access_key_authentication_parameters
- { :access_key=>authenticated.access_key }
+ # Raise to return 403 (Forbidden) with optional error message.
+ class NotAuthorized < Exception
end
+ rescue_responses[NotAuthorized.name] = :forbidden
+
+ # Returns Person object for currently authenticated user.
+ attr_reader :authenticated
# --- Authenticated user ---
@@ -60,27 +56,6 @@
authenticated.language
end
- # Given the time (defaults to now) returns an adjusted time based on the authenticated user's timezone.
- # This should be used when presenting formatted time without the timezone.
- #
- # For example:
- # tz_adjust(item.updated_at).to_s
- def tz_adjust(time = Time.now)
- return time unless authenticated.timezone
- timezone = TimeZone[authenticated.timezone]
- timezone ? timezone.adjust(time) : time
- end
-
- # Given the time (Time or string) returns unadjusted time (to UTC) based on the authenticated user's timezone.
- # This should be used for time inputs provided without the timezone.
- #
- # For example:
- # due_on = tz_adjust(params[:due_on])
- def tz_unadjust(time)
- time = Time.parse(time.to_s) unless Time === time
- return time unless authenticated.timezone
- timezone = TimeZone[authenticated.timezone]
- timezone ? timezone.unadjust(time) : time
- end
+ # TODO: Add timezone support when upgrading to Rails 2.1.
end
Modified: ode/sandbox/singleshot/app/helpers/application_helper.rb
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/helpers/application_helper.rb?rev=652957&r1=652956&r2=652957&view=diff
==============================================================================
--- ode/sandbox/singleshot/app/helpers/application_helper.rb (original)
+++ ode/sandbox/singleshot/app/helpers/application_helper.rb Fri May 2 17:14:01 2008
@@ -14,12 +14,12 @@
attr_reader :authenticated
def relative_date_with_adjustment(date)
- date = controller.tz_adjust(date.utc) if Time === date
+ date = date.utc if Time === date
relative_date(date)
end
def relative_date_with_abbr(date)
- date = controller.tz_adjust(date.utc) if Time === date
+ date = date.utc if Time === date
content_tag 'abbr', h(relative_date(date)), :title=>date.to_date.to_s
end
Modified: ode/sandbox/singleshot/app/models/person.rb
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/models/person.rb?rev=652957&r1=652956&r2=652957&view=diff
==============================================================================
--- ode/sandbox/singleshot/app/models/person.rb (original)
+++ ode/sandbox/singleshot/app/models/person.rb Fri May 2 17:14:01 2008
@@ -3,21 +3,20 @@
#
# Table name: people
#
-# id :integer(11) not null, primary key
-# identity :string(255) default(""), not null
-# fullname :string(255) default(""), not null
-# email :string(255) default(""), not null
+# id :integer not null, primary key
+# identity :string(255) not null
+# fullname :string(255) not null
+# email :string(255) not null
# language :string(5)
# timezone :integer(4)
# password :string(64)
-# access_key :string(32) default(""), not null
-# site_url :string(255)
-# admin :boolean(1) not null
+# access_key :string(32) not null
# created_at :datetime
# updated_at :datetime
#
require 'sha1'
+require 'openssl'
# Internally we keep a primary key association between the person and various other records.
# Externally, we use a public identifier returned from #to_param and resolved with Person.identify.
@@ -88,9 +87,6 @@
end
private :fix_attributes
- # Site URL, if specified, must be a valid HTTP(S) URL.
- validates_url :site_url, :if=>:site_url
-
# TODO: Some way to check minimum size of passwords.
def password=(password)
@@ -100,6 +96,7 @@
end
def password?(password)
+ return false unless self[:password]
seed, crypted = self[:password].split(':')
crypted == SHA1.hexdigest("#{seed}:#{password}")
end
Modified: ode/sandbox/singleshot/app/models/stakeholder.rb
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/models/stakeholder.rb?rev=652957&r1=652956&r2=652957&view=diff
==============================================================================
--- ode/sandbox/singleshot/app/models/stakeholder.rb (original)
+++ ode/sandbox/singleshot/app/models/stakeholder.rb Fri May 2 17:14:01 2008
@@ -3,9 +3,9 @@
#
# Table name: stakeholders
#
-# id :integer(11) not null, primary key
-# task_id :integer(11) not null
-# person_id :integer(11) not null
+# id :integer not null, primary key
+# task_id :integer not null
+# person_id :integer not null
# role :integer(2) not null
# created_at :datetime
# updated_at :datetime
Modified: ode/sandbox/singleshot/app/models/task.rb
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/models/task.rb?rev=652957&r1=652956&r2=652957&view=diff
==============================================================================
--- ode/sandbox/singleshot/app/models/task.rb (original)
+++ ode/sandbox/singleshot/app/models/task.rb Fri May 2 17:14:01 2008
@@ -3,7 +3,7 @@
#
# Table name: tasks
#
-# id :integer(11) not null, primary key
+# id :integer not null, primary key
# title :string(255)
# priority :integer(1) default(1)
# due_on :date
@@ -12,11 +12,11 @@
# outcome_url :string(255)
# outcome_type :string(255)
# cancellation :integer(1)
-# creator_id :integer(11)
-# owner_id :integer(11)
-# access_key :string(32) default(""), not null
-# data :text default(""), not null
-# version :integer(11) default(0), not null
+# creator_id :integer
+# owner_id :integer
+# access_key :string(32) not null
+# data :text not null
+# version :integer default(0), not null
# created_at :datetime
# updated_at :datetime
#
Modified: ode/sandbox/singleshot/config/boot.rb
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/config/boot.rb?rev=652957&r1=652956&r2=652957&view=diff
==============================================================================
--- ode/sandbox/singleshot/config/boot.rb (original)
+++ ode/sandbox/singleshot/config/boot.rb Fri May 2 17:14:01 2008
@@ -24,6 +24,7 @@
File.exist?("#{RAILS_ROOT}/vendor/rails")
end
+ # FIXME : Ruby 1.9
def preinitialize
load(preinitializer_path) if File.exists?(preinitializer_path)
end
@@ -93,7 +94,7 @@
end
def parse_gem_version(text)
- $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*'([!~<>=]*\s*[\d.]+)'/
+ $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
end
private
Modified: ode/sandbox/singleshot/config/database.yml
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/config/database.yml?rev=652957&r1=652956&r2=652957&view=diff
==============================================================================
--- ode/sandbox/singleshot/config/database.yml (original)
+++ ode/sandbox/singleshot/config/database.yml Fri May 2 17:14:01 2008
@@ -12,21 +12,17 @@
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
- adapter: mysql
- database: singleshot_development
- username: singleshot
- password: singleshot
- socket: /var/lib/mysql/mysql.sock
+ adapter: sqlite3
+ database: db/development.sqlite3
+ timeout: 5000
# Warning: The database defined as 'test' will be erased and
# re-generated from your development database when you run 'rake'.
# Do not set this db to the same as development or production.
test:
- adapter: mysql
- database: singleshot_test
- username: singleshot
- password: singleshot
- socket: /var/lib/mysql/mysql.sock
+ adapter: sqlite3
+ database: db/test.sqlite3
+ timeout: 5000
production:
adapter: mysql
Modified: ode/sandbox/singleshot/config/environment.rb
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/config/environment.rb?rev=652957&r1=652956&r2=652957&view=diff
==============================================================================
--- ode/sandbox/singleshot/config/environment.rb (original)
+++ ode/sandbox/singleshot/config/environment.rb Fri May 2 17:14:01 2008
@@ -32,7 +32,8 @@
config.action_controller.session = {
:session_key => '_single_shot_session',
# NOTE: This is publicly accessible, change before deploying!
- :secret => %{ 37°20'12.78"N, 121°53'41.69"W}
+ # Use rake secret to generate a new crypto random value.
+ :secret => '01d45defc4a9585c2e0a9d6bb1d10ff3488fa2ffef1fd439ad03894cc2ae4e5025bdc6487972679b97a7ac79bd385ee07b36c7952f7882d35bdc9bc60aa584bf'
}
# Use the database for sessions instead of the file system
@@ -42,13 +43,13 @@
# Use SQL instead of Active Record's schema dumper when creating the test database.
# This is necessary if your schema can't be completely dumped by the schema dumper,
# like if you have constraints or database-specific column types
- config.active_record.schema_format = :sql
+ #config.active_record.schema_format = :sql
# Activate observers that should always be running
# config.active_record.observers = :cacher, :garbage_collector
# Make Active Record use UTC-base instead of local time
- config.active_record.default_timezone = :utc
+ #config.active_record.default_timezone = :utc
# See Rails::Configuration for more options
Modified: ode/sandbox/singleshot/config/routes.rb
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/config/routes.rb?rev=652957&r1=652956&r2=652957&view=diff
==============================================================================
--- ode/sandbox/singleshot/config/routes.rb (original)
+++ ode/sandbox/singleshot/config/routes.rb Fri May 2 17:14:01 2008
@@ -9,6 +9,8 @@
end
map.resource :sandwich
map.root :controller=>'tasks'
+ map.connect ':controller/:action/:id'
+
# Authentication resource (create/destroy).
Modified: ode/sandbox/singleshot/db/migrate/001_create_people.rb
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/db/migrate/001_create_people.rb?rev=652957&r1=652956&r2=652957&view=diff
==============================================================================
--- ode/sandbox/singleshot/db/migrate/001_create_people.rb (original)
+++ ode/sandbox/singleshot/db/migrate/001_create_people.rb Fri May 2 17:14:01 2008
@@ -1,24 +1,22 @@
class CreatePeople < ActiveRecord::Migration
def self.up
- create_table :people do |t|
- t.string :identity, :null=>false
- t.string :fullname, :null=>false
- t.string :email, :null=>false
- t.string :language, :null=>true, :limit=>5
- t.integer :timezone, :null=>true, :limit=>4
- t.string :password, :null=>true, :limit=>64
- t.string :access_key, :null=>false, :limit=>32
- t.string :site_url, :null=>true
- t.boolean :admin, :null=>false, :default=>false
+ create_table 'people' do |t|
+ t.string 'identity', :null=>false
+ t.string 'fullname', :null=>false
+ t.string 'email', :null=>false
+ t.string 'language', :null=>true, :limit=>5
+ t.integer 'timezone', :null=>true, :limit=>4
+ t.string 'password', :null=>true, :limit=>64
+ t.string 'access_key', :null=>false, :limit=>32
t.timestamps
end
- add_index :people, :identity, :unique=>true
- add_index :people, :fullname
- add_index :people, :email, :unique=>true
- add_index :people, :access_key, :unique=>true
+ add_index 'people', 'identity', :unique=>true
+ add_index 'people', 'fullname'
+ add_index 'people', 'email', :unique=>true
+ add_index 'people', 'access_key', :unique=>true
end
def self.down
- drop_table :people
+ drop_table 'people'
end
end
Added: ode/sandbox/singleshot/db/schema.rb
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/db/schema.rb?rev=652957&view=auto
==============================================================================
--- ode/sandbox/singleshot/db/schema.rb (added)
+++ ode/sandbox/singleshot/db/schema.rb Fri May 2 17:14:01 2008
@@ -0,0 +1,63 @@
+# This file is auto-generated from the current state of the database. Instead of editing this file,
+# please use the migrations feature of ActiveRecord to incrementally modify your database, and
+# then regenerate this schema definition.
+#
+# Note that this schema.rb definition is the authoritative source for your database schema. If you need
+# to create the application database on another system, you should be using db:schema:load, not running
+# all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
+# you'll amass, the slower it'll run and the greater likelihood for issues).
+#
+# It's strongly recommended to check this file into your version control system.
+
+ActiveRecord::Schema.define(:version => 3) do
+
+ create_table "people", :force => true do |t|
+ t.string "identity", :null => false
+ t.string "fullname", :null => false
+ t.string "email", :null => false
+ t.string "language", :limit => 5
+ t.integer "timezone", :limit => 4
+ t.string "password", :limit => 64
+ t.string "access_key", :limit => 32, :null => false
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "people", ["access_key"], :name => "index_people_on_access_key", :unique => true
+ add_index "people", ["email"], :name => "index_people_on_email", :unique => true
+ add_index "people", ["fullname"], :name => "index_people_on_fullname"
+ add_index "people", ["identity"], :name => "index_people_on_identity", :unique => true
+
+ create_table "stakeholders", :force => true do |t|
+ t.integer "task_id", :null => false
+ t.integer "person_id", :null => false
+ t.integer "role", :limit => 2, :null => false
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "stakeholders", ["person_id", "role"], :name => "index_stakeholders_on_person_id_and_role"
+ add_index "stakeholders", ["task_id", "role"], :name => "index_stakeholders_on_task_id_and_role"
+ add_index "stakeholders", ["task_id", "person_id", "role"], :name => "index_stakeholders_on_task_id_and_person_id_and_role", :unique => true
+
+ create_table "tasks", :force => true do |t|
+ t.string "title"
+ t.integer "priority", :limit => 1, :default => 1
+ t.date "due_on"
+ t.integer "status", :limit => 2, :default => 0, :null => false
+ t.string "frame_url"
+ t.string "outcome_url"
+ t.string "outcome_type"
+ t.integer "cancellation", :limit => 1
+ t.integer "creator_id"
+ t.integer "owner_id"
+ t.string "access_key", :limit => 32, :null => false
+ t.text "data", :null => false
+ t.integer "version", :default => 0, :null => false
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "tasks", ["status", "updated_at"], :name => "index_tasks_on_status_and_updated_at"
+
+end
Added: ode/sandbox/singleshot/lib/tasks/setup.rb
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/lib/tasks/setup.rb?rev=652957&view=auto
==============================================================================
--- ode/sandbox/singleshot/lib/tasks/setup.rb (added)
+++ ode/sandbox/singleshot/lib/tasks/setup.rb Fri May 2 17:14:01 2008
@@ -0,0 +1,87 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with this
+# work for additional information regarding copyright ownership. The ASF
+# licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+# True if running on the Windows operating sytem. Different from Gem.win_platform?
+# which returns true if running on the Windows platform of MRI, false when using JRuby.
+
+
+require 'rubygems/source_info_cache'
+
+
+module Rake
+
+ module SetupMethods
+
+ # Returns true if the host OS is Windows. Different from checking RUBY_PLATFORM
+ # (and Gem.win_platform?) both of which report 'java' when running on JRuby.
+ # Knowing the host OS is necessary for certain things, e.g. sudo and which.
+ def windows?
+ Config::CONFIG['host_os'] =~ /windows|cygwin|bccwin|cygwin|djgpp|mingw|mswin|wince/i
+ end
+
+ # Installs the Gem (if not already installed). The first argument is either
+ # Gem::Dependency, or the Gem name. If a Gem name, the second argument can
+ # specify the required version.
+ #
+ # For example:
+ # spec.dependencies.each do |dep|
+ # install_gem dep
+ # end
+ # install_gem 'super'
+ # install_gem 'awesome', '~> 1.2'
+ def install_gem(dep, ver_requirement = nil)
+ dep = Gem::Dependency.new(dep, ver_requirement) unless Gem::Dependency === dep
+ if Gem::SourceIndex.from_installed_gems.search(dep).empty?
+ spec = Gem::SourceInfoCache.search(dep).last
+ fail "#{dep} not found in local or remote repository!" unless spec
+ puts "Installing #{spec} ..."
+ args = [Config::CONFIG['ruby_install_name'], '-S', 'gem', 'install', spec.name, '-v', spec.version.to_s]
+ args.unshift('sudo') unless windows?
+ sh *args
+ end
+ end
+
+ # Finds and returns path to executable. Consults PATH environment variable.
+ # Returns nil if executable not found.
+ def which(name)
+ if windows?
+ path = ENV['PATH'].split(File::PATH_SEPARATOR).map { |path| path.gsub('\\', '/') }.map { |path| "#{path}/#{name}.{exe,bat,com}" }
+ else
+ path = ENV['PATH'].split(File::PATH_SEPARATOR).map { |path| "#{path}/#{name}" }
+ end
+ FileList[path].existing.first
+ end
+
+ # Returns missing dependencies: dependencies defined in the Gem specification
+ # but not installed locally.
+ def missing_from(spec)
+ spec.dependencies.select { |dep| Gem::SourceIndex.from_installed_gems.search(dep).empty? }
+ end
+
+ end
+
+ class SetupTask < Task
+ extend SetupMethods
+ include SetupMethods
+ end
+
+ desc 'Sets up the necessary dependencies, tools, etc. Run after checking out the source code, or every major upadte.'
+ SetupTask.define_task 'setup' do |task|
+ if defined?(spec)
+ SetupTask.missing_from(spec).each do |dep|
+ SetupTask.install_gem dep
+ end
+ end
+ end
+end
Modified: ode/sandbox/singleshot/public/javascripts/application.js
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/public/javascripts/application.js?rev=652957&r1=652956&r2=652957&view=diff
==============================================================================
--- ode/sandbox/singleshot/public/javascripts/application.js (original)
+++ ode/sandbox/singleshot/public/javascripts/application.js Fri May 2 17:14:01 2008
@@ -1,47 +1,2 @@
// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
-
-var Singleshot = {
- // Returns the SingleShot.TaskView object.
- taskView: function() {
- var taskView = new Singleshot.TaskView();
- Singleshot.taskView = function() { return taskView };
- return taskView;
- },
-
- expand: function(event, target, alternative) {
- event = event || window.event;
- var source = Event.element(event);
- target = $(target);
- if (target.visible()) {
- source.innerHTML = source.originalText;
- target.hide();
- } else if (event.shiftKey || event.ctrlKey || event.metaKey) {
- return;
- } else {
- source.originalText = source.innerHTML;
- if (alternative)
- source.innerHTML = alternative;
- target.show();
- }
- Event.stop(event);
- }
-}
-
-Singleshot.TaskView = Class.create({
- initialize: function() {
- this.adjustFrame('task_frame');
- },
-
- adjustFrame: function(ifr) {
- // Adjust lower frame to expand and fit the reminder of the window.
- // Do it once now, and each time the window is resized.
- if (ifr = $(ifr)) {
- var adjust = function() {
- ifr.style.height = window.innerHeight - ifr.offsetTop;
- }
- Event.observe(window, 'resize', adjust);
- adjust();
- }
- }
-});
Added: ode/sandbox/singleshot/spec/controllers/authentication_spec.rb
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/spec/controllers/authentication_spec.rb?rev=652957&view=auto
==============================================================================
--- ode/sandbox/singleshot/spec/controllers/authentication_spec.rb (added)
+++ ode/sandbox/singleshot/spec/controllers/authentication_spec.rb Fri May 2 17:14:01 2008
@@ -0,0 +1,131 @@
+require File.dirname(__FILE__) + '/../spec_helper'
+
+class AuthenticationTestController < ApplicationController
+ prepend_before_filter :authenticate_with_access_key, :only=>['feed']
+
+ def index
+ end
+
+ def feed
+ end
+end
+
+
+share_examples_for 'AuthenticationTest' do
+ controller_name :authentication_test
+
+ before :all do
+ @person = Person.create(:email=>'lucy@test.host', :password=>'secret')
+ end
+
+ after :all do
+ Person.delete_all
+ end
+end
+
+
+describe 'Unauthenticated request' do
+ controller_name :authentication_test
+
+ it 'should redirect to login page when requesting HTML' do
+ get 'index'
+ response.should redirect_to('/session')
+ end
+
+ it 'should pass request URL in return_to session parameter' do
+ get 'index'
+ flash[:return_to].should eql(controller.url_for(:controller=>'authentication_test', :action=>'index'))
+ end
+
+ it 'should return 401 when requesting XML document' do
+ get 'index', :format=>'xml'
+ response.should be(:unauthorized)
+ end
+
+ it 'should return 401 when requesting JSON document' do
+ get 'index', :format=>'json'
+ response.should be(:unauthorized)
+ end
+end
+
+
+describe 'Session authentication' do
+ it_should_behave_like 'AuthenticationTest'
+
+ it 'should redirect to login page if person does not exist' do
+ get 'index', nil, :person_id=>0
+ response.should redirect_to('/session')
+ end
+
+ it 'should return response if user account exists' do
+ get 'index', nil, :person_id=>@person.id
+ response.should be(:ok)
+ end
+
+ it 'should assign authenticated user in controller' do
+ get 'index', nil, :person_id=>@person.id
+ assigns[:authenticated].should == @person
+ end
+end
+
+
+describe 'Query param authentication' do
+ it_should_behave_like 'AuthenticationTest'
+
+ it 'should have no affect unless applied to action' do
+ get 'index'
+ response.should redirect_to('/session')
+ end
+
+ it 'should return 404 if not matching user\'s access key' do
+ lambda { get 'feed', :access_key=>'wrong' }.should raise_error(ActiveRecord::RecordNotFound)
+ end
+
+ it 'should return 404 if no access key provided' do
+ lambda { get 'feed' }.should raise_error(ActiveRecord::RecordNotFound)
+ end
+
+ it 'should return 405 if POST request' do
+ lambda { post 'feed', :access_key=>@person.access_key }.should raise_error(ActionController::MethodNotAllowed, /Only GET/)
+ end
+
+ it 'should return response if matching user\'s access key' do
+ get 'feed', :access_key=>@person.access_key
+ response.should be(:ok)
+ end
+
+ it 'should assign authenticated user in controller' do
+ get 'feed', :access_key=>@person.access_key
+ assigns[:authenticated].should == @person
+ end
+end
+
+
+describe 'HTTP Basic username/password' do
+ it_should_behave_like 'AuthenticationTest'
+
+ it 'should return 401 if not authenticated' do
+ request.headers['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Basic.encode_credentials('lucy', 'wrong')
+ get 'index'
+ response.should be(:unauthorized)
+ end
+
+ it 'should return response if authenticated' do
+ request.headers['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Basic.encode_credentials('lucy', 'secret')
+ get 'index'
+ response.should be(:ok)
+ end
+
+ it 'should assign authenticated user in controller' do
+ request.headers['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Basic.encode_credentials('lucy', 'secret')
+ get 'index'
+ assigns[:authenticated].should == @person
+ end
+
+ it 'should not fail on password-less account' do
+ Person.create(:email=>'mary@test.host')
+ request.headers['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Basic.encode_credentials('mary', 'wrong')
+ get 'index'
+ response.should be(:unauthorized)
+ end
+end
Added: ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/MIT-LICENSE
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/MIT-LICENSE?rev=652957&view=auto
==============================================================================
--- ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/MIT-LICENSE (added)
+++ ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/MIT-LICENSE Fri May 2 17:14:01 2008
@@ -0,0 +1,31 @@
+====================================================================
+== RSpec
+Copyright (c) 2005-2007 The RSpec Development Team
+====================================================================
+== ARTS
+Copyright (c) 2006 Kevin Clark, Jake Howerton
+====================================================================
+== ZenTest
+Copyright (c) 2001-2006 Ryan Davis, Eric Hodel, Zen Spider Software
+====================================================================
+== AssertSelect
+Copyright (c) 2006 Assaf Arkin
+====================================================================
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
Added: ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/README
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/README?rev=652957&view=auto
==============================================================================
--- ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/README (added)
+++ ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/README Fri May 2 17:14:01 2008
@@ -0,0 +1,3 @@
+See the rdoc for Spec::Rails for usage documentation.
+
+See ~/rspec/README for instructions on running rspec_on_rails' examples.
\ No newline at end of file
Added: ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/Rakefile
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/Rakefile?rev=652957&view=auto
==============================================================================
--- ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/Rakefile (added)
+++ ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/Rakefile Fri May 2 17:14:01 2008
@@ -0,0 +1,9 @@
+require 'rake'
+require 'rake/rdoctask'
+
+desc 'Generate RDoc'
+rd = Rake::RDocTask.new do |rdoc|
+ rdoc.rdoc_dir = '../doc/output/rdoc-rails'
+ rdoc.options << '--title' << 'Spec::Rails' << '--line-numbers' << '--inline-source' << '--main' << 'Spec::Rails'
+ rdoc.rdoc_files.include('MIT-LICENSE', 'lib/**/*.rb')
+end
Added: ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/CHANGES
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/CHANGES?rev=652957&view=auto
==============================================================================
--- ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/CHANGES (added)
+++ ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/CHANGES Fri May 2 17:14:01 2008
@@ -0,0 +1 @@
+Please refer to the CHANGES file for RSpec's core
\ No newline at end of file
Added: ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/rspec_generator.rb
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/rspec_generator.rb?rev=652957&view=auto
==============================================================================
--- ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/rspec_generator.rb (added)
+++ ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/rspec_generator.rb Fri May 2 17:14:01 2008
@@ -0,0 +1,35 @@
+require 'rbconfig'
+
+# This generator bootstraps a Rails project for use with RSpec
+class RspecGenerator < Rails::Generator::Base
+ DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
+ Config::CONFIG['ruby_install_name'])
+
+ def initialize(runtime_args, runtime_options = {})
+ super
+ end
+
+ def manifest
+ record do |m|
+ script_options = { :chmod => 0755, :shebang => options[:shebang] == DEFAULT_SHEBANG ? nil : options[:shebang] }
+
+ m.directory 'spec'
+ m.template 'spec_helper.rb', 'spec/spec_helper.rb'
+ m.file 'spec.opts', 'spec/spec.opts'
+ m.file 'rcov.opts', 'spec/rcov.opts'
+ m.file 'script/spec_server', 'script/spec_server', script_options
+ m.file 'script/spec', 'script/spec', script_options
+
+ m.directory 'stories'
+ m.file 'all_stories.rb', 'stories/all.rb'
+ m.file 'stories_helper.rb', 'stories/helper.rb'
+ end
+ end
+
+protected
+
+ def banner
+ "Usage: #{$0} rspec"
+ end
+
+end
Added: ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/templates/all_stories.rb
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/templates/all_stories.rb?rev=652957&view=auto
==============================================================================
--- ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/templates/all_stories.rb (added)
+++ ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/templates/all_stories.rb Fri May 2 17:14:01 2008
@@ -0,0 +1,4 @@
+dir = File.dirname(__FILE__)
+Dir[File.expand_path("#{dir}/**/*.rb")].uniq.each do |file|
+ require file
+end
\ No newline at end of file
Added: ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/templates/previous_failures.txt
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/templates/previous_failures.txt?rev=652957&view=auto
==============================================================================
(empty)
Added: ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/templates/rcov.opts
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/templates/rcov.opts?rev=652957&view=auto
==============================================================================
--- ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/templates/rcov.opts (added)
+++ ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/templates/rcov.opts Fri May 2 17:14:01 2008
@@ -0,0 +1,2 @@
+--exclude "spec/*,gems/*"
+--rails
\ No newline at end of file
Added: ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/templates/script/spec
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/templates/script/spec?rev=652957&view=auto
==============================================================================
--- ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/templates/script/spec (added)
+++ ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/templates/script/spec Fri May 2 17:14:01 2008
@@ -0,0 +1,4 @@
+#!/usr/bin/env ruby
+$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../vendor/plugins/rspec/lib"))
+require 'spec'
+exit ::Spec::Runner::CommandLine.run(::Spec::Runner::OptionParser.parse(ARGV, STDERR, STDOUT))
Added: ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/templates/script/spec_server
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/templates/script/spec_server?rev=652957&view=auto
==============================================================================
--- ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/templates/script/spec_server (added)
+++ ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/templates/script/spec_server Fri May 2 17:14:01 2008
@@ -0,0 +1,102 @@
+#!/usr/bin/env ruby
+$LOAD_PATH.unshift File.dirname(__FILE__) + '/../../rspec/lib' # For svn
+$LOAD_PATH.unshift File.dirname(__FILE__) + '/../vendor/plugins/rspec/lib' # For rspec installed as plugin
+require 'rubygems'
+require 'drb/drb'
+require 'rbconfig'
+require 'spec'
+require 'optparse'
+
+# This is based on Florian Weber's TDDMate
+module Spec
+ module Runner
+ class RailsSpecServer
+ def run(argv, stderr, stdout)
+ $stdout = stdout
+ $stderr = stderr
+
+ base = ActiveRecord::Base
+ def base.clear_reloadable_connections!
+ active_connections.each do |name, conn|
+ if conn.requires_reloading?
+ conn.disconnect!
+ active_connections.delete(name)
+ end
+ end
+ end
+
+ if ActionController.const_defined?(:Dispatcher)
+ dispatcher = ::ActionController::Dispatcher.new($stdout)
+ dispatcher.cleanup_application(true)
+ elsif ::Dispatcher.respond_to?(:reset_application!)
+ ::Dispatcher.reset_application!
+ else
+ raise "Application reloading failed"
+ end
+ ::Dependencies.mechanism = :load
+ require_dependency('application.rb') unless Object.const_defined?(:ApplicationController)
+ load File.dirname(__FILE__) + '/../spec/spec_helper.rb'
+
+ ::Spec::Runner::CommandLine.run(
+ ::Spec::Runner::OptionParser.parse(
+ argv,
+ $stderr,
+ $stdout
+ )
+ )
+ end
+ end
+ end
+end
+puts "Loading Rails environment"
+
+ENV["RAILS_ENV"] = "test"
+require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
+require 'dispatcher'
+
+def restart_test_server
+ puts "restarting"
+ config = ::Config::CONFIG
+ ruby = File::join(config['bindir'], config['ruby_install_name']) + config['EXEEXT']
+ command_line = [ruby, $0, ARGV].flatten.join(' ')
+ exec(command_line)
+end
+
+def daemonize(pid_file = nil)
+ return yield if $DEBUG
+ pid = Process.fork{
+ Process.setsid
+ Dir.chdir(RAILS_ROOT)
+ trap("SIGINT"){ exit! 0 }
+ trap("SIGTERM"){ exit! 0 }
+ trap("SIGHUP"){ restart_test_server }
+ File.open("/dev/null"){|f|
+ STDERR.reopen f
+ STDIN.reopen f
+ STDOUT.reopen f
+ }
+ yield
+ }
+ puts "spec_server launched. (PID: %d)" % pid
+ File.open(pid_file,"w"){|f| f.puts pid } if pid_file
+ exit! 0
+end
+
+options = Hash.new
+opts = OptionParser.new
+opts.on("-d", "--daemon"){|v| options[:daemon] = true }
+opts.on("-p", "--pid PIDFILE"){|v| options[:pid] = v }
+opts.parse!(ARGV)
+
+puts "Ready"
+exec_server = lambda {
+ trap("USR2") { restart_test_server } if Signal.list.has_key?("USR2")
+ DRb.start_service("druby://localhost:8989", Spec::Runner::RailsSpecServer.new)
+ DRb.thread.join
+}
+
+if options[:daemon]
+ daemonize(options[:pid], &exec_server)
+else
+ exec_server.call
+end
Added: ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/templates/spec.opts
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/templates/spec.opts?rev=652957&view=auto
==============================================================================
--- ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/templates/spec.opts (added)
+++ ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/templates/spec.opts Fri May 2 17:14:01 2008
@@ -0,0 +1,6 @@
+--colour
+--format
+progress
+--loadby
+mtime
+--reverse
Added: ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/templates/spec_helper.rb
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/templates/spec_helper.rb?rev=652957&view=auto
==============================================================================
--- ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/templates/spec_helper.rb (added)
+++ ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/templates/spec_helper.rb Fri May 2 17:14:01 2008
@@ -0,0 +1,39 @@
+# This file is copied to ~/spec when you run 'ruby script/generate rspec'
+# from the project root directory.
+ENV["RAILS_ENV"] = "test"
+require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
+require 'spec'
+require 'spec/rails'
+
+Spec::Runner.configure do |config|
+ # If you're not using ActiveRecord you should remove these
+ # lines, delete config/database.yml and disable :active_record
+ # in your config/boot.rb
+ config.use_transactional_fixtures = true
+ config.use_instantiated_fixtures = false
+ config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
+
+ # == Fixtures
+ #
+ # You can declare fixtures for each example_group like this:
+ # describe "...." do
+ # fixtures :table_a, :table_b
+ #
+ # Alternatively, if you prefer to declare them only once, you can
+ # do so right here. Just uncomment the next line and replace the fixture
+ # names with your fixtures.
+ #
+ # config.global_fixtures = :table_a, :table_b
+ #
+ # If you declare global fixtures, be aware that they will be declared
+ # for all of your examples, even those that don't use them.
+ #
+ # == Mock Framework
+ #
+ # RSpec uses it's own mocking framework by default. If you prefer to
+ # use mocha, flexmock or RR, uncomment the appropriate line:
+ #
+ # config.mock_with :mocha
+ # config.mock_with :flexmock
+ # config.mock_with :rr
+end
Added: ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/templates/stories_helper.rb
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/templates/stories_helper.rb?rev=652957&view=auto
==============================================================================
--- ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/templates/stories_helper.rb (added)
+++ ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec/templates/stories_helper.rb Fri May 2 17:14:01 2008
@@ -0,0 +1,3 @@
+ENV["RAILS_ENV"] = "test"
+require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
+require 'spec/rails/story_adapter'
\ No newline at end of file
Added: ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_controller/USAGE
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_controller/USAGE?rev=652957&view=auto
==============================================================================
--- ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_controller/USAGE (added)
+++ ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_controller/USAGE Fri May 2 17:14:01 2008
@@ -0,0 +1,33 @@
+Description:
+ The rspec_controller generator creates stub specs and files for a new
+ controller and its views.
+
+ The generator takes a controller name and a list of views as arguments.
+ The controller name may be given in CamelCase or under_score and should
+ not be suffixed with 'Controller'. To create a controller within a
+ module, specify the controller name as 'module/controller'.
+
+ The generator creates stubs for a controller (and spec), a view (and spec)
+ for each view in the argument list, plus a helper.
+
+Example:
+ ./script/generate rspec_controller dog bark fetch
+ ...
+ create spec/controllers/dog_controller_spec.rb
+ create app/controllers/dog_controller.rb
+ create app/helpers/dog_helper.rb
+ create spec/views/dog/bark_view_spec.rb
+ create app/views/dog/bark.rhtml
+ create spec/views/dog/fetch_view_spec.rb
+ create app/views/dog/fetch.rhtml
+
+Modules Example:
+ ./script/generate rspec_controller 'pets/dog' bark fetch
+ ...
+ create spec/controllers/pets/dog_controller_spec.rb
+ create app/controllers/pets/dog_controller.rb
+ create app/helpers/pets/dog_helper.rb
+ create spec/views/pets/dog/bark_view_spec.rb
+ create app/views/pets/dog/bark.rhtml
+ create spec/views/pets/dog/fetch_view_spec.rb
+ create app/views/pets/dog/fetch.rhtml
Added: ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_controller/rspec_controller_generator.rb
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_controller/rspec_controller_generator.rb?rev=652957&view=auto
==============================================================================
--- ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_controller/rspec_controller_generator.rb (added)
+++ ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_controller/rspec_controller_generator.rb Fri May 2 17:14:01 2008
@@ -0,0 +1,49 @@
+require 'rails_generator/generators/components/controller/controller_generator'
+
+class RspecControllerGenerator < ControllerGenerator
+
+ def manifest
+ record do |m|
+ # Check for class naming collisions.
+ m.class_collisions class_path, "#{class_name}Controller", "#{class_name}Helper"
+
+ # Controller, helper, views, and spec directories.
+ m.directory File.join('app/controllers', class_path)
+ m.directory File.join('app/helpers', class_path)
+ m.directory File.join('app/views', class_path, file_name)
+ m.directory File.join('spec/controllers', class_path)
+ m.directory File.join('spec/helpers', class_path)
+ m.directory File.join('spec/views', class_path, file_name)
+
+ if Rails::VERSION::STRING < "2.0.0"
+ @default_file_extension = "rhtml"
+ else
+ @default_file_extension = "html.erb"
+ end
+
+ # Controller spec, class, and helper.
+ m.template 'controller_spec.rb',
+ File.join('spec/controllers', class_path, "#{file_name}_controller_spec.rb")
+
+ m.template 'helper_spec.rb',
+ File.join('spec/helpers', class_path, "#{file_name}_helper_spec.rb")
+
+ m.template 'controller:controller.rb',
+ File.join('app/controllers', class_path, "#{file_name}_controller.rb")
+
+ m.template 'controller:helper.rb',
+ File.join('app/helpers', class_path, "#{file_name}_helper.rb")
+
+ # Spec and view template for each action.
+ actions.each do |action|
+ m.template 'view_spec.rb',
+ File.join('spec/views', class_path, file_name, "#{action}.#{@default_file_extension}_spec.rb"),
+ :assigns => { :action => action, :model => file_name }
+ path = File.join('app/views', class_path, file_name, "#{action}.#{@default_file_extension}")
+ m.template "controller:view.#{@default_file_extension}",
+ path,
+ :assigns => { :action => action, :path => path }
+ end
+ end
+ end
+end
Added: ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/controller_spec.rb
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/controller_spec.rb?rev=652957&view=auto
==============================================================================
--- ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/controller_spec.rb (added)
+++ ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/controller_spec.rb Fri May 2 17:14:01 2008
@@ -0,0 +1,25 @@
+require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper'
+
+describe <%= class_name %>Controller do
+
+<% if actions.empty? -%>
+ #Delete this example and add some real ones
+<% else -%>
+ #Delete these examples and add some real ones
+<% end -%>
+ it "should use <%= class_name %>Controller" do
+ controller.should be_an_instance_of(<%= class_name %>Controller)
+ end
+
+<% unless actions.empty? -%>
+<% for action in actions -%>
+
+ describe "GET '<%= action %>'" do
+ it "should be successful" do
+ get '<%= action %>'
+ response.should be_success
+ end
+ end
+<% end -%>
+<% end -%>
+end
Added: ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/helper_spec.rb
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/helper_spec.rb?rev=652957&view=auto
==============================================================================
--- ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/helper_spec.rb (added)
+++ ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/helper_spec.rb Fri May 2 17:14:01 2008
@@ -0,0 +1,11 @@
+require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper'
+
+describe <%= class_name %>Helper do
+
+ #Delete this example and add some real ones or delete this file
+ it "should include the <%= class_name %>Helper" do
+ included_modules = self.metaclass.send :included_modules
+ included_modules.should include(<%= class_name %>Helper)
+ end
+
+end
Added: ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/view_spec.rb
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/view_spec.rb?rev=652957&view=auto
==============================================================================
--- ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/view_spec.rb (added)
+++ ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/view_spec.rb Fri May 2 17:14:01 2008
@@ -0,0 +1,12 @@
+require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper'
+
+describe "/<%= class_name.underscore %>/<%= action %>" do
+ before(:each) do
+ render '<%= class_name.underscore %>/<%= action %>'
+ end
+
+ #Delete this example and add some real ones or delete this file
+ it "should tell you where to find the file" do
+ response.should have_tag('p', /Find me in app\/views\/<%= class_name.underscore %>\/<%= action %>/)
+ end
+end
Added: ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_model/USAGE
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_model/USAGE?rev=652957&view=auto
==============================================================================
--- ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_model/USAGE (added)
+++ ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_model/USAGE Fri May 2 17:14:01 2008
@@ -0,0 +1,18 @@
+Description:
+ The rspec_model generator creates stubs for a new model.
+
+ The generator takes a model name as its argument. The model name may be
+ given in CamelCase or under_score and should not be suffixed with 'Model'.
+
+ The generator creates a model class in app/models, an RSpec spec in
+ spec/models, database fixtures in spec/fixtures/plural_name.yml, and a migration
+ in db/migrate.
+
+Example:
+ ./script/generate rspec_model Account
+
+ This will create an Account model:
+ Model: app/models/account.rb
+ Spec: spec/models/account_spec.rb
+ Fixtures: spec/fixtures/accounts.yml
+ Migration: db/migrate/XXX_add_accounts.rb
Added: ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_model/rspec_model_generator.rb
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_model/rspec_model_generator.rb?rev=652957&view=auto
==============================================================================
--- ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_model/rspec_model_generator.rb (added)
+++ ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_model/rspec_model_generator.rb Fri May 2 17:14:01 2008
@@ -0,0 +1,30 @@
+require 'rails_generator/generators/components/model/model_generator'
+
+class RspecModelGenerator < ModelGenerator
+
+ def manifest
+
+ record do |m|
+ # Check for class naming collisions.
+ m.class_collisions class_path, class_name
+
+ # Model, spec, and fixture directories.
+ m.directory File.join('app/models', class_path)
+ m.directory File.join('spec/models', class_path)
+ m.directory File.join('spec/fixtures', class_path)
+
+ # Model class, spec and fixtures.
+ m.template 'model:model.rb', File.join('app/models', class_path, "#{file_name}.rb")
+ m.template 'model:fixtures.yml', File.join('spec/fixtures', class_path, "#{table_name}.yml")
+ m.template 'model_spec.rb', File.join('spec/models', class_path, "#{file_name}_spec.rb")
+
+ unless options[:skip_migration]
+ m.migration_template 'model:migration.rb', 'db/migrate', :assigns => {
+ :migration_name => "Create#{class_name.pluralize.gsub(/::/, '')}"
+ }, :migration_file_name => "create_#{file_path.gsub(/\//, '_').pluralize}"
+ end
+
+ end
+ end
+
+end
Added: ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_model/templates/model_spec.rb
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_model/templates/model_spec.rb?rev=652957&view=auto
==============================================================================
--- ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_model/templates/model_spec.rb (added)
+++ ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_model/templates/model_spec.rb Fri May 2 17:14:01 2008
@@ -0,0 +1,11 @@
+require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper'
+
+describe <%= class_name %> do
+ before(:each) do
+ @<%= file_name %> = <%= class_name %>.new
+ end
+
+ it "should be valid" do
+ @<%= file_name %>.should be_valid
+ end
+end
Added: ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/rspec_scaffold_generator.rb
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/rspec_scaffold_generator.rb?rev=652957&view=auto
==============================================================================
--- ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/rspec_scaffold_generator.rb (added)
+++ ode/sandbox/singleshot/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/rspec_scaffold_generator.rb Fri May 2 17:14:01 2008
@@ -0,0 +1,167 @@
+class RspecScaffoldGenerator < Rails::Generator::NamedBase
+ default_options :skip_migration => false
+
+ attr_reader :controller_name,
+ :controller_class_path,
+ :controller_file_path,
+ :controller_class_nesting,
+ :controller_class_nesting_depth,
+ :controller_class_name,
+ :controller_singular_name,
+ :controller_plural_name,
+ :resource_edit_path,
+ :default_file_extension
+ alias_method :controller_file_name, :controller_singular_name
+ alias_method :controller_table_name, :controller_plural_name
+
+ def initialize(runtime_args, runtime_options = {})
+ super
+
+ @controller_name = @name.pluralize
+
+ base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(@controller_name)
+ @controller_class_name_without_nesting, @controller_singular_name, @controller_plural_name = inflect_names(base_name)
+
+ if @controller_class_nesting.empty?
+ @controller_class_name = @controller_class_name_without_nesting
+ else
+ @controller_class_name = "#{@controller_class_nesting}::#{@controller_class_name_without_nesting}"
+ end
+
+ if Rails::VERSION::STRING < "2.0.0"
+ @resource_generator = "scaffold_resource"
+ @default_file_extension = "rhtml"
+ else
+ @resource_generator = "scaffold"
+ @default_file_extension = "html.erb"
+ end
+
+ if ActionController::Base.respond_to?(:resource_action_separator)
+ @resource_edit_path = "/edit"
+ else
+ @resource_edit_path = ";edit"
+ end
+ end
+
+ def manifest
+ record do |m|
+
+ # Check for class naming collisions.
+ m.class_collisions(controller_class_path, "#{controller_class_name}Controller", "#{controller_class_name}Helper")
+ m.class_collisions(class_path, "#{class_name}")
+
+ # Controller, helper, views, and spec directories.
+ m.directory(File.join('app/models', class_path))
+ m.directory(File.join('app/controllers', controller_class_path))
+ m.directory(File.join('app/helpers', controller_class_path))
+ m.directory(File.join('app/views', controller_class_path, controller_file_name))
+ m.directory(File.join('spec/controllers', controller_class_path))
+ m.directory(File.join('spec/models', class_path))
+ m.directory(File.join('spec/helpers', class_path))
+ m.directory File.join('spec/fixtures', class_path)
+ m.directory File.join('spec/views', controller_class_path, controller_file_name)
+
+ # Controller spec, class, and helper.
+ m.template 'rspec_scaffold:routing_spec.rb',
+ File.join('spec/controllers', controller_class_path, "#{controller_file_name}_routing_spec.rb")
+
+ m.template 'rspec_scaffold:controller_spec.rb',
+ File.join('spec/controllers', controller_class_path, "#{controller_file_name}_controller_spec.rb")
+
+ m.template "#{@resource_generator}:controller.rb",
+ File.join('app/controllers', controller_class_path, "#{controller_file_name}_controller.rb")
+
+ m.template 'rspec_scaffold:helper_spec.rb',
+ File.join('spec/helpers', class_path, "#{controller_file_name}_helper_spec.rb")
+
+ m.template "#{@resource_generator}:helper.rb",
+ File.join('app/helpers', controller_class_path, "#{controller_file_name}_helper.rb")
+
+ for action in scaffold_views
+ m.template(
+ "#{@resource_generator}:view_#{action}.#{@default_file_extension}",
+ File.join('app/views', controller_class_path, controller_file_name, "#{action}.#{default_file_extension}")
+ )
+ end
+
+ # Model class, unit test, and fixtures.
+ m.template 'model:model.rb', File.join('app/models', class_path, "#{file_name}.rb")
+ m.template 'model:fixtures.yml', File.join('spec/fixtures', class_path, "#{table_name}.yml")
+ m.template 'rspec_model:model_spec.rb', File.join('spec/models', class_path, "#{file_name}_spec.rb")
+
+ # View specs
+ m.template "rspec_scaffold:edit_erb_spec.rb",
+ File.join('spec/views', controller_class_path, controller_file_name, "edit.#{default_file_extension}_spec.rb")
+ m.template "rspec_scaffold:index_erb_spec.rb",
+ File.join('spec/views', controller_class_path, controller_file_name, "index.#{default_file_extension}_spec.rb")
+ m.template "rspec_scaffold:new_erb_spec.rb",
+ File.join('spec/views', controller_class_path, controller_file_name, "new.#{default_file_extension}_spec.rb")
+ m.template "rspec_scaffold:show_erb_spec.rb",
+ File.join('spec/views', controller_class_path, controller_file_name, "show.#{default_file_extension}_spec.rb")
+
+ unless options[:skip_migration]
+ m.migration_template(
+ 'model:migration.rb', 'db/migrate',
+ :assigns => {
+ :migration_name => "Create#{class_name.pluralize.gsub(/::/, '')}",
+ :attributes => attributes
+ },
+ :migration_file_name => "create_#{file_path.gsub(/\//, '_').pluralize}"
+ )
+ end
+
+ m.route_resources controller_file_name
+
+ end
+ end
+
+ protected
+ # Override with your own usage banner.
+ def banner
+ "Usage: #{$0} rspec_scaffold ModelName [field:type field:type]"
+ end
+
+ def add_options!(opt)
+ opt.separator ''
+ opt.separator 'Options:'
+ opt.on("--skip-migration",
+ "Don't generate a migration file for this model") { |v| options[:skip_migration] = v }
+ end
+
+ def scaffold_views
+ %w[ index show new edit ]
+ end
+
+ def model_name
+ class_name.demodulize
+ end
+end
+
+module Rails
+ module Generator
+ class GeneratedAttribute
+ def default_value
+ @default_value ||= case type
+ when :int, :integer then "\"1\""
+ when :float then "\"1.5\""
+ when :decimal then "\"9.99\""
+ when :datetime, :timestamp, :time then "Time.now"
+ when :date then "Date.today"
+ when :string then "\"MyString\""
+ when :text then "\"MyText\""
+ when :boolean then "false"
+ else
+ ""
+ end
+ end
+
+ def input_type
+ @input_type ||= case type
+ when :text then "textarea"
+ else
+ "input"
+ end
+ end
+ end
+ end
+end