fassets_core 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. data/MIT-LICENSE +21 -0
  2. data/README.md +22 -0
  3. data/Rakefile +39 -0
  4. data/app/assets/images/fassets_core/add.png +0 -0
  5. data/app/assets/images/fassets_core/archive.png +0 -0
  6. data/app/assets/images/fassets_core/classify.png +0 -0
  7. data/app/assets/images/fassets_core/clipboard.png +0 -0
  8. data/app/assets/images/fassets_core/collapse.png +0 -0
  9. data/app/assets/images/fassets_core/collapsed.png +0 -0
  10. data/app/assets/images/fassets_core/delete.png +0 -0
  11. data/app/assets/images/fassets_core/drag.png +0 -0
  12. data/app/assets/images/fassets_core/edit.png +0 -0
  13. data/app/assets/images/fassets_core/link.png +0 -0
  14. data/app/assets/images/fassets_core/markup_preview.png +0 -0
  15. data/app/assets/images/fassets_core/remove.png +0 -0
  16. data/app/assets/images/fassets_core/sort.png +0 -0
  17. data/app/assets/images/fassets_core/warning.png +0 -0
  18. data/app/assets/javascripts/fassets_core/add_asset_box.js +102 -0
  19. data/app/assets/javascripts/fassets_core/application.js.erb +14 -0
  20. data/app/assets/javascripts/fassets_core/assets.js +31 -0
  21. data/app/assets/javascripts/fassets_core/catalog_box.js +73 -0
  22. data/app/assets/javascripts/fassets_core/catalogs.js +46 -0
  23. data/app/assets/javascripts/fassets_core/classification.js +37 -0
  24. data/app/assets/javascripts/fassets_core/edit_box.js +63 -0
  25. data/app/assets/javascripts/fassets_core/facets.js.erb +32 -0
  26. data/app/assets/javascripts/fassets_core/tray.js +30 -0
  27. data/app/assets/stylesheets/fassets_core/add_asset_box.css.scss +77 -0
  28. data/app/assets/stylesheets/fassets_core/application.css +16 -0
  29. data/app/assets/stylesheets/fassets_core/assets.css.scss +74 -0
  30. data/app/assets/stylesheets/fassets_core/catalog_box.css.scss +45 -0
  31. data/app/assets/stylesheets/fassets_core/collapsible.css.scss +54 -0
  32. data/app/assets/stylesheets/fassets_core/edit_box.css.scss +58 -0
  33. data/app/assets/stylesheets/fassets_core/facet.css.scss +56 -0
  34. data/app/assets/stylesheets/fassets_core/filter.css.scss +20 -0
  35. data/app/assets/stylesheets/fassets_core/forms.css.scss +12 -0
  36. data/app/assets/stylesheets/fassets_core/labels.css.scss +13 -0
  37. data/app/assets/stylesheets/fassets_core/master.css.scss +127 -0
  38. data/app/assets/stylesheets/fassets_core/sidebar.css.scss +84 -0
  39. data/app/assets/stylesheets/fassets_core/tray.css.scss +106 -0
  40. data/app/controllers/assets_controller.rb +115 -0
  41. data/app/controllers/catalogs_controller.rb +99 -0
  42. data/app/controllers/classifications_controller.rb +56 -0
  43. data/app/controllers/facets_controller.rb +57 -0
  44. data/app/controllers/fassets_core/application_controller.rb +5 -0
  45. data/app/controllers/labels_controller.rb +54 -0
  46. data/app/controllers/tray_positions_controller.rb +81 -0
  47. data/app/helpers/assets_helper.rb +20 -0
  48. data/app/helpers/catalogs_helper.rb +3 -0
  49. data/app/helpers/classifications_helper.rb +8 -0
  50. data/app/helpers/fassets_core/application_helper.rb +48 -0
  51. data/app/helpers/labels_helper.rb +3 -0
  52. data/app/helpers/tray_positions_helper.rb +3 -0
  53. data/app/models/asset.rb +52 -0
  54. data/app/models/catalog.rb +16 -0
  55. data/app/models/classification.rb +8 -0
  56. data/app/models/facet.rb +19 -0
  57. data/app/models/label.rb +11 -0
  58. data/app/models/label_filter.rb +16 -0
  59. data/app/models/labeling.rb +5 -0
  60. data/app/models/tray_position.rb +9 -0
  61. data/app/views/assets/_add_asset_sidebar.html.haml +8 -0
  62. data/app/views/assets/_classification.html.haml +33 -0
  63. data/app/views/assets/_form.html.haml +30 -0
  64. data/app/views/assets/_put_on_tray.html.haml +7 -0
  65. data/app/views/assets/edit.html.haml +15 -0
  66. data/app/views/assets/new.html.haml +25 -0
  67. data/app/views/assets/show.html.haml +13 -0
  68. data/app/views/catalogs/_box_catalog_list.html.haml +6 -0
  69. data/app/views/catalogs/_box_content.html.haml +13 -0
  70. data/app/views/catalogs/_catalog.html.haml +2 -0
  71. data/app/views/catalogs/_facet.html.haml +13 -0
  72. data/app/views/catalogs/_filter_item.html.haml +3 -0
  73. data/app/views/catalogs/_form.html.haml +6 -0
  74. data/app/views/catalogs/box.html.haml +6 -0
  75. data/app/views/catalogs/edit.html.haml +8 -0
  76. data/app/views/catalogs/index.html.haml +17 -0
  77. data/app/views/catalogs/new.html.haml +8 -0
  78. data/app/views/catalogs/show.html.haml +30 -0
  79. data/app/views/classifications/update.js.erb +4 -0
  80. data/app/views/facets/_form.html.haml +9 -0
  81. data/app/views/facets/edit.html.haml +15 -0
  82. data/app/views/labels/_form.haml +3 -0
  83. data/app/views/labels/_sidebar.html.haml +22 -0
  84. data/app/views/labels/destroy.js.erb +13 -0
  85. data/app/views/layouts/fassets_core/application.html.haml +16 -0
  86. data/app/views/shared/_asset.html.haml +22 -0
  87. data/app/views/shared/_asset_form.html.haml +7 -0
  88. data/app/views/shared/_classification.html.haml +23 -0
  89. data/app/views/shared/_clipboard.html.haml +10 -0
  90. data/app/views/shared/_error.html.haml +6 -0
  91. data/app/views/shared/_tray.html.haml +13 -0
  92. data/app/views/shared/_tray_position.html.haml +8 -0
  93. data/app/views/tray_positions/create.js.rjs +10 -0
  94. data/app/views/tray_positions/destroy.js.rjs +1 -0
  95. data/app/views/tray_positions/sort.js.rjs +15 -0
  96. data/config/initializers/mime_types.rb +2 -0
  97. data/config/initializers/uploader.rb +2 -0
  98. data/config/initializers/users.rb +7 -0
  99. data/config/routes.rb +34 -0
  100. data/db/migrate/001_create_catalogs.rb +13 -0
  101. data/db/migrate/002_create_facets.rb +14 -0
  102. data/db/migrate/003_create_labels.rb +12 -0
  103. data/db/migrate/005_create_classifications.rb +12 -0
  104. data/db/migrate/006_create_labelings.rb +12 -0
  105. data/db/migrate/007_create_tray_positions.rb +13 -0
  106. data/db/migrate/008_create_assets.rb +16 -0
  107. data/db/migrate/010_add_label_ordering.rb +10 -0
  108. data/db/migrate/017_add_clipboard.rb +11 -0
  109. data/db/migrate/20120803150826_add_position_to_facet.rb +5 -0
  110. data/db/schema.rb +141 -0
  111. data/db/seeds.rb +7 -0
  112. data/lib/acts_as_asset.rb +36 -0
  113. data/lib/authenticated_system.rb +187 -0
  114. data/lib/authenticated_test_helper.rb +20 -0
  115. data/lib/fassets_core.rb +6 -0
  116. data/lib/fassets_core/engine.rb +7 -0
  117. data/lib/fassets_core/plugins.rb +13 -0
  118. data/lib/fassets_core/test_helper.rb +3 -0
  119. data/lib/fassets_core/test_helper/every_assets_controller.rb +161 -0
  120. data/lib/fassets_core/test_helper/every_authenticated_controller.rb +10 -0
  121. data/lib/fassets_core/version.rb +3 -0
  122. data/lib/tasks/cucumber.rake +57 -0
  123. data/lib/tasks/fassets-core_tasks.rake +4 -0
  124. data/lib/template_manager.rb +27 -0
  125. data/test/fassets-core_test.rb +7 -0
  126. data/test/fixtures/asset_contents.yml +7 -0
  127. data/test/fixtures/assets.yml +7 -0
  128. data/test/fixtures/catalogs.yml +9 -0
  129. data/test/fixtures/classifications.yml +7 -0
  130. data/test/fixtures/facets.yml +9 -0
  131. data/test/fixtures/frames.yml +11 -0
  132. data/test/fixtures/image_assets.yml +7 -0
  133. data/test/fixtures/labellings.yml +7 -0
  134. data/test/fixtures/labels.yml +9 -0
  135. data/test/fixtures/presentations.yml +7 -0
  136. data/test/fixtures/slides.yml +11 -0
  137. data/test/fixtures/slots.yml +0 -0
  138. data/test/fixtures/topics.yml +11 -0
  139. data/test/fixtures/tray_positions.yml +7 -0
  140. data/test/fixtures/users.yml +31 -0
  141. data/test/functional/assets_controller_test.rb +8 -0
  142. data/test/functional/catalogs_controller_test.rb +8 -0
  143. data/test/functional/classifications_controller_test.rb +8 -0
  144. data/test/functional/content_controller_test.rb +8 -0
  145. data/test/functional/facets_controller_test.rb +8 -0
  146. data/test/functional/file_assets_controller_test.rb +8 -0
  147. data/test/functional/files_controller_test.rb +8 -0
  148. data/test/functional/labellings_controller_test.rb +8 -0
  149. data/test/functional/labels_controller_test.rb +8 -0
  150. data/test/functional/presentations_controller_test.rb +8 -0
  151. data/test/functional/sessions_controller_test.rb +82 -0
  152. data/test/functional/slides_controller_test.rb +8 -0
  153. data/test/functional/slots_controller_test.rb +8 -0
  154. data/test/functional/tray_positions_controller_test.rb +8 -0
  155. data/test/functional/urls_controller_test.rb +8 -0
  156. data/test/functional/users_controller_test.rb +58 -0
  157. data/test/integration/navigation_test.rb +10 -0
  158. data/test/performance/browsing_test.rb +9 -0
  159. data/test/test_helper.rb +10 -0
  160. data/test/unit/asset_content_test.rb +8 -0
  161. data/test/unit/asset_test.rb +8 -0
  162. data/test/unit/catalog_test.rb +8 -0
  163. data/test/unit/classification_test.rb +8 -0
  164. data/test/unit/facet_test.rb +8 -0
  165. data/test/unit/frame_test.rb +8 -0
  166. data/test/unit/image_asset_test.rb +8 -0
  167. data/test/unit/label_test.rb +8 -0
  168. data/test/unit/labelling_test.rb +8 -0
  169. data/test/unit/presentation_test.rb +8 -0
  170. data/test/unit/slide_test.rb +8 -0
  171. data/test/unit/slot_test.rb +8 -0
  172. data/test/unit/topic_test.rb +8 -0
  173. data/test/unit/tray_position_test.rb +8 -0
  174. data/test/unit/user_test.rb +103 -0
  175. metadata +453 -0
