muck-raker 0.3.18 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/MIT-LICENSE +1 -1
- data/README.rdoc +3 -7
- data/Rakefile +2 -4
- data/VERSION +1 -1
- data/config/initializers/muck_raker.rb +1 -1
- data/lib/muck-raker.rb +2 -0
- data/lib/muck-raker/config.rb +22 -0
- data/lib/muck-raker/engine.rb +12 -0
- data/lib/tasks/muck_raker.rake +152 -0
- data/muck-raker.gemspec +207 -191
- data/test/rails_test/app/controllers/application_controller.rb +21 -0
- data/test/rails_test/app/controllers/default_controller.rb +7 -0
- data/test/rails_test/app/helpers/application_helper.rb +3 -0
- data/test/rails_test/app/models/comment.rb +3 -0
- data/test/rails_test/app/models/profile.rb +3 -0
- data/test/rails_test/app/models/user.rb +9 -0
- data/test/rails_test/app/models/user_session.rb +2 -0
- data/test/rails_test/config/application.rb +42 -0
- data/test/rails_test/config/boot.rb +13 -0
- data/test/rails_test/config/environment.rb +5 -0
- data/test/rails_test/config/environments/development.rb +26 -0
- data/test/rails_test/config/environments/production.rb +49 -0
- data/test/rails_test/config/environments/test.rb +35 -0
- data/test/rails_test/config/initializers/backtrace_silencers.rb +7 -0
- data/test/{rails_root → rails_test}/config/initializers/inflections.rb +2 -2
- data/test/{rails_root → rails_test}/config/initializers/mime_types.rb +0 -0
- data/test/rails_test/config/initializers/muck_raker.rb +13 -0
- data/test/rails_test/config/initializers/secret_token.rb +7 -0
- data/test/rails_test/config/initializers/session_store.rb +8 -0
- data/test/rails_test/config/routes.rb +5 -0
- data/test/{rails_root → rails_test}/db/migrate/20090320174818_create_muck_permissions_and_roles.rb +0 -0
- data/test/{rails_root → rails_test}/db/migrate/20090402033319_add_muck_activities.rb +0 -0
- data/test/{rails_root → rails_test}/db/migrate/20090402234137_create_languages.rb +0 -0
- data/test/{rails_root → rails_test}/db/migrate/20090426041056_create_countries.rb +0 -0
- data/test/{rails_root → rails_test}/db/migrate/20090426041103_create_states.rb +0 -0
- data/test/{rails_root → rails_test}/db/migrate/20090602041838_create_users.rb +0 -0
- data/test/{rails_root → rails_test}/db/migrate/20090602191243_create_muck_raker.rb +0 -0
- data/test/{rails_root → rails_test}/db/migrate/20090613173314_create_comments.rb +0 -0
- data/test/{rails_root → rails_test}/db/migrate/20090619211125_create_tag_clouds.rb +0 -0
- data/test/{rails_root → rails_test}/db/migrate/20090623181458_add_grain_size_to_entries.rb +0 -0
- data/test/{rails_root → rails_test}/db/migrate/20090623193525_add_grain_size_to_tag_clouds.rb +0 -0
- data/test/{rails_root → rails_test}/db/migrate/20090703175825_denormalize_entries_subjects.rb +0 -0
- data/test/{rails_root → rails_test}/db/migrate/20090704220055_create_slugs.rb +0 -0
- data/test/{rails_root → rails_test}/db/migrate/20090704220120_acts_as_taggable_on_migration.rb +0 -0
- data/test/{rails_root → rails_test}/db/migrate/20090716035935_change_tag_cloud_grain_sizes.rb +0 -0
- data/test/{rails_root → rails_test}/db/migrate/20090717173900_add_contributor_to_feeds.rb +0 -0
- data/test/{rails_root → rails_test}/db/migrate/20090717175825_normalize_entries_subjects.rb +0 -0
- data/test/{rails_root → rails_test}/db/migrate/20090721043213_change_services_title_to_name.rb +0 -0
- data/test/{rails_root → rails_test}/db/migrate/20090721054927_remove_services_not_null_from_feeds.rb +0 -0
- data/test/{rails_root → rails_test}/db/migrate/20090723050510_create_feed_parents.rb +0 -0
- data/test/{rails_root → rails_test}/db/migrate/20090728165716_add_etag_to_feeds.rb +0 -0
- data/test/{rails_root → rails_test}/db/migrate/20090730044139_add_comment_cache.rb +0 -0
- data/test/{rails_root → rails_test}/db/migrate/20090730045848_add_comment_cache_to_entries.rb +0 -0
- data/test/{rails_root → rails_test}/db/migrate/20090730154102_allow_null_user.rb +0 -0
- data/test/{rails_root → rails_test}/db/migrate/20090803185323_create_shares.rb +0 -0
- data/test/{rails_root → rails_test}/db/migrate/20090804184247_add_comment_count_to_shares.rb +0 -0
- data/test/{rails_root → rails_test}/db/migrate/20090804211240_add_entry_id_to_shares.rb +0 -0
- data/test/{rails_root → rails_test}/db/migrate/20090804231857_add_shares_uri_index.rb +0 -0
- data/test/{rails_root → rails_test}/db/migrate/20090818204527_add_activity_indexes.rb +0 -0
- data/test/{rails_root → rails_test}/db/migrate/20090819030523_add_attachable_to_activities.rb +0 -0
- data/test/{rails_root → rails_test}/db/migrate/20090826220530_change_services_sequence_to_sort.rb +0 -0
- data/test/{rails_root → rails_test}/db/migrate/20090826225652_create_identity_feeds.rb +0 -0
- data/test/{rails_root → rails_test}/db/migrate/20090827005105_add_identity_fields_to_services.rb +0 -0
- data/test/{rails_root → rails_test}/db/migrate/20090827015308_create_service_categories.rb +0 -0
- data/test/{rails_root → rails_test}/db/migrate/20090827221502_add_prompt_and_template_to_services.rb +0 -0
- data/test/{rails_root → rails_test}/db/migrate/20090915041650_aggregations_to_polymorphic.rb +0 -0
- data/test/{rails_root → rails_test}/db/migrate/20090922174200_update_oai_endpoints.rb +0 -0
- data/test/{rails_root → rails_test}/db/migrate/20090922231552_add_dates_to_oai_endpoints.rb +0 -0
- data/test/{rails_root → rails_test}/db/migrate/20090923150807_rename_name_in_aggregation.rb +0 -0
- data/test/{rails_root → rails_test}/db/migrate/20090924200750_add_uri_data_template_to_services.rb +0 -0
- data/test/{rails_root → rails_test}/db/migrate/20091006183742_add_feed_count_to_aggregation.rb +0 -0
- data/test/{rails_root → rails_test}/db/migrate/20091022150615_add_uri_key_to_services.rb +0 -0
- data/test/rails_test/features/step_definitions/comment_steps.rb +11 -0
- data/test/rails_test/features/step_definitions/common_steps.rb +93 -0
- data/test/rails_test/features/step_definitions/web_steps.rb +219 -0
- data/test/rails_test/features/step_definitions/webrat_steps.rb +128 -0
- data/test/rails_test/features/support/custom_env.rb +19 -0
- data/test/rails_test/features/support/env.rb +58 -0
- data/test/rails_test/features/support/paths.rb +33 -0
- data/test/rails_test/public/dispatch.rb +10 -0
- data/test/rails_test/spec/spec_helper.rb +5 -0
- metadata +151 -117
- data/install.rb +0 -1
- data/lib/muck_raker.rb +0 -0
- data/lib/muck_raker/tasks.rb +0 -167
- data/rails/init.rb +0 -2
- data/tasks/muck_raker_tasks.rake +0 -1
- data/test/rails_root/config/boot.rb +0 -109
- data/test/rails_root/config/environment.rb +0 -20
- data/test/rails_root/config/environments/development.rb +0 -21
- data/test/rails_root/config/environments/production.rb +0 -1
- data/test/rails_root/config/environments/test.rb +0 -24
- data/test/rails_root/config/initializers/requires.rb +0 -13
- data/test/rails_root/config/initializers/session_store.rb +0 -8
- data/test/rails_root/config/routes.rb +0 -3
- data/test/rails_root/script/create_project.rb +0 -52
- data/uninstall.rb +0 -1
@@ -0,0 +1,21 @@
|
|
1
|
+
class ApplicationController < ActionController::Base
|
2
|
+
|
3
|
+
helper :all
|
4
|
+
protect_from_forgery
|
5
|
+
|
6
|
+
protected
|
7
|
+
# called by Admin::Muck::BaseController to check whether or not the
|
8
|
+
# user should have access to the admin UI
|
9
|
+
def admin_access?
|
10
|
+
admin?
|
11
|
+
end
|
12
|
+
|
13
|
+
# only require ssl if we are in production
|
14
|
+
def ssl_required?
|
15
|
+
return ENV['SSL'] == 'on' ? true : false if defined? ENV['SSL']
|
16
|
+
return false if local_request?
|
17
|
+
return false if RAILS_ENV == 'test'
|
18
|
+
((self.class.read_inheritable_attribute(:ssl_required_actions) || []).include?(action_name.to_sym)) && (RAILS_ENV == 'production' || RAILS_ENV == 'staging')
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
class User < ActiveRecord::Base
|
2
|
+
acts_as_authentic do |c|
|
3
|
+
c.crypto_provider = Authlogic::CryptoProviders::BCrypt
|
4
|
+
end
|
5
|
+
include MuckUsers::Models::MuckUser
|
6
|
+
include MuckProfiles::Models::MuckUser
|
7
|
+
has_many :comments
|
8
|
+
include MuckComments::Models::MuckCommentable
|
9
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require 'rails/all'
|
4
|
+
|
5
|
+
# If you have a Gemfile, require the gems listed there, including any gems
|
6
|
+
# you've limited to :test, :development, or :production.
|
7
|
+
Bundler.require(:default, Rails.env) if defined?(Bundler)
|
8
|
+
|
9
|
+
module RailsTest
|
10
|
+
class Application < Rails::Application
|
11
|
+
# Settings in config/environments/* take precedence over those specified here.
|
12
|
+
# Application configuration should go into files in config/initializers
|
13
|
+
# -- all .rb files in that directory are automatically loaded.
|
14
|
+
|
15
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
16
|
+
# config.autoload_paths += %W(#{config.root}/extras)
|
17
|
+
|
18
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
19
|
+
# :all can be used as a placeholder for all plugins not explicitly named.
|
20
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
21
|
+
|
22
|
+
# Activate observers that should always be running.
|
23
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
24
|
+
|
25
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
26
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
27
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
28
|
+
|
29
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
30
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
31
|
+
# config.i18n.default_locale = :de
|
32
|
+
|
33
|
+
# JavaScript files you want as :defaults (application.js is always included).
|
34
|
+
# config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
|
35
|
+
|
36
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
37
|
+
config.encoding = "utf-8"
|
38
|
+
|
39
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
40
|
+
config.filter_parameters += [:password]
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
# Set up gems listed in the Gemfile.
|
4
|
+
gemfile = File.expand_path('../../Gemfile', __FILE__)
|
5
|
+
begin
|
6
|
+
ENV['BUNDLE_GEMFILE'] = gemfile
|
7
|
+
require 'bundler'
|
8
|
+
Bundler.setup
|
9
|
+
rescue Bundler::GemNotFound => e
|
10
|
+
STDERR.puts e.message
|
11
|
+
STDERR.puts "Try running `bundle install`."
|
12
|
+
exit!
|
13
|
+
end if File.exist?(gemfile)
|
@@ -0,0 +1,26 @@
|
|
1
|
+
RailsTest::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/environment.rb
|
3
|
+
|
4
|
+
# In the development environment your application's code is reloaded on
|
5
|
+
# every request. This slows down response time but is perfect for development
|
6
|
+
# since you don't have to restart the webserver when you make code changes.
|
7
|
+
config.cache_classes = false
|
8
|
+
|
9
|
+
# Log error messages when you accidentally call methods on nil.
|
10
|
+
config.whiny_nils = true
|
11
|
+
|
12
|
+
# Show full error reports and disable caching
|
13
|
+
config.consider_all_requests_local = true
|
14
|
+
config.action_view.debug_rjs = true
|
15
|
+
config.action_controller.perform_caching = false
|
16
|
+
|
17
|
+
# Don't care if the mailer can't send
|
18
|
+
config.action_mailer.raise_delivery_errors = false
|
19
|
+
|
20
|
+
# Print deprecation notices to the Rails logger
|
21
|
+
config.active_support.deprecation = :log
|
22
|
+
|
23
|
+
# Only use best-standards-support built into browsers
|
24
|
+
config.action_dispatch.best_standards_support = :builtin
|
25
|
+
end
|
26
|
+
|
@@ -0,0 +1,49 @@
|
|
1
|
+
RailsTest::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/environment.rb
|
3
|
+
|
4
|
+
# The production environment is meant for finished, "live" apps.
|
5
|
+
# Code is not reloaded between requests
|
6
|
+
config.cache_classes = true
|
7
|
+
|
8
|
+
# Full error reports are disabled and caching is turned on
|
9
|
+
config.consider_all_requests_local = false
|
10
|
+
config.action_controller.perform_caching = true
|
11
|
+
|
12
|
+
# Specifies the header that your server uses for sending files
|
13
|
+
config.action_dispatch.x_sendfile_header = "X-Sendfile"
|
14
|
+
|
15
|
+
# For nginx:
|
16
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
|
17
|
+
|
18
|
+
# If you have no front-end server that supports something like X-Sendfile,
|
19
|
+
# just comment this out and Rails will serve the files
|
20
|
+
|
21
|
+
# See everything in the log (default is :info)
|
22
|
+
# config.log_level = :debug
|
23
|
+
|
24
|
+
# Use a different logger for distributed setups
|
25
|
+
# config.logger = SyslogLogger.new
|
26
|
+
|
27
|
+
# Use a different cache store in production
|
28
|
+
# config.cache_store = :mem_cache_store
|
29
|
+
|
30
|
+
# Disable Rails's static asset server
|
31
|
+
# In production, Apache or nginx will already do this
|
32
|
+
config.serve_static_assets = false
|
33
|
+
|
34
|
+
# Enable serving of images, stylesheets, and javascripts from an asset server
|
35
|
+
# config.action_controller.asset_host = "http://assets.example.com"
|
36
|
+
|
37
|
+
# Disable delivery errors, bad email addresses will be ignored
|
38
|
+
# config.action_mailer.raise_delivery_errors = false
|
39
|
+
|
40
|
+
# Enable threaded mode
|
41
|
+
# config.threadsafe!
|
42
|
+
|
43
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
44
|
+
# the I18n.default_locale when a translation can not be found)
|
45
|
+
config.i18n.fallbacks = true
|
46
|
+
|
47
|
+
# Send deprecation notices to registered listeners
|
48
|
+
config.active_support.deprecation = :notify
|
49
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
RailsTest::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/environment.rb
|
3
|
+
|
4
|
+
# The test environment is used exclusively to run your application's
|
5
|
+
# test suite. You never need to work with it otherwise. Remember that
|
6
|
+
# your test database is "scratch space" for the test suite and is wiped
|
7
|
+
# and recreated between test runs. Don't rely on the data there!
|
8
|
+
config.cache_classes = true
|
9
|
+
|
10
|
+
# Log error messages when you accidentally call methods on nil.
|
11
|
+
config.whiny_nils = true
|
12
|
+
|
13
|
+
# Show full error reports and disable caching
|
14
|
+
config.consider_all_requests_local = true
|
15
|
+
config.action_controller.perform_caching = false
|
16
|
+
|
17
|
+
# Raise exceptions instead of rendering exception templates
|
18
|
+
config.action_dispatch.show_exceptions = true
|
19
|
+
|
20
|
+
# Disable request forgery protection in test environment
|
21
|
+
config.action_controller.allow_forgery_protection = false
|
22
|
+
|
23
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
24
|
+
# The :test delivery method accumulates sent emails in the
|
25
|
+
# ActionMailer::Base.deliveries array.
|
26
|
+
config.action_mailer.delivery_method = :test
|
27
|
+
|
28
|
+
# Use SQL instead of Active Record's schema dumper when creating the test database.
|
29
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
30
|
+
# like if you have constraints or database-specific column types
|
31
|
+
# config.active_record.schema_format = :sql
|
32
|
+
|
33
|
+
# Print deprecation notices to the stderr
|
34
|
+
config.active_support.deprecation = :stderr
|
35
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
4
|
+
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
5
|
+
|
6
|
+
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
|
7
|
+
# Rails.backtrace_cleaner.remove_silencers!
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# Be sure to restart your server when you modify this file.
|
2
2
|
|
3
|
-
# Add new inflection rules using the following format
|
3
|
+
# Add new inflection rules using the following format
|
4
4
|
# (all these examples are active by default):
|
5
|
-
# Inflector.inflections do |inflect|
|
5
|
+
# ActiveSupport::Inflector.inflections do |inflect|
|
6
6
|
# inflect.plural /^(ox)$/i, '\1en'
|
7
7
|
# inflect.singular /^(ox)en/i, '\1'
|
8
8
|
# inflect.irregular 'person', 'people'
|
File without changes
|
@@ -0,0 +1,13 @@
|
|
1
|
+
ENV['RAILS_ENV'] = ENV['RAILS_ENV'] || MuckRaker.configuration.rails_env
|
2
|
+
SOLR_CONFIG_PATH = "#{RAILS_ROOT}/config/solr"
|
3
|
+
SOLR_LOGS_PATH = "#{RAILS_ROOT}/log"
|
4
|
+
SOLR_PIDS_PATH = "#{RAILS_ROOT}/tmp/pids/solr"
|
5
|
+
|
6
|
+
RAKER_LOGS_PATH = "#{RAILS_ROOT}/log"
|
7
|
+
RAKER_PIDS_PATH = "#{RAILS_ROOT}/tmp/pids/raker"
|
8
|
+
|
9
|
+
if ENV['RAILS_ENV'] == "production"
|
10
|
+
SOLR_DATA_PATH = "#{RAILS_ROOT}/../../shared/solr_indexes"
|
11
|
+
else
|
12
|
+
SOLR_DATA_PATH = "#{RAILS_ROOT}/solr_indexes"
|
13
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Your secret key for verifying the integrity of signed cookies.
|
4
|
+
# If you change this key, all old signed cookies will become invalid!
|
5
|
+
# Make sure the secret is at least 30 characters and all random,
|
6
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
7
|
+
RailsTest::Application.config.secret_token = '9dokr4d5e1od335fdfb1caec46711pdodkiec976d0ba95b4c0f575cb046cc358bce7a335ee36eb29253fb680d8u3838d871f6baeff48220fee8e9e42ab88diub'
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
RailsTest::Application.config.session_store :cookie_store, :key => '_muck_raker_session'
|
4
|
+
|
5
|
+
# Use the database for sessions instead of the cookie-based default,
|
6
|
+
# which shouldn't be used to store highly confidential information
|
7
|
+
# (create the session table with "rake db:sessions:create")
|
8
|
+
# RailsTest::Application.config.session_store :active_record_store
|
data/test/{rails_root → rails_test}/db/migrate/20090320174818_create_muck_permissions_and_roles.rb
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/test/{rails_root → rails_test}/db/migrate/20090623193525_add_grain_size_to_tag_clouds.rb
RENAMED
File without changes
|
data/test/{rails_root → rails_test}/db/migrate/20090703175825_denormalize_entries_subjects.rb
RENAMED
File without changes
|
File without changes
|
data/test/{rails_root → rails_test}/db/migrate/20090704220120_acts_as_taggable_on_migration.rb
RENAMED
File without changes
|
data/test/{rails_root → rails_test}/db/migrate/20090716035935_change_tag_cloud_grain_sizes.rb
RENAMED
File without changes
|
File without changes
|
File without changes
|
data/test/{rails_root → rails_test}/db/migrate/20090721043213_change_services_title_to_name.rb
RENAMED
File without changes
|
data/test/{rails_root → rails_test}/db/migrate/20090721054927_remove_services_not_null_from_feeds.rb
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/test/{rails_root → rails_test}/db/migrate/20090730045848_add_comment_cache_to_entries.rb
RENAMED
File without changes
|
File without changes
|
File without changes
|
data/test/{rails_root → rails_test}/db/migrate/20090804184247_add_comment_count_to_shares.rb
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/test/{rails_root → rails_test}/db/migrate/20090819030523_add_attachable_to_activities.rb
RENAMED
File without changes
|
data/test/{rails_root → rails_test}/db/migrate/20090826220530_change_services_sequence_to_sort.rb
RENAMED
File without changes
|
File without changes
|
data/test/{rails_root → rails_test}/db/migrate/20090827005105_add_identity_fields_to_services.rb
RENAMED
File without changes
|
File without changes
|
data/test/{rails_root → rails_test}/db/migrate/20090827221502_add_prompt_and_template_to_services.rb
RENAMED
File without changes
|
data/test/{rails_root → rails_test}/db/migrate/20090915041650_aggregations_to_polymorphic.rb
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/test/{rails_root → rails_test}/db/migrate/20090924200750_add_uri_data_template_to_services.rb
RENAMED
File without changes
|
data/test/{rails_root → rails_test}/db/migrate/20091006183742_add_feed_count_to_aggregation.rb
RENAMED
File without changes
|
File without changes
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Given /^There are comments$/ do
|
2
|
+
create_comments
|
3
|
+
end
|
4
|
+
|
5
|
+
def create_comments(commentable = nil)
|
6
|
+
commentable ||= Factory(:user)
|
7
|
+
comment = Factory(:comment, :commentable => commentable)
|
8
|
+
child = Factory(:comment, :commentable => commentable)
|
9
|
+
child.move_to_child_of(comment)
|
10
|
+
comment
|
11
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
PASSWORD = "asdfasdf"
|
2
|
+
|
3
|
+
def log_in_user(user, password)
|
4
|
+
visit(login_url)
|
5
|
+
fill_in("user_session_login", :with => user.login)
|
6
|
+
fill_in("user_session_password", :with => PASSWORD)
|
7
|
+
click_button("Sign In")
|
8
|
+
end
|
9
|
+
|
10
|
+
def log_in_with_login_and_role(login, role)
|
11
|
+
@user = Factory(:user, :login => login, :password => PASSWORD, :password_confirmation => PASSWORD)
|
12
|
+
@user.add_to_role(role)
|
13
|
+
log_in_user(@user, PASSWORD)
|
14
|
+
end
|
15
|
+
|
16
|
+
def log_in_with_role(role)
|
17
|
+
@user = Factory(:user, :password => PASSWORD, :password_confirmation => PASSWORD)
|
18
|
+
@user.add_to_role(role)
|
19
|
+
log_in_user(@user, PASSWORD)
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
Before do
|
24
|
+
ActionMailer::Base.deliveries = []
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
# Assumes password is 'asdfasdf'
|
29
|
+
Given /I log in as "(.*)"/ do |login|
|
30
|
+
@user = User.find_by_login(login)
|
31
|
+
log_in_user(@user, PASSWORD)
|
32
|
+
end
|
33
|
+
|
34
|
+
Given /I log in as new user "(.*)" with password "(.*)"/ do |login, password|
|
35
|
+
@user = Factory(:user, :login => login, :password => password, :password_confirmation => password)
|
36
|
+
log_in_user(@user, password)
|
37
|
+
end
|
38
|
+
|
39
|
+
Given /I log in as new user/ do
|
40
|
+
@user = Factory(:user, :password => PASSWORD, :password_confirmation => PASSWORD)
|
41
|
+
log_in_user(@user, PASSWORD)
|
42
|
+
end
|
43
|
+
|
44
|
+
Given /^I log in with role "(.*)"$/ do |role|
|
45
|
+
log_in_with_role(role)
|
46
|
+
end
|
47
|
+
|
48
|
+
Given /^I am not logged in$/ do
|
49
|
+
post '/logout'
|
50
|
+
end
|
51
|
+
|
52
|
+
Then /^I should see the login$/ do
|
53
|
+
response.body.should =~ /sign_in/m
|
54
|
+
response.body.should =~ /user_session_login/m
|
55
|
+
response.body.should =~ /user_session_password/m
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
#features/step_definitions/common_steps.rb
|
60
|
+
# On page/record
|
61
|
+
Given /^I am on "([^"]*)"$/ do |path|
|
62
|
+
visit path
|
63
|
+
end
|
64
|
+
|
65
|
+
Then /^I should be on "([^"]*)"$/ do |path|
|
66
|
+
current_path.should == path
|
67
|
+
end
|
68
|
+
|
69
|
+
Given /^I am on "([^"]*)" "([^"]*)"$/ do |model,number|
|
70
|
+
visit polymorphic_path(record_from_strings(model,number))
|
71
|
+
end
|
72
|
+
|
73
|
+
Then /^I should be on "([^"]*)" "([^"]*)"$/ do |model,number|
|
74
|
+
current_path.should == polymorphic_path(record_from_strings(model,number))
|
75
|
+
end
|
76
|
+
|
77
|
+
# Existing
|
78
|
+
Given /^a "([^"]*)" exists for "([^"]*)" "([^"]*)"$/ do |associated,model,number|
|
79
|
+
record = record_from_strings(model,number)
|
80
|
+
record.send(associated.underscore+'=',valid(associated))
|
81
|
+
record.save!
|
82
|
+
end
|
83
|
+
|
84
|
+
# Support
|
85
|
+
def current_path
|
86
|
+
response.request.request_uri
|
87
|
+
end
|
88
|
+
|
89
|
+
def record_from_strings(model,number)
|
90
|
+
model.constantize.find(:first,:offset=>number.to_i-1)
|
91
|
+
end
|
92
|
+
|
93
|
+
|