@@ -5,20 +5,22 @@ |
||
| 5 | 5 |
<h1><i class="fa fa-file-image-o"></i> <%= t "admin_panel.files" %> <%= link_to (t "admin_panel.upload_file"), new_upload_path, :class => 'btn btn-primary btn-mini' %></h1> |
| 6 | 6 |
</div> |
| 7 | 7 |
<%= bootstrap_flash %> |
| 8 |
- <ul class="thumbnails"> |
|
| 9 |
- <% @uploads.each do |upload| %> |
|
| 10 |
- <li class="span3" style=""> |
|
| 11 |
- <div class="thumbnail" style="height: 250px;"> |
|
| 12 |
- <% if upload.file.content_type.start_with?('image') && upload.file.thumb.to_s != nil %>
|
|
| 13 |
- <%= image_tag upload.file.thumb.to_s %> |
|
| 14 |
- <% else %> |
|
| 15 |
- <img src="http://placehold.it/300x200" alt=""> |
|
| 16 |
- <% end %> |
|
| 17 |
- <h5 style="height: 40px"><%= link_to upload.title, upload_path(upload) %></h5> |
|
| 18 |
- <p><%= upload.description %></p> |
|
| 19 |
- </div> |
|
| 20 |
- </li> |
|
| 21 |
- <% end %> |
|
| 22 |
- </ul> |
|
| 8 |
+ <% if @uploads != nil %> |
|
| 9 |
+ <ul class="thumbnails"> |
|
| 10 |
+ <% @uploads.each do |upload| %> |
|
| 11 |
+ <li class="span3" style=""> |
|
| 12 |
+ <div class="thumbnail" style="height: 250px;"> |
|
| 13 |
+ <% if upload.file.content_type.to_s.start_with?('image') && upload.file.thumb.to_s != nil %>
|
|
| 14 |
+ <%= image_tag upload.file.thumb.to_s %> |
|
| 15 |
+ <% else %> |
|
| 16 |
+ <img src="http://placehold.it/300x200" alt=""> |
|
| 17 |
+ <% end %> |
|
| 18 |
+ <h5 style="height: 40px"><%= link_to upload.title, upload_path(upload) %></h5> |
|
| 19 |
+ <p><%= upload.description %></p> |
|
| 20 |
+ </div> |
|
| 21 |
+ </li> |
|
| 22 |
+ <% end %> |
|
| 23 |
+ </ul> |
|
| 24 |
+ <% end %> |
|
| 23 | 25 |
</div> |
| 24 | 26 |
</div> |
@@ -2,7 +2,7 @@ |
||
| 2 | 2 |
<h1> |
| 3 | 3 |
<%= @upload.title %> |
| 4 | 4 |
<%= link_to 'Edit', edit_upload_path(@upload), class: 'btn btn-mini pull-right', style: 'margin-top: 12px; margin-left: 6px;'%> |
| 5 |
- <%= link_to 'Destroy', @upload, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger btn-mini pull-right', style: 'margin-top: 12px;' %>
|
|
| 5 |
+ <%= link_to 'Delete', @upload, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger btn-mini pull-right', style: 'margin-top: 12px;' %>
|
|
| 6 | 6 |
</h1> |
| 7 | 7 |
</div> |
| 8 | 8 |
|
@@ -0,0 +1,61 @@ |
||
| 1 |
+@file_upload |
|
| 2 |
+Feature: File Upload |
|
| 3 |
+ |
|
| 4 |
+ In order to upload files |
|
| 5 |
+ As an content creator |
|
| 6 |
+ I want to upload and manage files |
|
| 7 |
+ |
|
| 8 |
+ Background: |
|
| 9 |
+ Given the website is configured |
|
| 10 |
+ |
|
| 11 |
+ Scenario: Upload file |
|
| 12 |
+ Given I am logged in as admin |
|
| 13 |
+ And I go to the files page |
|
| 14 |
+ When I click in the link "Upload File" |
|
| 15 |
+ And I fill in "Title" with "Cat meme" |
|
| 16 |
+ And I fill in "Description" with "Cats with lasers" |
|
| 17 |
+ And I upload the file "cats_with_lasers.jpg" to the field "upload_file" |
|
| 18 |
+ And I click in the button "Save" |
|
| 19 |
+ Then I should see "Upload was successfully created" |
|
| 20 |
+ And I should see the image "cats_with_lasers.jpg" |
|
| 21 |
+ |
|
| 22 |
+ Scenario: List files |
|
| 23 |
+ Given I am logged in as admin |
|
| 24 |
+ And the following files where uploaded |
|
| 25 |
+ | title | description | file | |
|
| 26 |
+ | Aliens | History Chanel guy | aliens_meme.jpg | |
|
| 27 |
+ | Cats | Cats with lasers | cats_with_lasers.jpg | |
|
| 28 |
+ When I go to the files page |
|
| 29 |
+ Then I should see "Aliens" |
|
| 30 |
+ And I should see the image "aliens_meme.jpg" |
|
| 31 |
+ And I should see "Cats" |
|
| 32 |
+ And I should see the image "cats_with_lasers.jpg" |
|
| 33 |
+ |
|
| 34 |
+ Scenario: Edit file |
|
| 35 |
+ Given I am logged in as admin |
|
| 36 |
+ And the following files where uploaded |
|
| 37 |
+ | title | description | file | |
|
| 38 |
+ | Aliens | History Chanel guy | aliens_meme.jpg | |
|
| 39 |
+ | Cats | Cats with lasers | cats_with_lasers.jpg | |
|
| 40 |
+ When I go to the files page |
|
| 41 |
+ And I click in the link "Aliens" |
|
| 42 |
+ And I click in the link "Edit" |
|
| 43 |
+ And I fill in "Title" with "Crazy Dude" |
|
| 44 |
+ And I fill in "Description" with "I see aliens" |
|
| 45 |
+ And I click in the button "Save" |
|
| 46 |
+ Then I should see the image "aliens_meme.jpg" |
|
| 47 |
+ And I should see "Crazy Dude" |
|
| 48 |
+ And I should see "I see aliens" |
|
| 49 |
+ |
|
| 50 |
+ Scenario: Delete file |
|
| 51 |
+ Given I am logged in as admin |
|
| 52 |
+ And the following files where uploaded |
|
| 53 |
+ | title | description | file | |
|
| 54 |
+ | Aliens | History Chanel guy | aliens_meme.jpg | |
|
| 55 |
+ | Cats | Cats with lasers | cats_with_lasers.jpg | |
|
| 56 |
+ When I go to the files page |
|
| 57 |
+ And I click in the link "Aliens" |
|
| 58 |
+ And I click in the link "Delete" |
|
| 59 |
+ Then I should see "Cats" |
|
| 60 |
+ And I should see the image "cats_with_lasers.jpg" |
|
| 61 |
+ And I should not see "Aliens" |
@@ -1,3 +1,4 @@ |
||
| 1 |
+@maintenance_mode |
|
| 1 | 2 |
Feature: Maintenance Mode |
| 2 | 3 |
|
| 3 | 4 |
In order to change things in the website |
@@ -52,4 +52,17 @@ end |
||
| 52 | 52 |
|
| 53 | 53 |
Then(/^I should see the image "(.*?)"$/) do |image_name| |
| 54 | 54 |
page.should have_selector("img[src$='#{image_name}']")
|
| 55 |
+end |
|
| 56 |
+ |
|
| 57 |
+# Upload Images |
|
| 58 |
+ |
|
| 59 |
+Given(/^the following files where uploaded$/) do |table| |
|
| 60 |
+ table.hashes.each do |hash| |
|
| 61 |
+ visit '/admin/files/new' |
|
| 62 |
+ fill_in "Title", :with => hash[:title] |
|
| 63 |
+ fill_in "Description", :with => hash[:description] |
|
| 64 |
+ @test_file_path = File.expand_path(('../../spec/fixtures/' + hash[:file]), File.dirname(__FILE__))
|
|
| 65 |
+ attach_file "upload_file", @test_file_path |
|
| 66 |
+ click_button "Save" |
|
| 67 |
+ end |
|
| 55 | 68 |
end |
@@ -21,6 +21,9 @@ module NavigationHelpers |
||
| 21 | 21 |
|
| 22 | 22 |
when/the blog page/ |
| 23 | 23 |
visit blog_path |
| 24 |
+ |
|
| 25 |
+ when/the files page/ |
|
| 26 |
+ visit admin_files_path |
|
| 24 | 27 |
|
| 25 | 28 |
when/the contact page/ |
| 26 | 29 |
visit contact_messages_path |