@@ -0,0 +1,10 @@
1
+ shared_examples_for "every authenticated controller" do
2
+ def mock_user(stubs={})
3
+ @mock_user ||= mock_model(User, stubs).as_null_object
4
+ end
5
+ before(:each) do
6
+ # mock up an authentication in the underlying warden library
7
+ request.env['warden'] = mock(Warden, :authenticate => mock_user,
8
+ :authenticate! => mock_user)
9
+ end
10
+ end
@@ -0,0 +1,3 @@
1
+ module FassetsCore
2
+ VERSION = "0.2.0"
3
+ end
@@ -0,0 +1,57 @@
1
+ # IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
2
+ # It is recommended to regenerate this file in the future when you upgrade to a
3
+ # newer version of cucumber-rails. Consider adding your own code to a new file
4
+ # instead of editing this one. Cucumber will automatically load all features/**/*.rb
5
+ # files.
6
+
7
+
8
+ unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks
9
+
10
+ vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
11
+ $LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil?
12
+
13
+ begin
14
+ require 'cucumber/rake/task'
15
+
16
+ namespace :cucumber do
17
+ Cucumber::Rake::Task.new({:ok => 'db:test:prepare'}, 'Run features that should pass') do |t|
18
+ t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
19
+ t.fork = true # You may get faster startup if you set this to false
20
+ t.profile = 'default'
21
+ end
22
+
23
+ Cucumber::Rake::Task.new({:wip => 'db:test:prepare'}, 'Run features that are being worked on') do |t|
24
+ t.binary = vendored_cucumber_bin
25
+ t.fork = true # You may get faster startup if you set this to false
26
+ t.profile = 'wip'
27
+ end
28
+
29
+ Cucumber::Rake::Task.new({:rerun => 'db:test:prepare'}, 'Record failing features and run only them if any exist') do |t|
30
+ t.binary = vendored_cucumber_bin
31
+ t.fork = true # You may get faster startup if you set this to false
32
+ t.profile = 'rerun'
33
+ end
34
+
35
+ desc 'Run all features'
36
+ task :all => [:ok, :wip]
37
+ end
38
+ desc 'Alias for cucumber:ok'
39
+ task :cucumber => 'cucumber:ok'
40
+
41
+ task :default => :cucumber
42
+
43
+ task :features => :cucumber do
44
+ STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
45
+ end
46
+
47
+ # In case we don't have ActiveRecord, append a no-op task that we can depend upon.
48
+ task 'db:test:prepare' do
49
+ end
50
+ rescue LoadError
51
+ desc 'cucumber rake task not available (cucumber not installed)'
52
+ task :cucumber do
53
+ abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
54
+ end
55
+ end
56
+
57
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :fassets-core do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,27 @@
1
+ module TemplateManager
2
+ extend self
3
+
4
+ def outer_templates
5
+ templates.keys
6
+ end
7
+ def inner_templates(outer)
8
+ templates[outer].keys
9
+ end
10
+ def inner_template(outer, name)
11
+ templates[outer][name]
12
+ end
13
+ private
14
+ def templates
15
+ Dir.chdir(TEMPLATE_PATH) do
16
+ @templates ||= Dir.entries(".").inject({}) do |templates, entry|
17
+ yml_path = File.join(entry, "template.yml")
18
+ if entry != '.' &&
19
+ entry != '..' &&
20
+ File.exists?(yml_path)
21
+ templates[entry] = YAML.load_file(yml_path)
22
+ end
23
+ templates
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class FassetsCoreTest < ActiveSupport::TestCase
4
+ test "truth" do
5
+ assert_kind_of Module, FassetsCore
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
+
3
+ # one:
4
+ # column: value
5
+ #
6
+ # two:
7
+ # column: value
@@ -0,0 +1,7 @@
1
+ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
+
3
+ # one:
4
+ # column: value
5
+ #
6
+ # two:
7
+ # column: value
@@ -0,0 +1,9 @@
1
+ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
+
3
+ one:
4
+ title: MyString
5
+ info: MyText
6
+
7
+ two:
8
+ title: MyString
9
+ info: MyText
@@ -0,0 +1,7 @@
1
+ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
+
3
+ # one:
4
+ # column: value
5
+ #
6
+ # two:
7
+ # column: value
@@ -0,0 +1,9 @@
1
+ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
+
3
+ one:
4
+ caption: MyString
5
+ domain_id: 1
6
+
7
+ two:
8
+ caption: MyString
9
+ domain_id: 1
@@ -0,0 +1,11 @@
1
+ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
+
3
+ # This model initially had no columns defined. If you add columns to the
4
+ # model remove the '{}' from the fixture names and add the columns immediately
5
+ # below each fixture, per the syntax in the comments below
6
+ #
7
+ one: {}
8
+ # column: value
9
+ #
10
+ two: {}
11
+ # column: value
@@ -0,0 +1,7 @@
1
+ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
+
3
+ # one:
4
+ # column: value
5
+ #
6
+ # two:
7
+ # column: value
@@ -0,0 +1,7 @@
1
+ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
+
3
+ # one:
4
+ # column: value
5
+ #
6
+ # two:
7
+ # column: value
@@ -0,0 +1,9 @@
1
+ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
+
3
+ one:
4
+ caption: MyString
5
+ facet_id: 1
6
+
7
+ two:
8
+ caption: MyString
9
+ facet_id: 1
@@ -0,0 +1,7 @@
1
+ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
+
3
+ one:
4
+ string:
5
+
6
+ two:
7
+ string:
@@ -0,0 +1,11 @@
1
+ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
+
3
+ one:
4
+ string:
5
+ string:
6
+ integer:
7
+
8
+ two:
9
+ string:
10
+ string:
11
+ integer:
File without changes
@@ -0,0 +1,11 @@
1
+ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
+
3
+ # This model initially had no columns defined. If you add columns to the
4
+ # model remove the '{}' from the fixture names and add the columns immediately
5
+ # below each fixture, per the syntax in the comments below
6
+ #
7
+ one: {}
8
+ # column: value
9
+ #
10
+ two: {}
11
+ # column: value
@@ -0,0 +1,7 @@
1
+ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
+
3
+ # one:
4
+ # column: value
5
+ #
6
+ # two:
7
+ # column: value
@@ -0,0 +1,31 @@
1
+
2
+ quentin:
3
+ id: 1
4
+ login: quentin
5
+ email: quentin@example.com
6
+ salt: 356a192b7913b04c54574d18c28d46e6395428ab # SHA1('0')
7
+ crypted_password: ebbca7d0032ebeda0ae8b605e3393345b489e2ae # 'monkey'
8
+ created_at: <%= 5.days.ago.to_s :db %>
9
+ remember_token_expires_at: <%= 1.days.from_now.to_s %>
10
+ remember_token: 77de68daecd823babbb58edb1c8e14d7106e83bb
11
+
12
+ aaron:
13
+ id: 2
14
+ login: aaron
15
+ email: aaron@example.com
16
+ salt: da4b9237bacccdf19c0760cab7aec4a8359010b0 # SHA1('1')
17
+ crypted_password: 755050623245521dc891adc8bedd951a9b59324f # 'monkey'
18
+ created_at: <%= 1.days.ago.to_s :db %>
19
+ remember_token_expires_at:
20
+ remember_token:
21
+
22
+
23
+ old_password_holder:
24
+ id: 3
25
+ login: old_password_holder
26
+ email: salty_dog@example.com
27
+ salt: 7e3041ebc2fc05a40c60028e2c4901a81035d3cd
28
+ crypted_password: 00742970dc9e6319f8019fd54864d3ea740f04b1 # test
29
+ created_at: <%= 1.days.ago.to_s :db %>
30
+
31
+
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+
3
+ class AssetsControllerTest < ActionController::TestCase
4
+ # Replace this with your real tests.
5
+ def test_truth
6
+ assert true
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+
3
+ class CatalogsControllerTest < ActionController::TestCase
4
+ # Replace this with your real tests.
5
+ def test_truth
6
+ assert true
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+
3
+ class ClassificationsControllerTest < ActionController::TestCase
4
+ # Replace this with your real tests.
5
+ def test_truth
6
+ assert true
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+
3
+ class ContentControllerTest < ActionController::TestCase
4
+ # Replace this with your real tests.
5
+ def test_truth
6
+ assert true
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+
3
+ class FacetsControllerTest < ActionController::TestCase
4
+ # Replace this with your real tests.
5
+ def test_truth
6
+ assert true
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+
3
+ class FileAssetsControllerTest < ActionController::TestCase
4
+ # Replace this with your real tests.
5
+ def test_truth
6
+ assert true
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+
3
+ class FilesControllerTest < ActionController::TestCase
4
+ # Replace this with your real tests.
5
+ def test_truth
6
+ assert true
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+
3
+ class LabellingsControllerTest < ActionController::TestCase
4
+ # Replace this with your real tests.
5
+ def test_truth
6
+ assert true
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+
3
+ class LabelsControllerTest < ActionController::TestCase
4
+ # Replace this with your real tests.
5
+ def test_truth
6
+ assert true
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+
3
+ class PresentationsControllerTest < ActionController::TestCase
4
+ # Replace this with your real tests.
5
+ def test_truth
6
+ assert true
7
+ end
8
+ end
@@ -0,0 +1,82 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+ require 'sessions_controller'
3
+
4
+ # Re-raise errors caught by the controller.
5
+ class SessionsController; def rescue_action(e) raise e end; end
6
+
7
+ class SessionsControllerTest < ActionController::TestCase
8
+ # Be sure to include AuthenticatedTestHelper in test/test_helper.rb instead
9
+ # Then, you can remove it from this and the units test.
10
+ include AuthenticatedTestHelper
11
+
12
+ fixtures :users
13
+
14
+ def test_should_login_and_redirect
15
+ post :create, :login => 'quentin', :password => 'monkey'
16
+ assert session[:user_id]
17
+ assert_response :redirect
18
+ end
19
+
20
+ def test_should_fail_login_and_not_redirect
21
+ post :create, :login => 'quentin', :password => 'bad password'
22
+ assert_nil session[:user_id]
23
+ assert_response :success
24
+ end
25
+
26
+ def test_should_logout
27
+ login_as :quentin
28
+ get :destroy
29
+ assert_nil session[:user_id]
30
+ assert_response :redirect
31
+ end
32
+
33
+ def test_should_remember_me
34
+ @request.cookies["auth_token"] = nil
35
+ post :create, :login => 'quentin', :password => 'monkey', :remember_me => "1"
36
+ assert_not_nil @response.cookies["auth_token"]
37
+ end
38
+
39
+ def test_should_not_remember_me
40
+ @request.cookies["auth_token"] = nil
41
+ post :create, :login => 'quentin', :password => 'monkey', :remember_me => "0"
42
+ puts @response.cookies["auth_token"]
43
+ assert @response.cookies["auth_token"].blank?
44
+ end
45
+
46
+ def test_should_delete_token_on_logout
47
+ login_as :quentin
48
+ get :destroy
49
+ assert @response.cookies["auth_token"].blank?
50
+ end
51
+
52
+ def test_should_login_with_cookie
53
+ users(:quentin).remember_me
54
+ @request.cookies["auth_token"] = cookie_for(:quentin)
55
+ get :new
56
+ assert @controller.send(:user_signed_in?)
57
+ end
58
+
59
+ def test_should_fail_expired_cookie_login
60
+ users(:quentin).remember_me
61
+ users(:quentin).update_attribute :remember_token_expires_at, 5.minutes.ago
62
+ @request.cookies["auth_token"] = cookie_for(:quentin)
63
+ get :new
64
+ assert !@controller.send(:user_signed_in?)
65
+ end
66
+
67
+ def test_should_fail_cookie_login
68
+ users(:quentin).remember_me
69
+ @request.cookies["auth_token"] = auth_token('invalid_auth_token')
70
+ get :new
71
+ assert !@controller.send(:user_signed_in?)
72
+ end
73
+
74
+ protected
75
+ def auth_token(token)
76
+ CGI::Cookie.new('name' => 'auth_token', 'value' => token)
77
+ end
78
+
79
+ def cookie_for(user)
80
+ auth_token users(user).remember_token
81
+ end
82
+ end