fassets_core 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/MIT-LICENSE +21 -0
- data/README.md +22 -0
- data/Rakefile +39 -0
- data/app/assets/images/fassets_core/add.png +0 -0
- data/app/assets/images/fassets_core/archive.png +0 -0
- data/app/assets/images/fassets_core/classify.png +0 -0
- data/app/assets/images/fassets_core/clipboard.png +0 -0
- data/app/assets/images/fassets_core/collapse.png +0 -0
- data/app/assets/images/fassets_core/collapsed.png +0 -0
- data/app/assets/images/fassets_core/delete.png +0 -0
- data/app/assets/images/fassets_core/drag.png +0 -0
- data/app/assets/images/fassets_core/edit.png +0 -0
- data/app/assets/images/fassets_core/link.png +0 -0
- data/app/assets/images/fassets_core/markup_preview.png +0 -0
- data/app/assets/images/fassets_core/remove.png +0 -0
- data/app/assets/images/fassets_core/sort.png +0 -0
- data/app/assets/images/fassets_core/warning.png +0 -0
- data/app/assets/javascripts/fassets_core/add_asset_box.js +102 -0
- data/app/assets/javascripts/fassets_core/application.js.erb +14 -0
- data/app/assets/javascripts/fassets_core/assets.js +31 -0
- data/app/assets/javascripts/fassets_core/catalog_box.js +73 -0
- data/app/assets/javascripts/fassets_core/catalogs.js +46 -0
- data/app/assets/javascripts/fassets_core/classification.js +37 -0
- data/app/assets/javascripts/fassets_core/edit_box.js +63 -0
- data/app/assets/javascripts/fassets_core/facets.js.erb +32 -0
- data/app/assets/javascripts/fassets_core/tray.js +30 -0
- data/app/assets/stylesheets/fassets_core/add_asset_box.css.scss +77 -0
- data/app/assets/stylesheets/fassets_core/application.css +16 -0
- data/app/assets/stylesheets/fassets_core/assets.css.scss +74 -0
- data/app/assets/stylesheets/fassets_core/catalog_box.css.scss +45 -0
- data/app/assets/stylesheets/fassets_core/collapsible.css.scss +54 -0
- data/app/assets/stylesheets/fassets_core/edit_box.css.scss +58 -0
- data/app/assets/stylesheets/fassets_core/facet.css.scss +56 -0
- data/app/assets/stylesheets/fassets_core/filter.css.scss +20 -0
- data/app/assets/stylesheets/fassets_core/forms.css.scss +12 -0
- data/app/assets/stylesheets/fassets_core/labels.css.scss +13 -0
- data/app/assets/stylesheets/fassets_core/master.css.scss +127 -0
- data/app/assets/stylesheets/fassets_core/sidebar.css.scss +84 -0
- data/app/assets/stylesheets/fassets_core/tray.css.scss +106 -0
- data/app/controllers/assets_controller.rb +115 -0
- data/app/controllers/catalogs_controller.rb +99 -0
- data/app/controllers/classifications_controller.rb +56 -0
- data/app/controllers/facets_controller.rb +57 -0
- data/app/controllers/fassets_core/application_controller.rb +5 -0
- data/app/controllers/labels_controller.rb +54 -0
- data/app/controllers/tray_positions_controller.rb +81 -0
- data/app/helpers/assets_helper.rb +20 -0
- data/app/helpers/catalogs_helper.rb +3 -0
- data/app/helpers/classifications_helper.rb +8 -0
- data/app/helpers/fassets_core/application_helper.rb +48 -0
- data/app/helpers/labels_helper.rb +3 -0
- data/app/helpers/tray_positions_helper.rb +3 -0
- data/app/models/asset.rb +52 -0
- data/app/models/catalog.rb +16 -0
- data/app/models/classification.rb +8 -0
- data/app/models/facet.rb +19 -0
- data/app/models/label.rb +11 -0
- data/app/models/label_filter.rb +16 -0
- data/app/models/labeling.rb +5 -0
- data/app/models/tray_position.rb +9 -0
- data/app/views/assets/_add_asset_sidebar.html.haml +8 -0
- data/app/views/assets/_classification.html.haml +33 -0
- data/app/views/assets/_form.html.haml +30 -0
- data/app/views/assets/_put_on_tray.html.haml +7 -0
- data/app/views/assets/edit.html.haml +15 -0
- data/app/views/assets/new.html.haml +25 -0
- data/app/views/assets/show.html.haml +13 -0
- data/app/views/catalogs/_box_catalog_list.html.haml +6 -0
- data/app/views/catalogs/_box_content.html.haml +13 -0
- data/app/views/catalogs/_catalog.html.haml +2 -0
- data/app/views/catalogs/_facet.html.haml +13 -0
- data/app/views/catalogs/_filter_item.html.haml +3 -0
- data/app/views/catalogs/_form.html.haml +6 -0
- data/app/views/catalogs/box.html.haml +6 -0
- data/app/views/catalogs/edit.html.haml +8 -0
- data/app/views/catalogs/index.html.haml +17 -0
- data/app/views/catalogs/new.html.haml +8 -0
- data/app/views/catalogs/show.html.haml +30 -0
- data/app/views/classifications/update.js.erb +4 -0
- data/app/views/facets/_form.html.haml +9 -0
- data/app/views/facets/edit.html.haml +15 -0
- data/app/views/labels/_form.haml +3 -0
- data/app/views/labels/_sidebar.html.haml +22 -0
- data/app/views/labels/destroy.js.erb +13 -0
- data/app/views/layouts/fassets_core/application.html.haml +16 -0
- data/app/views/shared/_asset.html.haml +22 -0
- data/app/views/shared/_asset_form.html.haml +7 -0
- data/app/views/shared/_classification.html.haml +23 -0
- data/app/views/shared/_clipboard.html.haml +10 -0
- data/app/views/shared/_error.html.haml +6 -0
- data/app/views/shared/_tray.html.haml +13 -0
- data/app/views/shared/_tray_position.html.haml +8 -0
- data/app/views/tray_positions/create.js.rjs +10 -0
- data/app/views/tray_positions/destroy.js.rjs +1 -0
- data/app/views/tray_positions/sort.js.rjs +15 -0
- data/config/initializers/mime_types.rb +2 -0
- data/config/initializers/uploader.rb +2 -0
- data/config/initializers/users.rb +7 -0
- data/config/routes.rb +34 -0
- data/db/migrate/001_create_catalogs.rb +13 -0
- data/db/migrate/002_create_facets.rb +14 -0
- data/db/migrate/003_create_labels.rb +12 -0
- data/db/migrate/005_create_classifications.rb +12 -0
- data/db/migrate/006_create_labelings.rb +12 -0
- data/db/migrate/007_create_tray_positions.rb +13 -0
- data/db/migrate/008_create_assets.rb +16 -0
- data/db/migrate/010_add_label_ordering.rb +10 -0
- data/db/migrate/017_add_clipboard.rb +11 -0
- data/db/migrate/20120803150826_add_position_to_facet.rb +5 -0
- data/db/schema.rb +141 -0
- data/db/seeds.rb +7 -0
- data/lib/acts_as_asset.rb +36 -0
- data/lib/authenticated_system.rb +187 -0
- data/lib/authenticated_test_helper.rb +20 -0
- data/lib/fassets_core.rb +6 -0
- data/lib/fassets_core/engine.rb +7 -0
- data/lib/fassets_core/plugins.rb +13 -0
- data/lib/fassets_core/test_helper.rb +3 -0
- data/lib/fassets_core/test_helper/every_assets_controller.rb +161 -0
- data/lib/fassets_core/test_helper/every_authenticated_controller.rb +10 -0
- data/lib/fassets_core/version.rb +3 -0
- data/lib/tasks/cucumber.rake +57 -0
- data/lib/tasks/fassets-core_tasks.rake +4 -0
- data/lib/template_manager.rb +27 -0
- data/test/fassets-core_test.rb +7 -0
- data/test/fixtures/asset_contents.yml +7 -0
- data/test/fixtures/assets.yml +7 -0
- data/test/fixtures/catalogs.yml +9 -0
- data/test/fixtures/classifications.yml +7 -0
- data/test/fixtures/facets.yml +9 -0
- data/test/fixtures/frames.yml +11 -0
- data/test/fixtures/image_assets.yml +7 -0
- data/test/fixtures/labellings.yml +7 -0
- data/test/fixtures/labels.yml +9 -0
- data/test/fixtures/presentations.yml +7 -0
- data/test/fixtures/slides.yml +11 -0
- data/test/fixtures/slots.yml +0 -0
- data/test/fixtures/topics.yml +11 -0
- data/test/fixtures/tray_positions.yml +7 -0
- data/test/fixtures/users.yml +31 -0
- data/test/functional/assets_controller_test.rb +8 -0
- data/test/functional/catalogs_controller_test.rb +8 -0
- data/test/functional/classifications_controller_test.rb +8 -0
- data/test/functional/content_controller_test.rb +8 -0
- data/test/functional/facets_controller_test.rb +8 -0
- data/test/functional/file_assets_controller_test.rb +8 -0
- data/test/functional/files_controller_test.rb +8 -0
- data/test/functional/labellings_controller_test.rb +8 -0
- data/test/functional/labels_controller_test.rb +8 -0
- data/test/functional/presentations_controller_test.rb +8 -0
- data/test/functional/sessions_controller_test.rb +82 -0
- data/test/functional/slides_controller_test.rb +8 -0
- data/test/functional/slots_controller_test.rb +8 -0
- data/test/functional/tray_positions_controller_test.rb +8 -0
- data/test/functional/urls_controller_test.rb +8 -0
- data/test/functional/users_controller_test.rb +58 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/performance/browsing_test.rb +9 -0
- data/test/test_helper.rb +10 -0
- data/test/unit/asset_content_test.rb +8 -0
- data/test/unit/asset_test.rb +8 -0
- data/test/unit/catalog_test.rb +8 -0
- data/test/unit/classification_test.rb +8 -0
- data/test/unit/facet_test.rb +8 -0
- data/test/unit/frame_test.rb +8 -0
- data/test/unit/image_asset_test.rb +8 -0
- data/test/unit/label_test.rb +8 -0
- data/test/unit/labelling_test.rb +8 -0
- data/test/unit/presentation_test.rb +8 -0
- data/test/unit/slide_test.rb +8 -0
- data/test/unit/slot_test.rb +8 -0
- data/test/unit/topic_test.rb +8 -0
- data/test/unit/tray_position_test.rb +8 -0
- data/test/unit/user_test.rb +103 -0
- 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,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,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,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
|
|
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,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,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
|