dms-tog_depot 0.1.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/CHANGELOG.md +0 -0
- data/MIT-LICENSE +19 -0
- data/README.markdown +78 -0
- data/Rakefile +22 -0
- data/app/controllers/depot/filefolders_controller.rb +10 -0
- data/app/controllers/depot/files_controller.rb +35 -0
- data/app/controllers/member/depot/filefolders_controller.rb +84 -0
- data/app/controllers/member/depot/files_controller.rb +102 -0
- data/app/helpers/depot/files_helper.rb +18 -0
- data/app/models/depot/file.rb +41 -0
- data/app/models/depot/filefolder.rb +21 -0
- data/app/models/tog/depot/version.rb +17 -0
- data/app/models/user.rb +4 -0
- data/app/views/depot/filefolders/show.html.erb +97 -0
- data/app/views/depot/files/_tag_cloud_file.html.erb +6 -0
- data/app/views/depot/files/by_tag.html.erb +113 -0
- data/app/views/depot/files/index.html.erb +111 -0
- data/app/views/depot/files/show.html.erb +69 -0
- data/app/views/member/depot/filefolders/edit.html.erb +22 -0
- data/app/views/member/depot/filefolders/new.html.erb +19 -0
- data/app/views/member/depot/filefolders/show.html.erb +121 -0
- data/app/views/member/depot/files/by_tag.html.erb +130 -0
- data/app/views/member/depot/files/edit.html.erb +27 -0
- data/app/views/member/depot/files/index.html.erb +132 -0
- data/app/views/member/depot/files/new.html.erb +24 -0
- data/app/views/member/depot/files/show.html.erb +79 -0
- data/config/routes.rb +32 -0
- data/db/migrate/001_create_files.rb +21 -0
- data/db/migrate/002_create_files_folder.rb +16 -0
- data/init.rb +14 -0
- data/public/images/1px.gif +0 -0
- data/public/images/privacity/admin.gif +0 -0
- data/public/images/privacity/community.gif +0 -0
- data/public/images/privacity/member.gif +0 -0
- data/public/images/privacity/public_domain.gif +0 -0
- data/public/images/tog-depot_arrow_dn.gif +0 -0
- data/public/images/tog-depot_arrow_dn_deact.gif +0 -0
- data/public/images/tog-depot_arrow_up.gif +0 -0
- data/public/images/tog-depot_arrow_up_deact.gif +0 -0
- data/public/images/tog-depot_file_dl.gif +0 -0
- data/public/images/tog-depot_iconfile_16px.gif +0 -0
- data/public/images/tog-depot_iconfile_32px.gif +0 -0
- data/public/images/tog-depot_iconfile_48px.gif +0 -0
- data/public/images/tog-depot_iconfolder_16px.gif +0 -0
- data/public/images/tog-depot_iconfolder_32px.gif +0 -0
- data/public/images/tog-depot_iconfolder_48px.gif +0 -0
- data/public/stylesheets/depot.css +52 -0
- data/test/factories.rb +17 -0
- data/test/functional/depot/filefolders_controller_test.rb +30 -0
- data/test/functional/depot/files_controller_test.rb +43 -0
- data/test/functional/member/depot/filefolders_controller_test.rb +15 -0
- data/test/functional/member/depot/files_controller_test.rb +107 -0
- data/test/test_helper.rb +26 -0
- data/test/unit/file_test.rb +8 -0
- data/test/unit/filefolder_test.rb +8 -0
- data/tog_depot.gemspec +81 -0
- metadata +155 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
<% include_stylesheet "/tog_depot/stylesheets/depot" %>
|
|
2
|
+
<% content_for :sidebar do %>
|
|
3
|
+
<ul class="tags">
|
|
4
|
+
<li class="l5">
|
|
5
|
+
<%= link_to 'Edit metadata', edit_member_depot_file_url(@file.id) %>
|
|
6
|
+
</li>
|
|
7
|
+
<li class="l5">
|
|
8
|
+
<%= link_to 'Update archive', edit_member_depot_file_url(@file.id) %>
|
|
9
|
+
</li>
|
|
10
|
+
<li class="l5">
|
|
11
|
+
<%= link_to 'Change visibility', edit_member_depot_file_url(@file.id) %>
|
|
12
|
+
</li>
|
|
13
|
+
<li class="l5">
|
|
14
|
+
<%= link_to 'Delete', member_depot_file_url(@file.id), :method => :delete %>
|
|
15
|
+
</li>
|
|
16
|
+
</ul>
|
|
17
|
+
<% end %>
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
<div id="file_overview">
|
|
21
|
+
<div class="floater_L">
|
|
22
|
+
<div class="fileicon_48"><img src="/tog_depot/images/1px.gif" border="0" height="26" width="5"/><br /><%= @extension %></div>
|
|
23
|
+
</div>
|
|
24
|
+
<div class="floater_R">
|
|
25
|
+
<h1><img src="/tog_depot/images/1px.gif" border="0" height="28" width="5"/><br /><%= @file.title %></h1>
|
|
26
|
+
</div>
|
|
27
|
+
<div class="float_breaker"></div>
|
|
28
|
+
<div style="padding-left:15px;">
|
|
29
|
+
|
|
30
|
+
<% tags = @file.tag_list %>
|
|
31
|
+
<b>Tags:</b>
|
|
32
|
+
<% if !tags.blank? %>
|
|
33
|
+
<% for tag in tags %>
|
|
34
|
+
<%= link_to tag, tag_member_depot_files_path(tag.to_sym) %>
|
|
35
|
+
<% end %>
|
|
36
|
+
<% else %>
|
|
37
|
+
No tags.
|
|
38
|
+
<% end %>
|
|
39
|
+
|
|
40
|
+
<p class="file_metadata">
|
|
41
|
+
<b>Created:</b> <%= @file.created_at %><br />
|
|
42
|
+
<b>Updated:</b> <%= @file.updated_at %><br />
|
|
43
|
+
<b>Size:</b>
|
|
44
|
+
<%if @file.size%>
|
|
45
|
+
<%= @file.size / 1024 %> Kb. (<%= @file.size %> Bytes)
|
|
46
|
+
<%end%>
|
|
47
|
+
<br />
|
|
48
|
+
<b>Owner:</b> <%= @file.user.login %><br />
|
|
49
|
+
<b>Times downloaded:</b> <%= @file.num_download %><br />
|
|
50
|
+
<b>Parent folder:</b>
|
|
51
|
+
<%if @file.filefolder%>
|
|
52
|
+
<%= link_to @file.filefolder.title, member_depot_filefolder_url(@file.filefolder.id) %>
|
|
53
|
+
<%end%>
|
|
54
|
+
<br />
|
|
55
|
+
<b>Visibility: <%= @file.state %></b>
|
|
56
|
+
</p>
|
|
57
|
+
<p>
|
|
58
|
+
<b>Description:</b>
|
|
59
|
+
<%= @file.description %>
|
|
60
|
+
<br /><br />
|
|
61
|
+
</p>
|
|
62
|
+
</div>
|
|
63
|
+
|
|
64
|
+
<div class="floater_L" style="float:left;">
|
|
65
|
+
<a href=" <%= member_depot_files_download_path %> "><img src="/tog_depot/images/tog-depot_file_dl.gif" border="0" /></a></div>
|
|
66
|
+
<div style="float:left; padding-left:8px;"><h2 class="no_margins" style="padding:0px; border:0px; margin:0px;">
|
|
67
|
+
<%= link_to "Download file", member_depot_files_download_path %></h2>
|
|
68
|
+
|
|
69
|
+
<%= report_abuse_link(@file, 'Report abuse', :class => 'abuse_link') -%>
|
|
70
|
+
|
|
71
|
+
</div>
|
|
72
|
+
<div style="clear:both;" class="float_breaker"></div><br />
|
|
73
|
+
|
|
74
|
+
<%= link_to '<< Back to filelist', member_depot_files_path %><br /><br />
|
|
75
|
+
<%= render :partial => "shared/comments", :locals => { :commentable => @file } %>
|
|
76
|
+
|
|
77
|
+
</div>
|
|
78
|
+
|
|
79
|
+
|
data/config/routes.rb
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Add your custom routes here. If in config/routes.rb you would
|
|
2
|
+
# add <tt>map.resources</tt>, here you would add just <tt>resources</tt>
|
|
3
|
+
|
|
4
|
+
# resources :tog_depot
|
|
5
|
+
|
|
6
|
+
namespace(:depot) do |depot|
|
|
7
|
+
depot.resources :filefolders
|
|
8
|
+
depot.resources :filefolders, :collection => {:tags => :get}
|
|
9
|
+
depot.resources :files
|
|
10
|
+
depot.resources :files, :collection => {:tags => :get}
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
namespace(:member) do |member|
|
|
14
|
+
member.namespace(:depot) do |depot|
|
|
15
|
+
depot.resources :filefolders
|
|
16
|
+
depot.resources :filefolders, :collection => {:tags => :get}
|
|
17
|
+
depot.resources :files
|
|
18
|
+
depot.resources :files, :collection => {:tags => :get}
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
with_options(:controller => 'depot/files', :conditions => { :method => :get }) do |file|
|
|
23
|
+
file.tag_depot_files 'depot/files/tag/:tag_name', :action => 'by_tag'
|
|
24
|
+
file.depot_files_order 'depot/files/order/:order', :action => 'index'
|
|
25
|
+
file.depot_files_download 'depot/files/download/:id', :action => 'download'
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
with_options(:controller => 'member/depot/files', :conditions => { :method => :get }) do |file|
|
|
29
|
+
file.tag_member_depot_files 'member/depot/files/tag/:tag_name', :action => 'by_tag'
|
|
30
|
+
file.member_depot_files_order 'member/depot/files/order/:order', :action => 'index'
|
|
31
|
+
file.member_depot_files_download 'member/depot/files/download/:id', :action => 'download'
|
|
32
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
class CreateFiles < ActiveRecord::Migration
|
|
2
|
+
def self.up
|
|
3
|
+
create_table :files do |t|
|
|
4
|
+
t.string :title
|
|
5
|
+
t.text :description
|
|
6
|
+
t.integer :user_id
|
|
7
|
+
t.string :filename
|
|
8
|
+
t.integer :size
|
|
9
|
+
t.string :content_type
|
|
10
|
+
t.string :state
|
|
11
|
+
t.integer :filefolder_id
|
|
12
|
+
t.integer :num_download, :default => 0
|
|
13
|
+
|
|
14
|
+
t.timestamps
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def self.down
|
|
19
|
+
drop_table :files
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
class CreateFilesFolder < ActiveRecord::Migration
|
|
2
|
+
def self.up
|
|
3
|
+
create_table :files_folder do |t|
|
|
4
|
+
t.string :title
|
|
5
|
+
t.text :description
|
|
6
|
+
t.integer :user_id
|
|
7
|
+
t.string :state
|
|
8
|
+
|
|
9
|
+
t.timestamps
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.down
|
|
14
|
+
drop_table :files_folder
|
|
15
|
+
end
|
|
16
|
+
end
|
data/init.rb
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require_plugin 'tog_core'
|
|
2
|
+
require_plugin 'seo_urls'
|
|
3
|
+
require_plugin 'attachment_fu'
|
|
4
|
+
require_plugin 'acts_as_rateable'
|
|
5
|
+
require_plugin 'acts_as_taggable_on_steroids'
|
|
6
|
+
|
|
7
|
+
Tog::Interface.sections(:site).add "Files", "/depot/files"
|
|
8
|
+
|
|
9
|
+
Tog::Interface.sections(:member).add "My files", "/member/depot/files"
|
|
10
|
+
|
|
11
|
+
Tog::Plugins.settings :tog_depot, "file.max_size_file" => "5000",
|
|
12
|
+
"file.max_size_storage" => "500000"
|
|
13
|
+
|
|
14
|
+
#Tog::Plugins.helpers Files::FilesHelper
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
.no_margins{}
|
|
2
|
+
.floater_L{float:left;}
|
|
3
|
+
.floater_R{foat:right;}
|
|
4
|
+
.float_breaker{clear:both;}
|
|
5
|
+
#file_overview{}
|
|
6
|
+
.end_list {border-bottom:1px solid #d1d1d1;}
|
|
7
|
+
.fileicon_32{background-image: url(../../tog_depot/images/tog-depot_iconfile_32px.gif); background-repeat:no-repeat; vertical-align:bottom; text-align:center; height:32px; width:32px; font-family:Arial, Helvetica, sans-serif; font-size:9px; text-transform:uppercase;}
|
|
8
|
+
.fileicon_48{background-image: url(../../tog_depot/images/tog-depot_iconfile_48px.gif); background-repeat:no-repeat; vertical-align:bottom; text-align:center; height:48px; width:48px; font-family:Arial, Helvetica, sans-serif; font-size:12px; text-transform:uppercase; font-weight:bold; color:#333333;}
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
/*++++++++++++++ TABLE [Override TOG_core style] +++++++++++++++*/
|
|
13
|
+
|
|
14
|
+
table{
|
|
15
|
+
width: 700px;
|
|
16
|
+
border: 0;
|
|
17
|
+
border-collapse: separate;
|
|
18
|
+
border: 1px solid #d1d1d1;
|
|
19
|
+
}
|
|
20
|
+
table caption {
|
|
21
|
+
background-color: #edf3fd;
|
|
22
|
+
color: #dd4171;
|
|
23
|
+
font-weight: bold;
|
|
24
|
+
font-size: 1.1em;
|
|
25
|
+
text-align: left;
|
|
26
|
+
padding: 2px 5px;
|
|
27
|
+
border-right: 1px solid #d1d1d1;
|
|
28
|
+
border-left: 1px solid #d1d1d1;
|
|
29
|
+
}
|
|
30
|
+
table th, table td {
|
|
31
|
+
padding: 0px 0px;
|
|
32
|
+
border-top: none;
|
|
33
|
+
border-bottom: none;
|
|
34
|
+
}
|
|
35
|
+
table th img, table td img {
|
|
36
|
+
vertical-align: middle;
|
|
37
|
+
}
|
|
38
|
+
table th {
|
|
39
|
+
text-align: left;
|
|
40
|
+
font-weight: normal;
|
|
41
|
+
color: #636f7d;
|
|
42
|
+
background-color: inherit;
|
|
43
|
+
}
|
|
44
|
+
table tr.pair {
|
|
45
|
+
background: #edf3fd;
|
|
46
|
+
color: inherit;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/*++++++++++++++ TEMPLATE.CSS [Override styles] +++++++++++++++*/
|
|
50
|
+
|
|
51
|
+
.col_60_40 .left_col{width:75%;}
|
|
52
|
+
.col_60_40 .right_col{width:25%;}
|
data/test/factories.rb
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Factory.define :user do |u|
|
|
2
|
+
u.salt '9c3b835d47f73a22f22fb2ee3b20b8f4d3c84fbe'
|
|
3
|
+
u.crypted_password 'e06d3c1e75543efe814829a341fb783d23c0f9b9'
|
|
4
|
+
u.activation_code ''
|
|
5
|
+
u.state 'active'
|
|
6
|
+
u.email {'ignacio.vega@dmsti.es'}
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
Factory.define :file do |f|
|
|
10
|
+
f.title 'file title'
|
|
11
|
+
f.description 'file description'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
Factory.define :filefolder do |ff|
|
|
15
|
+
ff.title 'filefolder title'
|
|
16
|
+
ff.description 'filefolder description'
|
|
17
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
|
2
|
+
|
|
3
|
+
class Depot::FilefoldersControllerTest < Test::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
context "Given a Filefolder" do
|
|
6
|
+
setup do
|
|
7
|
+
@controller = Depot::FilefoldersController.new
|
|
8
|
+
@request = ActionController::TestRequest.new
|
|
9
|
+
@response = ActionController::TestResponse.new
|
|
10
|
+
|
|
11
|
+
@member_user = Factory(:user, :login => 'member_user', :admin => true)
|
|
12
|
+
@filefolder = Factory(:filefolder, :title => 'My Folder', :description => 'Folder description', :user => @member_user)
|
|
13
|
+
@file.published!
|
|
14
|
+
filefolder(:filefolder, :title => 'My draft draft', :description => 'bla, bla, bla...', :user => @member_user).draft!
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
context "on GET to :show" do
|
|
18
|
+
setup do
|
|
19
|
+
Factory(:filefolder, :title => 'Other post', :description => 'bla, bla, bla...', :user => @member_user).draft!
|
|
20
|
+
get :show, :id => @filefolder.id
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
should_assign_to :filefolder, :equals => '@filefolder'
|
|
24
|
+
|
|
25
|
+
should_respond_with :success
|
|
26
|
+
should_render_template :show
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
|
2
|
+
|
|
3
|
+
class Depot::FilesControllerTest < Test::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
context "Given a File" do
|
|
6
|
+
setup do
|
|
7
|
+
@controller = Depot::FilesController.new
|
|
8
|
+
@request = ActionController::TestRequest.new
|
|
9
|
+
@response = ActionController::TestResponse.new
|
|
10
|
+
|
|
11
|
+
@member_user = Factory(:user, :login => 'member_user', :admin => true)
|
|
12
|
+
@filefolder = Factory(:filefolder, :title => 'My Folder', :description => 'Folder description', :user => @member_user)
|
|
13
|
+
@file = Factory(:file, :title => 'My File', :description => 'Cool description', :author => @member_user, :filefolder => @filefolder)
|
|
14
|
+
@file.published!
|
|
15
|
+
Factory(:file, :title => 'My draft draft', :description => 'bla, bla, bla...', :user => @member_user, :filefolder => @filefolder).draft!
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
context "on GET to :index" do
|
|
19
|
+
setup do
|
|
20
|
+
get :index
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
should_assign_to :filefolders
|
|
24
|
+
|
|
25
|
+
should_respond_with :success
|
|
26
|
+
should_render_template :index
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
context "on GET to :show" do
|
|
30
|
+
setup do
|
|
31
|
+
Factory(:file, :title => 'Other post', :description => 'bla, bla, bla...', :user => @member_user, :filefolder => @filefolder).draft!
|
|
32
|
+
get :show, :id => @filefolder.id
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
should_assign_to :filefolder, :equals => '@filefolder'
|
|
36
|
+
should_assign_to :file, :equals => '@filefolder.published_files'
|
|
37
|
+
|
|
38
|
+
should_respond_with :success
|
|
39
|
+
should_render_template :show
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../test_helper'
|
|
2
|
+
|
|
3
|
+
class Member::Depot::FilefoldersControllerTest < Test::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
def setup
|
|
6
|
+
@member_user = Factory(:user, :login => 'member_user', :admin => true)
|
|
7
|
+
@filefolder = Factory(:filefolder, :title => 'My Blog', :description => 'Cool description', :user => @member_user)
|
|
8
|
+
|
|
9
|
+
@controller = Member::Conversatio::FilefoldersController.new
|
|
10
|
+
@request = ActionController::TestRequest.new
|
|
11
|
+
@response = ActionController::TestResponse.new
|
|
12
|
+
@request.session[:user_id] = @member_user.id
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
end
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../test_helper'
|
|
2
|
+
|
|
3
|
+
class Member::Depot::FilesControllerTest < Test::Unit::TestCase
|
|
4
|
+
context "FilesController in Member's area" do
|
|
5
|
+
context "without a logged user" do
|
|
6
|
+
setup do
|
|
7
|
+
get :index, :id => 1
|
|
8
|
+
end
|
|
9
|
+
should_redirect_to "login_path"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
context "with a logged user" do
|
|
13
|
+
setup do
|
|
14
|
+
@member_user = Factory(:user, :login => 'member_user')
|
|
15
|
+
@request.session[:user_id] = @member_user.id
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
context "given a File" do
|
|
19
|
+
setup do
|
|
20
|
+
@file = Factory(:file, :title => 'My file', :description => 'bla, bla, bla...', :user => @member_user)
|
|
21
|
+
@file.published!
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
context "on GET to :index" do
|
|
25
|
+
setup do
|
|
26
|
+
get :index
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
should_respond_with :success
|
|
30
|
+
should_assign_to :file, :equals => '@file'
|
|
31
|
+
should_render_template :index
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
context "on GET to :show" do
|
|
35
|
+
setup do
|
|
36
|
+
get :show, :id => @file.id
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
should_respond_with :success
|
|
40
|
+
should_assign_to :file, :equals => '@file'
|
|
41
|
+
should_assign_to :comments, :equals => '@file.all_comments'
|
|
42
|
+
should_render_template :show
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
context "on GET to :new" do
|
|
46
|
+
setup do
|
|
47
|
+
get :new
|
|
48
|
+
assert_equal(true, assigns(:file).new_record?)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
should_respond_with :success
|
|
52
|
+
should_assign_to :file
|
|
53
|
+
should_render_template :new
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
context "on FILE to :create with correct data" do
|
|
57
|
+
setup do
|
|
58
|
+
file :create, :file => { :title => 'New File', :description => 'Cool description' }, :state => 'published'
|
|
59
|
+
@file_created = File.find(assigns(:file).id)
|
|
60
|
+
assert @file_created
|
|
61
|
+
assert_equal('New File', assigns(:file).title)
|
|
62
|
+
assert_equal('Cool description', assigns(:file).description)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
should_assign_to :file, :equals => "File.find(@file_created.id)"
|
|
66
|
+
should_set_the_flash_to /created/i
|
|
67
|
+
should_redirect_to "member_depot_files_path"
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
context "on FILE to :create without correct data" do
|
|
71
|
+
setup do
|
|
72
|
+
file :create
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
should_set_the_flash_to /failed/i
|
|
76
|
+
should_render_template :new
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
context "on PUT to :update with correct data" do
|
|
80
|
+
setup do
|
|
81
|
+
put :update, :id => @file.id, :file => { :title => 'Title Changed', :description => 'Body changed' }, :state => 'published'
|
|
82
|
+
@file_updated = File.find(@file.id)
|
|
83
|
+
assert @file_updated
|
|
84
|
+
assert_equal('Title Changed', @file_updated.title)
|
|
85
|
+
assert_equal('Body changed', @file_updated.description)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
should_set_the_flash_to /updated/i
|
|
89
|
+
should_redirect_to "member_depot_files_path(@file)"
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
context "on PUT to :update without correct data" do
|
|
93
|
+
setup do
|
|
94
|
+
put :update, :id => @file.id, :file => { :title => nil, :description => 'Body changed' }, :state => 'published'
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
should_set_the_flash_to /failed/i
|
|
98
|
+
should_render_template :edit
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# context "on DELETE to :destroy" do
|
|
102
|
+
# end
|
|
103
|
+
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
end
|