vkhater-social_stream-documents 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +15 -0
- data/.rspec +1 -0
- data/Gemfile +5 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +6 -0
- data/Rakefile +26 -0
- data/app/assets/flash/Jplayer.swf +0 -0
- data/app/assets/images/16/audio.png +0 -0
- data/app/assets/images/16/btn_documents.png +0 -0
- data/app/assets/images/16/default.png +0 -0
- data/app/assets/images/16/doc.png +0 -0
- data/app/assets/images/16/mpeg.png +0 -0
- data/app/assets/images/16/pdf.png +0 -0
- data/app/assets/images/16/photo.png +0 -0
- data/app/assets/images/16/plain.png +0 -0
- data/app/assets/images/16/ppt.png +0 -0
- data/app/assets/images/16/rar.png +0 -0
- data/app/assets/images/16/video.png +0 -0
- data/app/assets/images/16/xls.png +0 -0
- data/app/assets/images/16/zip.png +0 -0
- data/app/assets/images/48/audio.png +0 -0
- data/app/assets/images/48/default.png +0 -0
- data/app/assets/images/48/excel.png +0 -0
- data/app/assets/images/48/mpeg.png +0 -0
- data/app/assets/images/48/pdf.png +0 -0
- data/app/assets/images/48/ppt.png +0 -0
- data/app/assets/images/48/rar.png +0 -0
- data/app/assets/images/48/resource.png +0 -0
- data/app/assets/images/48/video.png +0 -0
- data/app/assets/images/48/word.png +0 -0
- data/app/assets/images/48/zip.png +0 -0
- data/app/assets/images/btn/btn_audio.png +0 -0
- data/app/assets/images/btn/btn_document.png +0 -0
- data/app/assets/images/btn/btn_excel.png +0 -0
- data/app/assets/images/btn/btn_pdf.png +0 -0
- data/app/assets/images/btn/btn_picture.png +0 -0
- data/app/assets/images/btn/btn_resource.png +0 -0
- data/app/assets/images/btn/btn_video.png +0 -0
- data/app/assets/images/btn/btn_word.png +0 -0
- data/app/assets/images/btn/document.png +0 -0
- data/app/assets/javascripts/documents.js.erb +71 -0
- data/app/assets/javascripts/social_stream-documents.js +3 -0
- data/app/assets/stylesheets/documents.css.scss +271 -0
- data/app/assets/stylesheets/show.css.scss +111 -0
- data/app/assets/stylesheets/social_stream-documents.css +6 -0
- data/app/controllers/audios_controller.rb +2 -0
- data/app/controllers/documents_controller.rb +97 -0
- data/app/controllers/pictures_controller.rb +2 -0
- data/app/controllers/videos_controller.rb +2 -0
- data/app/helpers/documents_helper.rb +30 -0
- data/app/models/audio.rb +24 -0
- data/app/models/document.rb +78 -0
- data/app/models/picture.rb +30 -0
- data/app/models/video.rb +29 -0
- data/app/views/audios/_audio.html.erb +27 -0
- data/app/views/audios/_audio_focus_search.html.erb +3 -0
- data/app/views/audios/_audio_global_search.html.erb +3 -0
- data/app/views/audios/_audio_processed.html.erb +45 -0
- data/app/views/audios/_audio_processing.html.erb +7 -0
- data/app/views/audios/_audio_show.html.erb +62 -0
- data/app/views/audios/_audio_with_details.html.erb +3 -0
- data/app/views/audios/_new.html.erb +1 -0
- data/app/views/audios/destroy.js.erb +1 -0
- data/app/views/audios/index.html.erb +1 -0
- data/app/views/audios/show.html.erb +2 -0
- data/app/views/common_documents/_document_info.html.erb +48 -0
- data/app/views/common_documents/_edit_form.html.erb +57 -0
- data/app/views/common_documents/_headers.html.erb +72 -0
- data/app/views/common_documents/_index.html.erb +68 -0
- data/app/views/common_documents/_show.html.erb +34 -0
- data/app/views/documents/_document.html.erb +15 -0
- data/app/views/documents/_document_focus_search.html.erb +2 -0
- data/app/views/documents/_document_global_search.html.erb +2 -0
- data/app/views/documents/_document_show.html.erb +7 -0
- data/app/views/documents/_document_with_details.html.erb +13 -0
- data/app/views/documents/_new_activity.html.erb +1 -0
- data/app/views/documents/_new_activity_fields.html.erb +1 -0
- data/app/views/documents/destroy.js.erb +1 -0
- data/app/views/documents/index.html.erb +1 -0
- data/app/views/documents/show.html.erb +2 -0
- data/app/views/pictures/_new.html.erb +1 -0
- data/app/views/pictures/_picture.html.erb +42 -0
- data/app/views/pictures/_picture_focus_search.html.erb +2 -0
- data/app/views/pictures/_picture_global_search.html.erb +2 -0
- data/app/views/pictures/_picture_show.html.erb +26 -0
- data/app/views/pictures/_picture_with_details.html.erb +2 -0
- data/app/views/pictures/destroy.js.erb +1 -0
- data/app/views/pictures/index.html.erb +1 -0
- data/app/views/pictures/show.html.erb +2 -0
- data/app/views/videos/_new.html.erb +1 -0
- data/app/views/videos/_video.html.erb +29 -0
- data/app/views/videos/_video_focus_search.html.erb +2 -0
- data/app/views/videos/_video_global_search.html.erb +2 -0
- data/app/views/videos/_video_processed.html.erb +50 -0
- data/app/views/videos/_video_processing.html.erb +7 -0
- data/app/views/videos/_video_show.html.erb +64 -0
- data/app/views/videos/_video_with_details.html.erb +2 -0
- data/app/views/videos/destroy.js.erb +1 -0
- data/app/views/videos/index.html.erb +1 -0
- data/app/views/videos/show.html.erb +2 -0
- data/app/worker/audioencoder.rb +7 -0
- data/app/worker/videoencoder.rb +7 -0
- data/config/locales/en.yml +67 -0
- data/config/locales/es.yml +67 -0
- data/config/routes.rb +22 -0
- data/db/migrate/20110615143707_create_social_stream_documents.rb +24 -0
- data/db/migrate/20110922173707_add_file_processing_to_document.rb +9 -0
- data/db/migrate/20111005112707_add_title_and_description_to_document.rb +11 -0
- data/lib/generators/social_stream/documents/install_generator.rb +24 -0
- data/lib/social_stream-documents.rb +25 -0
- data/lib/social_stream/documents/engine.rb +46 -0
- data/lib/social_stream/documents/version.rb +5 -0
- data/lib/social_stream/migrations/documents.rb +9 -0
- data/lib/social_stream/toolbar_config/documents.rb +27 -0
- data/social_stream-documents.gemspec +30 -0
- data/spec/controllers/documents_controller_spec.rb +118 -0
- data/spec/controllers/pictures_controller_spec.rb +80 -0
- data/spec/dummy/.gitignore +1 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +45 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +22 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +25 -0
- data/spec/dummy/config/environments/production.rb +49 -0
- data/spec/dummy/config/environments/test.rb +37 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/devise.rb +176 -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/locales/en.yml +5 -0
- data/spec/dummy/config/navigation.rb +0 -0
- data/spec/dummy/config/relations.yml +39 -0
- data/spec/dummy/config/routes.rb +60 -0
- data/spec/dummy/db/.gitkeep +0 -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/public/javascripts/application.js +2 -0
- data/spec/dummy/public/javascripts/controls.js +965 -0
- data/spec/dummy/public/javascripts/dragdrop.js +974 -0
- data/spec/dummy/public/javascripts/effects.js +1123 -0
- data/spec/dummy/public/javascripts/prototype.js +6001 -0
- data/spec/dummy/public/javascripts/rails.js +191 -0
- data/spec/dummy/public/stylesheets/.gitkeep +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/factories/document.rb +20 -0
- data/spec/factories/files/privado.png +0 -0
- data/spec/factories/files/rails.png +0 -0
- data/spec/factories/files/small.pdf +157 -0
- data/spec/factories/picture.rb +21 -0
- data/spec/integration/navigation_spec.rb +9 -0
- data/spec/models/video_spec.rb +9 -0
- data/spec/socialstream_documents_spec.rb +7 -0
- data/spec/spec_helper.rb +46 -0
- data/spec/support/cancan.rb +1 -0
- data/spec/support/db.rb +8 -0
- data/spec/support/devise.rb +4 -0
- data/spec/support/mock.rb +4 -0
- data/vendor/assets/javascripts/jquery.jplayer.js +78 -0
- data/vendor/assets/stylesheets/jplayer.blue.monday.css +448 -0
- data/vendor/assets/stylesheets/jplayer.blue.monday.jpg +0 -0
- data/vendor/assets/stylesheets/jplayer.blue.monday.video.play.hover.png +0 -0
- data/vendor/assets/stylesheets/jplayer.blue.monday.video.play.png +0 -0
- data/vendor/assets/stylesheets/jquery.lightbox.css +101 -0
- data/vendor/assets/stylesheets/pbar-ani.gif +0 -0
- metadata +322 -0
data/config/routes.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Rails.application.routes.draw do
|
2
|
+
resources :pictures
|
3
|
+
resources :audios
|
4
|
+
resources :videos
|
5
|
+
|
6
|
+
resources :documents do
|
7
|
+
get "download", :on => :member
|
8
|
+
end
|
9
|
+
|
10
|
+
# Social Stream subjects configured in config/initializers/social_stream.rb
|
11
|
+
SocialStream.subjects.each do |actor|
|
12
|
+
resources actor.to_s.pluralize do
|
13
|
+
resources :pictures
|
14
|
+
resources :audios
|
15
|
+
resources :videos
|
16
|
+
|
17
|
+
resources :documents do
|
18
|
+
get "download", :on => :member
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class CreateSocialStreamDocuments < ActiveRecord::Migration
|
2
|
+
|
3
|
+
def self.up
|
4
|
+
create_table "documents", :force => true do |t|
|
5
|
+
t.string "type"
|
6
|
+
t.integer "activity_object_id"
|
7
|
+
t.datetime "created_at"
|
8
|
+
t.datetime "updated_at"
|
9
|
+
t.string "file_file_name"
|
10
|
+
t.string "file_content_type"
|
11
|
+
t.string "file_file_size"
|
12
|
+
end
|
13
|
+
|
14
|
+
add_index "documents", "activity_object_id"
|
15
|
+
add_foreign_key "documents", "activity_objects", :name => "documents_on_activity_object_id"
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.down
|
20
|
+
remove_foreign_key "documents", :name => "documents_on_activity_object_id"
|
21
|
+
drop_table :documents
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class AddTitleAndDescriptionToDocument < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
add_column :documents, :title, :string
|
4
|
+
add_column :documents, :description, :text
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.down
|
8
|
+
remove_column :documents, :title
|
9
|
+
remove_column :documents, :description
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class SocialStream::Documents::InstallGenerator < Rails::Generators::Base
|
2
|
+
include Rails::Generators::Migration
|
3
|
+
|
4
|
+
source_root File.expand_path('../templates', __FILE__)
|
5
|
+
|
6
|
+
def create_migration_file
|
7
|
+
require 'rake'
|
8
|
+
Rails.application.load_tasks
|
9
|
+
Rake::Task['railties:install:migrations'].reenable
|
10
|
+
Rake::Task['social_stream_documents_engine:install:migrations'].invoke
|
11
|
+
end
|
12
|
+
|
13
|
+
def require_javascripts
|
14
|
+
inject_into_file 'app/assets/javascripts/application.js',
|
15
|
+
"//= require social_stream-documents\n",
|
16
|
+
:before => '//= require_tree .'
|
17
|
+
end
|
18
|
+
|
19
|
+
def require_stylesheets
|
20
|
+
inject_into_file 'app/assets/stylesheets/application.css',
|
21
|
+
" *= require social_stream-documents\n",
|
22
|
+
:before => ' *= require_tree .'
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'social_stream-base'
|
2
|
+
require 'delayed_paperclip'
|
3
|
+
|
4
|
+
module SocialStream
|
5
|
+
module ToolbarConfig
|
6
|
+
autoload :Documents, 'social_stream/toolbar_config/documents'
|
7
|
+
end
|
8
|
+
|
9
|
+
module Documents
|
10
|
+
# Add :document to SocialStream.objects and SocialStream.activity_forms by default
|
11
|
+
# It can be configured by users at application's config/initializers/social_stream.rb
|
12
|
+
[ :picture, :video, :audio, :document].each do |o|
|
13
|
+
SocialStream.quick_search_models.push(o) unless SocialStream.quick_search_models.include?(o)
|
14
|
+
SocialStream.extended_search_models.push(o) unless SocialStream.extended_search_models.include?(o)
|
15
|
+
end
|
16
|
+
|
17
|
+
%w(objects activity_forms).each do |m|
|
18
|
+
SocialStream.__send__(m).push(:document) unless SocialStream.__send__(m).include?(:document)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
#require 'paperclip_processors/ffmpeg'
|
24
|
+
require 'paperclip-ffmpeg'
|
25
|
+
require 'social_stream/documents/engine'
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module SocialStream
|
2
|
+
module Documents
|
3
|
+
class Engine < Rails::Engine
|
4
|
+
|
5
|
+
initializer "social_stream-documents.register_mime_types" do
|
6
|
+
# Documents
|
7
|
+
Mime::Type.register "text/plain", :txt
|
8
|
+
Mime::Type.register "application/zip", :zip
|
9
|
+
Mime::Type.register "application/x-rar", :rar
|
10
|
+
Mime::Type.register "application/pdf", :pdf
|
11
|
+
Mime::Type.register "application/postscript", :ps, [ "application/ps" ]
|
12
|
+
Mime::Type.register "application/vnd.oasis.opendocument.text", :odt
|
13
|
+
Mime::Type.register "application/vnd.oasis.opendocument.presentation", :odp
|
14
|
+
Mime::Type.register "application/vnd.oasis.opendocument.presentation", :ods
|
15
|
+
Mime::Type.register "application/vnd.ms-word", :doc, [ "application/msword" ]
|
16
|
+
Mime::Type.register "application/vnd.ms-powerpoint", :ppt, [ "application/mspowerpoint" ]
|
17
|
+
Mime::Type.register "application/vnd.ms-excel", :xls, [ "application/msexcel" ]
|
18
|
+
Mime::Type.register "application/rtf", :rtf
|
19
|
+
Mime::Type.register "application/vnd.scribus", :sla
|
20
|
+
|
21
|
+
# Picture
|
22
|
+
Mime::Type.register "image/jpeg", :jpeg, ["image/pjpeg","image/jpg"]
|
23
|
+
Mime::Type.register "image/gif", :gif
|
24
|
+
Mime::Type.register "image/png", :png, [ "image/x-png" ]
|
25
|
+
Mime::Type.register "image/bmp", :bmp
|
26
|
+
Mime::Type.register "image/x-xcf", :xcf
|
27
|
+
|
28
|
+
# Audio
|
29
|
+
Mime::Type.register "audio/x-wav", :wav, [ "audio/wav" ]
|
30
|
+
Mime::Type.register "audio/mpeg", :mpeg
|
31
|
+
Mime::Type.register "audio/x-vorbis+ogg", :ogg, [ "application/ogg" ]
|
32
|
+
Mime::Type.register "audio/webm", :webma
|
33
|
+
|
34
|
+
# Video
|
35
|
+
Mime::Type.register "video/x-flv", :flv
|
36
|
+
Mime::Type.register "video/webm", :webm
|
37
|
+
end
|
38
|
+
|
39
|
+
initializer "social_stream-documents.toolbar_config" do
|
40
|
+
SocialStream::ToolbarConfig.module_eval do
|
41
|
+
include SocialStream::ToolbarConfig::Documents
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module SocialStream
|
2
|
+
module ToolbarConfig
|
3
|
+
module Documents
|
4
|
+
def profile_toolbar_items(subject = current_subject)
|
5
|
+
items = super
|
6
|
+
|
7
|
+
items << {
|
8
|
+
:key => :documents,
|
9
|
+
:name => image_tag("btn/btn_resource.png",:class =>"menu_icon")+t("document.title"),
|
10
|
+
:url => polymorphic_path([subject, Document.new]),
|
11
|
+
:options => {:link => {:id => "documents_menu"}}
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
def home_toolbar_items
|
16
|
+
items = super
|
17
|
+
|
18
|
+
items << {
|
19
|
+
:key => :documents,
|
20
|
+
:name => image_tag("btn/btn_resource.png",:class =>"menu_icon")+t("document.title"),
|
21
|
+
:url => polymorphic_path([current_subject, Document.new]),
|
22
|
+
:options => {:link => {:id => "documents_menu"}}
|
23
|
+
}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require File.join(File.dirname(__FILE__), 'lib', 'social_stream', 'documents', 'version')
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "vkhater-social_stream-documents"
|
6
|
+
s.version = SocialStream::Documents::VERSION.dup
|
7
|
+
s.authors = ["Víctor Sánchez Belmar", "GING - DIT - UPM"]
|
8
|
+
s.summary = "File capabilities for Social Stream, the core for building social network websites"
|
9
|
+
s.description = "Social Stream is a Ruby on Rails engine providing your application with social networking features and activity streams.\n\nThis gem allow you upload almost any kind of file as new social stream activity."
|
10
|
+
s.email = "social-stream@dit.upm.es"
|
11
|
+
s.homepage = "http://github.com/ging/social_stream-documents"
|
12
|
+
s.files = `git ls-files`.split("\n")
|
13
|
+
|
14
|
+
# Gem dependencies
|
15
|
+
s.add_runtime_dependency('vkhater-social_stream-base', '~> 0.11.1')
|
16
|
+
s.add_runtime_dependency('paperclip-ffmpeg', '~> 0.7.0')
|
17
|
+
# Waiting for version > 2.4.5, which fixes:
|
18
|
+
# https://github.com/thoughtbot/paperclip/issues/293
|
19
|
+
s.add_runtime_dependency('paperclip','2.3.11')
|
20
|
+
s.add_runtime_dependency('delayed_paperclip','0.7.2')
|
21
|
+
# Development Gem dependencies
|
22
|
+
s.add_development_dependency('sqlite3-ruby')
|
23
|
+
if RUBY_VERSION < '1.9'
|
24
|
+
s.add_development_dependency('ruby-debug', '~> 0.10.3')
|
25
|
+
end
|
26
|
+
s.add_development_dependency('rspec-rails', '~> 2.6.0')
|
27
|
+
s.add_development_dependency('factory_girl', '~> 1.3.2')
|
28
|
+
s.add_development_dependency('forgery', '~> 0.3.6')
|
29
|
+
s.add_development_dependency('capybara', '~> 0.3.9')
|
30
|
+
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe DocumentsController do
|
4
|
+
render_views
|
5
|
+
|
6
|
+
context "with public document" do
|
7
|
+
before do
|
8
|
+
@public_document = Factory(:public_document)
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "when not authenticated" do
|
12
|
+
it "should redirect to login" do
|
13
|
+
get :index
|
14
|
+
response.should redirect_to(:new_user_session)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should render receiver's index with public document included" do
|
18
|
+
get :index, :user_id => @public_document.post_activity.receiver.to_param
|
19
|
+
response.should be_success
|
20
|
+
response.body.should =~ /attachment_tile/
|
21
|
+
response.body.should =~ /small.pdf/
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should render receiver's html show" do
|
25
|
+
get :show, :id => @public_document.to_param
|
26
|
+
response.should be_success
|
27
|
+
response.headers["Content-Type"].should include('text/html')
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should render receiver's format pdf download" do
|
31
|
+
get :download, :id => @public_document.to_param
|
32
|
+
response.should be_success
|
33
|
+
response.headers["Content-Type"].should include('application/pdf')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "when authenticated" do
|
38
|
+
before do
|
39
|
+
sign_in Factory(:user)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should render index" do
|
43
|
+
get :index, :user_id => @public_document.post_activity.receiver.to_param
|
44
|
+
response.should be_success
|
45
|
+
response.body.should =~ /attachment_tile/
|
46
|
+
response.body.should =~ /small.pdf/
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should render html show" do
|
50
|
+
get :show, :id => @public_document.to_param
|
51
|
+
response.should be_success
|
52
|
+
response.headers["Content-Type"].should include('text/html')
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should render format pdf download" do
|
56
|
+
get :download, :id => @public_document.to_param, :format => :pdf
|
57
|
+
response.should be_success
|
58
|
+
response.headers["Content-Type"].should include('application/pdf')
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end #end of the context
|
62
|
+
|
63
|
+
context "with private document" do
|
64
|
+
before do
|
65
|
+
@private_document = Factory(:private_document)
|
66
|
+
end
|
67
|
+
describe "when not authenticated" do
|
68
|
+
it "should render receiver's index without private document" do
|
69
|
+
get :index, :user_id => @private_document.post_activity.receiver.to_param
|
70
|
+
response.should be_success
|
71
|
+
response.body.should_not =~ /attachment_tile/
|
72
|
+
response.body.should_not =~ /small.pdf/
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "when authenticated" do
|
77
|
+
before do
|
78
|
+
sign_in Factory(:user)
|
79
|
+
end
|
80
|
+
it "should render index" do
|
81
|
+
get :index, :user_id => @private_document.post_activity.receiver.to_param
|
82
|
+
response.should be_success
|
83
|
+
response.body.should_not =~ /attachment_tile/
|
84
|
+
response.body.should_not =~ /small.pdf/
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should render show" do
|
88
|
+
lambda {get :show, :id => @private_document.to_param}.should raise_error(CanCan::AccessDenied)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
context "with public picture" do
|
94
|
+
before do
|
95
|
+
@public_picture = Factory(:public_picture)
|
96
|
+
end
|
97
|
+
|
98
|
+
describe "when not authenticated" do
|
99
|
+
it "should render receiver's format png download" do
|
100
|
+
get :download, :id => @public_picture.to_param
|
101
|
+
response.should be_success
|
102
|
+
response.headers["Content-Type"].should include('image/png')
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
describe "when authenticated" do
|
107
|
+
before do
|
108
|
+
sign_in Factory(:user)
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should render format png download" do
|
112
|
+
get :download, :id => @public_picture.to_param
|
113
|
+
response.should be_success
|
114
|
+
response.headers["Content-Type"].should include('image/png')
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe PicturesController do
|
4
|
+
render_views
|
5
|
+
|
6
|
+
context "with public picture" do
|
7
|
+
before do
|
8
|
+
@public_picture = Factory(:public_picture)
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "when not authenticated" do
|
12
|
+
it "should redirect to login" do
|
13
|
+
get :index
|
14
|
+
response.should redirect_to(:new_user_session)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should render receiver's index with public picture included" do
|
18
|
+
get :index, :user_id => @public_picture.post_activity.receiver.to_param
|
19
|
+
response.should be_success
|
20
|
+
response.body.should =~ /attachment_tile/
|
21
|
+
response.body.should =~ /rails.png/
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should render receiver's html show" do
|
25
|
+
get :show, :id => @public_picture.to_param
|
26
|
+
response.should be_success
|
27
|
+
response.headers["Content-Type"].should include('text/html')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "when authenticated" do
|
32
|
+
before do
|
33
|
+
sign_in Factory(:user)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should render index" do
|
37
|
+
get :index, :user_id => @public_picture.post_activity.receiver.to_param
|
38
|
+
response.should be_success
|
39
|
+
response.body.should =~ /attachment_tile/
|
40
|
+
response.body.should =~ /rails.png/
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should render html show" do
|
44
|
+
get :show, :id => @public_picture.to_param
|
45
|
+
response.should be_success
|
46
|
+
response.headers["Content-Type"].should include('text/html')
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end #end of the context
|
50
|
+
|
51
|
+
context "with private picture" do
|
52
|
+
before do
|
53
|
+
@private_picture = Factory(:private_picture)
|
54
|
+
end
|
55
|
+
describe "when not authenticated" do
|
56
|
+
it "should render receiver's index without private picture" do
|
57
|
+
get :index, :user_id => @private_picture.post_activity.receiver.to_param
|
58
|
+
response.should be_success
|
59
|
+
response.body.should_not =~ /attachment_tile/
|
60
|
+
response.body.should_not =~ /privado.png/
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "when authenticated" do
|
65
|
+
before do
|
66
|
+
sign_in Factory(:user)
|
67
|
+
end
|
68
|
+
it "should render index" do
|
69
|
+
get :index, :user_id => @private_picture.post_activity.receiver.to_param
|
70
|
+
response.should be_success
|
71
|
+
response.body.should_not =~ /attachment_tile/
|
72
|
+
response.body.should_not =~ /privado.png/
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should render show" do
|
76
|
+
lambda {get :show, :id => @private_picture.to_param}.should raise_error(CanCan::AccessDenied)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|