turkee_rails4 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +5 -0
- data/.gitignore +27 -0
- data/.travis.yml +8 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +121 -0
- data/Guardfile +12 -0
- data/LICENSE +20 -0
- data/README.rdoc +205 -0
- data/Rakefile +50 -0
- data/VERSION +1 -0
- data/lib/generators/turkee/templates/add_completed_tasks.rb.erb +17 -0
- data/lib/generators/turkee/templates/add_expired.rb.erb +15 -0
- data/lib/generators/turkee/templates/add_hit_duration.rb.erb +15 -0
- data/lib/generators/turkee/templates/add_imported_assignment_details.rb.erb +33 -0
- data/lib/generators/turkee/templates/create_turkee_study.rb.erb +18 -0
- data/lib/generators/turkee/templates/turkee.rb +8 -0
- data/lib/generators/turkee/templates/turkee_imported_assignments.rb.erb +16 -0
- data/lib/generators/turkee/templates/turkee_migration.rb.erb +25 -0
- data/lib/generators/turkee/turkee_generator.rb +51 -0
- data/lib/helpers/turkee_forms_helper.rb +69 -0
- data/lib/models/turkee_imported_assignment.rb +15 -0
- data/lib/models/turkee_study.rb +11 -0
- data/lib/models/turkee_task.rb +259 -0
- data/lib/tasks/turkee.rb +29 -0
- data/lib/turkee.rb +8 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +5 -0
- data/spec/dummy/app/assets/stylesheets/application.css +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/controllers/surveys_controller.rb +7 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.gitkeep +0 -0
- data/spec/dummy/app/models/.gitkeep +0 -0
- data/spec/dummy/app/models/survey.rb +3 -0
- data/spec/dummy/app/views/layouts/application.html.erb +19 -0
- data/spec/dummy/config/application.rb +41 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +26 -0
- data/spec/dummy/config/environments/production.rb +54 -0
- data/spec/dummy/config/environments/test.rb +38 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +12 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +61 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/migrate/20110710143903_initial_tables.rb +23 -0
- data/spec/dummy/db/migrate/20120819164528_add_association_with_class_name.rb +12 -0
- data/spec/dummy/db/migrate/20130203095901_create_company.rb +14 -0
- data/spec/dummy/db/schema.rb +45 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/dummy/tmp/cache/.gitkeep +0 -0
- data/spec/factories/survey_factory.rb +7 -0
- data/spec/factories/turkee_task_factory.rb +21 -0
- data/spec/helpers/turkee_forms_helper_spec.rb +75 -0
- data/spec/models/turkee_study_spec.rb +19 -0
- data/spec/models/turkee_task_spec.rb +146 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +89 -0
- data/turkee.gemspec +59 -0
- metadata +232 -0
@@ -0,0 +1,54 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# Code is not reloaded between requests
|
5
|
+
config.cache_classes = true
|
6
|
+
|
7
|
+
# Full error reports are disabled and caching is turned on
|
8
|
+
config.consider_all_requests_local = false
|
9
|
+
config.action_controller.perform_caching = true
|
10
|
+
|
11
|
+
# Disable Rails's static asset server (Apache or nginx will already do this)
|
12
|
+
config.serve_static_assets = false
|
13
|
+
|
14
|
+
# Compress JavaScripts and CSS
|
15
|
+
config.assets.compress = true
|
16
|
+
|
17
|
+
# Specify the default JavaScript compressor
|
18
|
+
config.assets.js_compressor = :uglifier
|
19
|
+
|
20
|
+
# Specifies the header that your server uses for sending files
|
21
|
+
# (comment out if your front-end server doesn't support this)
|
22
|
+
config.action_dispatch.x_sendfile_header = "X-Sendfile" # Use 'X-Accel-Redirect' for nginx
|
23
|
+
|
24
|
+
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
25
|
+
# config.force_ssl = true
|
26
|
+
|
27
|
+
# See everything in the log (default is :info)
|
28
|
+
# config.log_level = :debug
|
29
|
+
|
30
|
+
# Use a different logger for distributed setups
|
31
|
+
# config.logger = SyslogLogger.new
|
32
|
+
|
33
|
+
# Use a different cache store in production
|
34
|
+
# config.cache_store = :mem_cache_store
|
35
|
+
|
36
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server
|
37
|
+
# config.action_controller.asset_host = "http://assets.example.com"
|
38
|
+
|
39
|
+
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
|
40
|
+
# config.assets.precompile += %w( search.js )
|
41
|
+
|
42
|
+
# Disable delivery errors, bad email addresses will be ignored
|
43
|
+
# config.action_mailer.raise_delivery_errors = false
|
44
|
+
|
45
|
+
# Enable threaded mode
|
46
|
+
# config.threadsafe!
|
47
|
+
|
48
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
49
|
+
# the I18n.default_locale when a translation can not be found)
|
50
|
+
config.i18n.fallbacks = true
|
51
|
+
|
52
|
+
# Send deprecation notices to registered listeners
|
53
|
+
config.active_support.deprecation = :notify
|
54
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.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
|
+
# Configure static asset server for tests with Cache-Control for performance
|
11
|
+
config.serve_static_assets = true
|
12
|
+
config.static_cache_control = "public, max-age=3600"
|
13
|
+
|
14
|
+
config.eager_load = false if Rails::VERSION::MAJOR >= 4
|
15
|
+
|
16
|
+
# Show full error reports and disable caching
|
17
|
+
config.consider_all_requests_local = true
|
18
|
+
config.action_controller.perform_caching = false
|
19
|
+
|
20
|
+
# Raise exceptions instead of rendering exception templates
|
21
|
+
config.action_dispatch.show_exceptions = false
|
22
|
+
|
23
|
+
# Disable request forgery protection in test environment
|
24
|
+
config.action_controller.allow_forgery_protection = false
|
25
|
+
|
26
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
27
|
+
# The :test delivery method accumulates sent emails in the
|
28
|
+
# ActionMailer::Base.deliveries array.
|
29
|
+
config.action_mailer.delivery_method = :test
|
30
|
+
|
31
|
+
# Use SQL instead of Active Record's schema dumper when creating the test database.
|
32
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
33
|
+
# like if you have constraints or database-specific column types
|
34
|
+
# config.active_record.schema_format = :sql
|
35
|
+
|
36
|
+
# Print deprecation notices to the stderr
|
37
|
+
config.active_support.deprecation = :stderr
|
38
|
+
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!
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Add new inflection rules using the following format
|
4
|
+
# (all these examples are active by default):
|
5
|
+
# ActiveSupport::Inflector.inflections do |inflect|
|
6
|
+
# inflect.plural /^(ox)$/i, '\1en'
|
7
|
+
# inflect.singular /^(ox)en/i, '\1'
|
8
|
+
# inflect.irregular 'person', 'people'
|
9
|
+
# inflect.uncountable %w( fish sheep )
|
10
|
+
# 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
|
+
Dummy::Application.config.secret_token = '34d776d7b34c759d74790e5cc10edfaf610a403281e7cda53f0c25e750dc4b774d1a1a59d0ca3698e11ea260c57fcaa6c98b9aee9e62a95ffd9f7f91f21db18d'
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
Dummy::Application.config.session_store :cookie_store, :key => '_dummy_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 "rails generate session_migration")
|
8
|
+
# Dummy::Application.config.session_store :active_record_store
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
#
|
3
|
+
# This file contains settings for ActionController::ParamsWrapper which
|
4
|
+
# is enabled by default.
|
5
|
+
|
6
|
+
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
7
|
+
ActionController::Base.wrap_parameters :format => [:json] if ActionController::Base.respond_to?(:wrap_parameters)
|
8
|
+
|
9
|
+
# Disable root element in JSON by default.
|
10
|
+
if defined?(ActiveRecord)
|
11
|
+
ActiveRecord::Base.include_root_in_json = false
|
12
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
Dummy::Application.routes.draw do
|
2
|
+
resources :surveys, :only => %w(new)
|
3
|
+
get '/:controller/:action'
|
4
|
+
|
5
|
+
# The priority is based upon order of creation:
|
6
|
+
# first created -> highest priority.
|
7
|
+
|
8
|
+
# Sample of regular route:
|
9
|
+
# match 'products/:id' => 'catalog#view'
|
10
|
+
# Keep in mind you can assign values other than :controller and :action
|
11
|
+
|
12
|
+
# Sample of named route:
|
13
|
+
# match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
|
14
|
+
# This route can be invoked with purchase_url(:id => product.id)
|
15
|
+
|
16
|
+
# Sample resource route (maps HTTP verbs to controller actions automatically):
|
17
|
+
# resources :products
|
18
|
+
|
19
|
+
# Sample resource route with options:
|
20
|
+
# resources :products do
|
21
|
+
# member do
|
22
|
+
# get 'short'
|
23
|
+
# post 'toggle'
|
24
|
+
# end
|
25
|
+
#
|
26
|
+
# collection do
|
27
|
+
# get 'sold'
|
28
|
+
# end
|
29
|
+
# end
|
30
|
+
|
31
|
+
# Sample resource route with sub-resources:
|
32
|
+
# resources :products do
|
33
|
+
# resources :comments, :sales
|
34
|
+
# resource :seller
|
35
|
+
# end
|
36
|
+
|
37
|
+
# Sample resource route with more complex sub-resources
|
38
|
+
# resources :products do
|
39
|
+
# resources :comments
|
40
|
+
# resources :sales do
|
41
|
+
# get 'recent', :on => :collection
|
42
|
+
# end
|
43
|
+
# end
|
44
|
+
|
45
|
+
# Sample resource route within a namespace:
|
46
|
+
# namespace :admin do
|
47
|
+
# # Directs /admin/products/* to Admin::ProductsController
|
48
|
+
# # (app/controllers/admin/products_controller.rb)
|
49
|
+
# resources :products
|
50
|
+
# end
|
51
|
+
|
52
|
+
# You can have the root of your site routed with "root"
|
53
|
+
# just remember to delete public/index.html.
|
54
|
+
# root :to => 'welcome#index'
|
55
|
+
|
56
|
+
# See how all your routes lay out with "rake routes"
|
57
|
+
|
58
|
+
# This is a legacy wild controller route that's not recommended for RESTful applications.
|
59
|
+
# Note: This route will make all actions in every controller accessible via GET requests.
|
60
|
+
# match ':controller(/:action(/:id(.:format)))'
|
61
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class InitialTables < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :projects do |t|
|
4
|
+
t.string :name
|
5
|
+
end
|
6
|
+
|
7
|
+
create_table :tasks do |t|
|
8
|
+
t.integer :project_id
|
9
|
+
t.string :name
|
10
|
+
end
|
11
|
+
|
12
|
+
create_table :milestones do |t|
|
13
|
+
t.integer :task_id
|
14
|
+
t.string :name
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.down
|
19
|
+
drop_table :projects
|
20
|
+
drop_table :tasks
|
21
|
+
drop_table :milestones
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class CreateCompany < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :companies do |t|
|
4
|
+
t.string :name
|
5
|
+
end
|
6
|
+
|
7
|
+
add_column :projects, :company_id, :integer
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.down
|
11
|
+
remove_column :projects, :company_id
|
12
|
+
drop_table :companies
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# This file is auto-generated from the current state of the database. Instead
|
3
|
+
# of editing this file, please use the migrations feature of Active Record to
|
4
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
5
|
+
#
|
6
|
+
# Note that this schema.rb definition is the authoritative source for your
|
7
|
+
# database schema. If you need to create the application database on another
|
8
|
+
# system, you should be using db:schema:load, not running all the migrations
|
9
|
+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
10
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
11
|
+
#
|
12
|
+
# It's strongly recommended to check this file into your version control system.
|
13
|
+
|
14
|
+
ActiveRecord::Schema.define(:version => 20130203095901) do
|
15
|
+
|
16
|
+
create_table :turkee_tasks do |t|
|
17
|
+
t.string "hit_url"
|
18
|
+
t.boolean "sandbox"
|
19
|
+
t.string "task_type"
|
20
|
+
t.text "hit_title"
|
21
|
+
t.text "hit_description"
|
22
|
+
t.string "hit_id"
|
23
|
+
t.decimal "hit_reward", :precision => 10, :scale => 2
|
24
|
+
t.integer "hit_num_assignments"
|
25
|
+
t.integer "hit_lifetime"
|
26
|
+
t.string "form_url"
|
27
|
+
t.integer "completed_assignments", :default => 0
|
28
|
+
t.boolean "complete"
|
29
|
+
t.boolean "expired"
|
30
|
+
t.datetime "created_at", :null => false
|
31
|
+
t.datetime "updated_at", :null => false
|
32
|
+
t.integer "turkee_flow_id"
|
33
|
+
t.integer "hit_duration"
|
34
|
+
end
|
35
|
+
|
36
|
+
create_table :surveys do |t|
|
37
|
+
t.string :answer
|
38
|
+
end
|
39
|
+
|
40
|
+
create_table :turkee_studies do |t|
|
41
|
+
t.integer :turkee_task_id
|
42
|
+
t.string :feedback
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/404.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
23
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/422.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The change you wanted was rejected.</h1>
|
23
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/500.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>We're sorry, but something went wrong.</h1>
|
23
|
+
<p>We've been notified about this issue and we'll take a look at it shortly.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
File without changes
|
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
|
+
require 'rails/commands'
|
File without changes
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'turkee'
|
2
|
+
FactoryGirl.define do
|
3
|
+
factory :turkee_task, :class => Turkee::TurkeeTask do |s|
|
4
|
+
s.hit_url "http://workersandbox.mturk.com/mturk/preview?groupId=248SVGULF395SZ65OC6S6NYNJDXAO5"
|
5
|
+
s.sandbox true
|
6
|
+
s.task_type "TestTask"
|
7
|
+
s.hit_title "Test Title"
|
8
|
+
s.hit_description "Test Desc"
|
9
|
+
s.hit_id "123"
|
10
|
+
s.hit_reward 0.05
|
11
|
+
s.completed_assignments 0
|
12
|
+
s.hit_num_assignments 100
|
13
|
+
s.hit_lifetime 1
|
14
|
+
s.hit_duration 1
|
15
|
+
s.form_url "http://localhost/test_task/new"
|
16
|
+
s.complete false
|
17
|
+
s.expired false
|
18
|
+
s.created_at Time.now
|
19
|
+
s.updated_at Time.now
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Turkee::TurkeeFormHelper, :type => :helper do
|
4
|
+
describe "mturk_url" do
|
5
|
+
it "should return sandbox" do
|
6
|
+
RTurk.stub(:sandbox?).and_return true
|
7
|
+
mturk_url.should match /workersandbox.mturk.com/
|
8
|
+
end
|
9
|
+
it "should return production url" do
|
10
|
+
RTurk.stub(:sandbox?).and_return false
|
11
|
+
mturk_url.should match /www.mturk.com/
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "turkee_study" do
|
16
|
+
before do
|
17
|
+
@task = create(:turkee_task)
|
18
|
+
RTurk.stub(:sandbox?).and_return true
|
19
|
+
|
20
|
+
helper.stub(:params).and_return({:assignmentId => '123456', :workerId => '987654'})
|
21
|
+
@study_form = helper.turkee_study
|
22
|
+
end
|
23
|
+
|
24
|
+
it "includes the description, textarea" do
|
25
|
+
@study_form.should match(/Test Desc/)
|
26
|
+
@study_form.should match(/feedback/)
|
27
|
+
@study_form.should match(/textarea/)
|
28
|
+
@study_form.should match(/workersandbox.mturk.com/)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "the form points to the sandbox" do
|
32
|
+
@study_form = turkee_study
|
33
|
+
@study_form.should match(/workersandbox.mturk.com/)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "still includes the necessary assignmentId and workerId" do
|
37
|
+
@study_form.should match(/assignmentId/)
|
38
|
+
@study_form.should match(/workerId/)
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "turkee_form_for" do
|
44
|
+
before do
|
45
|
+
@survey = create(:survey)
|
46
|
+
RTurk.stub(:sandbox?).and_return true
|
47
|
+
|
48
|
+
params = {:assignmentId => '123456', :workerId => '987654'}
|
49
|
+
@survey_form = helper.turkee_form_for(@survey, params) do |f|
|
50
|
+
f.text_field :answer
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
it "displays the passed in assignmentId and workerId " do
|
55
|
+
@survey_form.should match(/answer/)
|
56
|
+
@survey_form.should match(/type=\"text\"/)
|
57
|
+
@survey_form.should match(/assignmentId/)
|
58
|
+
@survey_form.should match(/workerId/)
|
59
|
+
end
|
60
|
+
|
61
|
+
it "the intial turkee_form_for saved the assignmentId and workerId to a cookie for later retrieval" do
|
62
|
+
helper.cookies['assignmentId'].should == '123456'
|
63
|
+
helper.cookies['workerId'].should == '987654'
|
64
|
+
|
65
|
+
# Subsequent requests should still return form fields for assignmentId
|
66
|
+
survey_form = helper.turkee_form_for(@survey, {}) do |f|
|
67
|
+
f.text_field :answer
|
68
|
+
end
|
69
|
+
survey_form.should match(/123456/)
|
70
|
+
survey_form.should match(/987654/)
|
71
|
+
survey_form.should match(/assignmentId/)
|
72
|
+
survey_form.should match(/workerId/)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Turkee::TurkeeStudy do
|
4
|
+
|
5
|
+
describe "approve?" do
|
6
|
+
before do
|
7
|
+
@study = Turkee::TurkeeStudy.new(:feedback => "I really loved the site. I will tell my mom about it.",
|
8
|
+
:gold_response => 'the')
|
9
|
+
end
|
10
|
+
it "approves the task" do
|
11
|
+
@study.approve?.should be_true
|
12
|
+
end
|
13
|
+
|
14
|
+
it "rejects the task" do
|
15
|
+
@study.gold_response = "loved"
|
16
|
+
@study.approve?.should be_false
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|