Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

window done

  • Loading branch information...
commit f8157c0d38f326bcc56b18c8b63188769959f30f 1 parent 88c624b
John Rees authored
Showing with 824 additions and 29 deletions.
  1. +1 −0  Gemfile
  2. +4 −0 Gemfile.lock
  3. +15 −0 app/assets/javascripts/contact.js.coffee
  4. +3 −0  app/assets/javascripts/downloads.js.coffee
  5. +5 −5 app/assets/javascripts/home.js.coffee
  6. +8 −3 app/assets/javascripts/projects.js.coffee
  7. +6 −1 app/assets/stylesheets/application.css.scss
  8. +15 −1 app/assets/stylesheets/contact.css.scss
  9. +3 −0  app/assets/stylesheets/downloads.css.scss
  10. +5 −3 app/assets/stylesheets/home.css.scss
  11. +3 −1 app/assets/stylesheets/slider.css.scss
  12. +83 −0 app/controllers/downloads_controller.rb
  13. +2 −2 app/controllers/services_controller.rb
  14. +2 −0  app/helpers/downloads_helper.rb
  15. +3 −0  app/models/download.rb
  16. +4 −0 app/models/photo.rb
  17. +2 −0  app/models/project.rb
  18. +3 −0  app/models/video.rb
  19. +56 −0 app/uploaders/file_uploader.rb
  20. +60 −0 app/uploaders/image_uploader.rb
  21. +29 −0 app/views/downloads/_form.html.erb
  22. +6 −0 app/views/downloads/edit.html.erb
  23. +26 −0 app/views/downloads/index.html.erb
  24. +5 −0 app/views/downloads/new.html.erb
  25. +20 −0 app/views/downloads/show.html.erb
  26. +1 −1  app/views/layouts/application.html.erb
  27. +8 −4 app/views/pages/contact.html.erb
  28. +20 −0 app/views/projects/_form.html.erb
  29. +4 −3 app/views/projects/index.html.erb
  30. +21 −1 app/views/projects/show.html.erb
  31. +1 −1  app/views/services/index.html.erb
  32. +4 −2 config/routes.rb
  33. +12 −0 db/migrate/20120329110345_create_videos.rb
  34. +12 −0 db/migrate/20120329113301_create_photos.rb
  35. +11 −0 db/migrate/20120329130823_create_downloads.rb
  36. +28 −1 db/schema.rb
  37. BIN  public/file/1/Brief_01.pdf
  38. BIN  public/file/2/Wireframes_01.pdf
  39. BIN  public/uploads/download/file/1/Brief_01.pdf
  40. +164 −0 spec/controllers/downloads_controller_spec.rb
  41. +15 −0 spec/helpers/downloads_helper_spec.rb
  42. +5 −0 spec/models/download_spec.rb
  43. +5 −0 spec/models/photo_spec.rb
  44. +5 −0 spec/models/video_spec.rb
  45. +11 −0 spec/requests/downloads_spec.rb
  46. +35 −0 spec/routing/downloads_routing_spec.rb
  47. +22 −0 spec/views/downloads/edit.html.erb_spec.rb
  48. +28 −0 spec/views/downloads/index.html.erb_spec.rb
  49. +22 −0 spec/views/downloads/new.html.erb_spec.rb
  50. +21 −0 spec/views/downloads/show.html.erb_spec.rb
View
1  Gemfile
@@ -19,6 +19,7 @@ group :assets do
end
gem 'friendly_id'
+gem 'carrierwave'
group :production do
gem 'pg'
View
4 Gemfile.lock
@@ -40,6 +40,9 @@ GEM
rack-test (>= 0.5.4)
selenium-webdriver (~> 2.0)
xpath (~> 0.1.4)
+ carrierwave (0.6.0)
+ activemodel (>= 3.2.0)
+ activesupport (>= 3.2.0)
childprocess (0.3.1)
ffi (~> 1.0.6)
chronic (0.6.7)
@@ -156,6 +159,7 @@ PLATFORMS
DEPENDENCIES
bourbon
capybara
+ carrierwave
coffee-rails (~> 3.2.1)
database_cleaner
delorean
View
15 app/assets/javascripts/contact.js.coffee
@@ -0,0 +1,15 @@
+jQuery ->
+ if $('#map_canvas').length
+ myLatlng = new google.maps.LatLng(53.472169,-2.181558);
+ myOptions = {
+ zoom: 13,
+ center: myLatlng,
+ mapTypeId: google.maps.MapTypeId.ROADMAP
+ }
+ map = new google.maps.Map(document.getElementById("map_canvas"), myOptions)
+
+ marker = new google.maps.Marker({
+ position: myLatlng,
+ map: map,
+ title:"Hello World!"
+ })
View
3  app/assets/javascripts/downloads.js.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
View
10 app/assets/javascripts/home.js.coffee
@@ -7,8 +7,8 @@ jQuery ->
loading_text: "loading tweets..."
template: "<div class='tweet_body'>{text}</div><div class='tweet_time'>{time}</div>"
$('#my-slideshow').bjqs
- 'width' : 940,
- 'height' : 340,
- 'showMarkers' : true,
- 'showControls' : true,
- 'centerMarkers' : false
+ width: '100%'
+ height : 360
+ showMarkers: true
+ showControls: true
+ centerMarkers: false
View
11 app/assets/javascripts/projects.js.coffee
@@ -1,3 +1,8 @@
-# Place all the behaviors and hooks related to the matching controller here.
-# All this logic will automatically be available in application.js.
-# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
+jQuery ->
+
+ $('#add_video').click ->
+ embed_code = $('#video_url').val().replace(/^[^v]+v.(.{11}).*/,"$1")
+ $('#video_url').val('').focus()
+ player = "<iframe width='280' height='156' src='http://www.youtube.com/embed/#{embed_code}' frameborder='0' allowfullscreen></iframe>"
+ $('#video_list').append("<li>#{player}</li>")
+ return false
View
7 app/assets/stylesheets/application.css.scss
@@ -15,7 +15,9 @@ nav {
display: inline;
}
}
-
+a {
+ text-decoration: none;
+}
.container {
width: grid-width(7); // returns 520px;
margin: 0 auto;
@@ -23,6 +25,9 @@ nav {
#telephone_number {
float: right;
}
+header {
+ margin-bottom: 20px;
+}
@import "home";
@import "contact";
View
16 app/assets/stylesheets/contact.css.scss
@@ -1,5 +1,19 @@
-.address {
+#address {
span {
display: block;
}
+ width: grid-width(2);
+ float: left;
+}
+
+#map_canvas {
+ display: block;
+ width: grid-width(5);
+ height: 400px;
+ float: left;
+}
+
+#downloads {
+ clear: both;
+ width: grid-width(8);
}
View
3  app/assets/stylesheets/downloads.css.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the Downloads controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
View
8 app/assets/stylesheets/home.css.scss
@@ -1,10 +1,12 @@
#my-slideshow {
- margin-bottom: 30px;
+ margin-bottom: 20px;
+// overflow: auto;
+position: relative;
}
+
#window {
- height: 400px;
+ height: 360px;
background: #111;
- margin: 10px 0;
position: relative;
overflow: hidden;
h1 {
View
4 app/assets/stylesheets/slider.css.scss
@@ -60,7 +60,9 @@ a.bjqs-next{
ol.bjqs-markers{
position:absolute;
- bottom:-50px;
+// bottom:-50px;
+bottom: 5px;
+right: 5px;
}
ol.bjqs-markers li{
View
83 app/controllers/downloads_controller.rb
@@ -0,0 +1,83 @@
+class DownloadsController < ApplicationController
+ # GET /downloads
+ # GET /downloads.json
+ def index
+ @downloads = Download.all
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.json { render json: @downloads }
+ end
+ end
+
+ # GET /downloads/1
+ # GET /downloads/1.json
+ def show
+ @download = Download.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.json { render json: @download }
+ end
+ end
+
+ # GET /downloads/new
+ # GET /downloads/new.json
+ def new
+ @download = Download.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.json { render json: @download }
+ end
+ end
+
+ # GET /downloads/1/edit
+ def edit
+ @download = Download.find(params[:id])
+ end
+
+ # POST /downloads
+ # POST /downloads.json
+ def create
+ @download = Download.new(params[:download])
+
+ respond_to do |format|
+ if @download.save
+ format.html { redirect_to @download, notice: 'Download was successfully created.' }
+ format.json { render json: @download, status: :created, location: @download }
+ else
+ format.html { render action: "new" }
+ format.json { render json: @download.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /downloads/1
+ # PUT /downloads/1.json
+ def update
+ @download = Download.find(params[:id])
+
+ respond_to do |format|
+ if @download.update_attributes(params[:download])
+ format.html { redirect_to @download, notice: 'Download was successfully updated.' }
+ format.json { head :no_content }
+ else
+ format.html { render action: "edit" }
+ format.json { render json: @download.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /downloads/1
+ # DELETE /downloads/1.json
+ def destroy
+ @download = Download.find(params[:id])
+ @download.destroy
+
+ respond_to do |format|
+ format.html { redirect_to downloads_url }
+ format.json { head :no_content }
+ end
+ end
+end
View
4 app/controllers/services_controller.rb
@@ -44,7 +44,7 @@ def create
respond_to do |format|
if @service.save
- format.html { redirect_to @service, notice: 'Service was successfully created.' }
+ format.html { redirect_to services_url, notice: 'Service was successfully created.' }
format.json { render json: @service, status: :created, location: @service }
else
format.html { render action: "new" }
@@ -60,7 +60,7 @@ def update
respond_to do |format|
if @service.update_attributes(params[:service])
- format.html { redirect_to @service, notice: 'Service was successfully updated.' }
+ format.html { redirect_to services_url, notice: 'Service was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
View
2  app/helpers/downloads_helper.rb
@@ -0,0 +1,2 @@
+module DownloadsHelper
+end
View
3  app/models/download.rb
@@ -0,0 +1,3 @@
+class Download < ActiveRecord::Base
+ mount_uploader :file, FileUploader
+end
View
4 app/models/photo.rb
@@ -0,0 +1,4 @@
+class Photo < ActiveRecord::Base
+ belongs_to :project
+ mount_uploader :image, ImageUploader
+end
View
2  app/models/project.rb
@@ -1,4 +1,6 @@
class Project < ActiveRecord::Base
extend FriendlyId
friendly_id :name, use: :slugged
+ has_many :videos
+ has_many :photos
end
View
3  app/models/video.rb
@@ -0,0 +1,3 @@
+class Video < ActiveRecord::Base
+ belongs_to :project
+end
View
56 app/uploaders/file_uploader.rb
@@ -0,0 +1,56 @@
+# encoding: utf-8
+
+class FileUploader < CarrierWave::Uploader::Base
+
+ # Include RMagick or MiniMagick support:
+ # include CarrierWave::RMagick
+ # include CarrierWave::MiniMagick
+
+ # Include the Sprockets helpers for Rails 3.1+ asset pipeline compatibility:
+ # include Sprockets::Helpers::RailsHelper
+ # include Sprockets::Helpers::IsolatedHelper
+
+ # Choose what kind of storage to use for this uploader:
+ storage :file
+ # storage :fog
+
+ # Override the directory where uploaded files will be stored.
+ # This is a sensible default for uploaders that are meant to be mounted:
+ def store_dir
+ # uploads/#{model.class.to_s.underscore}/
+ "#{mounted_as}/#{model.id}"
+ end
+
+ # Provide a default URL as a default if there hasn't been a file uploaded:
+ # def default_url
+ # # For Rails 3.1+ asset pipeline compatibility:
+ # # asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
+ #
+ # "/images/fallback/" + [version_name, "default.png"].compact.join('_')
+ # end
+
+ # Process files as they are uploaded:
+ # process :scale => [200, 300]
+ #
+ # def scale(width, height)
+ # # do something
+ # end
+
+ # Create different versions of your uploaded files:
+ # version :thumb do
+ # process :scale => [50, 50]
+ # end
+
+ # Add a white list of extensions which are allowed to be uploaded.
+ # For images you might use something like this:
+ # def extension_white_list
+ # %w(jpg jpeg gif png)
+ # end
+
+ # Override the filename of the uploaded files:
+ # Avoid using model.id or version_name here, see uploader/store.rb for details.
+ # def filename
+ # "something.jpg" if original_filename
+ # end
+
+end
View
60 app/uploaders/image_uploader.rb
@@ -0,0 +1,60 @@
+# encoding: utf-8
+
+class ImageUploader < CarrierWave::Uploader::Base
+
+ # Include RMagick or MiniMagick support:
+ # include CarrierWave::RMagick
+ # include CarrierWave::MiniMagick
+
+ # Include the Sprockets helpers for Rails 3.1+ asset pipeline compatibility:
+ # include Sprockets::Helpers::RailsHelper
+ # include Sprockets::Helpers::IsolatedHelper
+
+ # Choose what kind of storage to use for this uploader:
+ storage :file
+ # storage :fog
+
+ # Override the directory where uploaded files will be stored.
+ # This is a sensible default for uploaders that are meant to be mounted:
+ def store_dir
+ "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
+ end
+
+ process :resize_to_fit => [800, 800]
+ version :thumb do
+ process :resize_to_fill => [200,200]
+ end
+
+ # Provide a default URL as a default if there hasn't been a file uploaded:
+ # def default_url
+ # # For Rails 3.1+ asset pipeline compatibility:
+ # # asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
+ #
+ # "/images/fallback/" + [version_name, "default.png"].compact.join('_')
+ # end
+
+ # Process files as they are uploaded:
+ # process :scale => [200, 300]
+ #
+ # def scale(width, height)
+ # # do something
+ # end
+
+ # Create different versions of your uploaded files:
+ # version :thumb do
+ # process :scale => [50, 50]
+ # end
+
+ # Add a white list of extensions which are allowed to be uploaded.
+ # For images you might use something like this:
+ # def extension_white_list
+ # %w(jpg jpeg gif png)
+ # end
+
+ # Override the filename of the uploaded files:
+ # Avoid using model.id or version_name here, see uploader/store.rb for details.
+ # def filename
+ # "something.jpg" if original_filename
+ # end
+
+end
View
29 app/views/downloads/_form.html.erb
@@ -0,0 +1,29 @@
+<%= form_for(@download) do |f| %>
+ <% if @download.errors.any? %>
+ <div id="error_explanation">
+ <h2><%= pluralize(@download.errors.count, "error") %> prohibited this download from being saved:</h2>
+
+ <ul>
+ <% @download.errors.full_messages.each do |msg| %>
+ <li><%= msg %></li>
+ <% end %>
+ </ul>
+ </div>
+ <% end %>
+
+ <div class="field">
+ <%= f.label :name %><br />
+ <%= f.text_field :name %>
+ </div>
+ <div class="field">
+ <%= f.label :description %><br />
+ <%= f.text_area :description %>
+ </div>
+ <div class="field">
+ <%= f.label :file %><br />
+ <%= f.file_field :file %>
+ </div>
+ <div class="actions">
+ <%= f.submit %>
+ </div>
+<% end %>
View
6 app/views/downloads/edit.html.erb
@@ -0,0 +1,6 @@
+<h1>Editing download</h1>
+
+<%= render 'form' %>
+
+<%= link_to 'Show', @download %> |
+<%= link_to 'Back', downloads_path %>
View
26 app/views/downloads/index.html.erb
@@ -0,0 +1,26 @@
+<h1>Listing downloads</h1>
+
+<table>
+ <tr>
+ <th>Name</th>
+ <th>Description</th>
+ <th>File</th>
+ <th></th>
+ <th></th>
+ <th></th>
+ </tr>
+
+<% @downloads.each do |download| %>
+ <tr>
+ <td><%= link_to download.name, download.file.url %></td>
+ <td><%= download.description %></td>
+ <td><%= download.file %></td>
+ <td><%= link_to 'Edit', edit_download_path(download) %></td>
+ <td><%= link_to 'Destroy', download, confirm: 'Are you sure?', method: :delete %></td>
+ </tr>
+<% end %>
+</table>
+
+<br />
+
+<%= link_to 'New Download', new_download_path %>
View
5 app/views/downloads/new.html.erb
@@ -0,0 +1,5 @@
+<h1>New download</h1>
+
+<%= render 'form' %>
+
+<%= link_to 'Back', downloads_path %>
View
20 app/views/downloads/show.html.erb
@@ -0,0 +1,20 @@
+<p id="notice"><%= notice %></p>
+
+<p>
+ <b>Name:</b>
+ <%= @download.name %>
+</p>
+
+<p>
+ <b>Description:</b>
+ <%= @download.description %>
+</p>
+
+<p>
+ <b>File:</b>
+ <%= @download.file %>
+</p>
+
+
+<%= link_to 'Edit', edit_download_path(@download) %> |
+<%= link_to 'Back', downloads_path %>
View
2  app/views/layouts/application.html.erb
@@ -10,7 +10,7 @@
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<%= stylesheet_link_tag "application", :media => "all" %>
- <%= javascript_include_tag "application" %>
+ <%= javascript_include_tag "application", "//maps.googleapis.com/maps/api/js?sensor=false" %>
<%= csrf_meta_tags %>
</head>
<body>
View
12 app/views/pages/contact.html.erb
@@ -1,11 +1,15 @@
-<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=Unit+10,+Medlock+Court,+Manchester,+M11+2NB&amp;aq=&amp;sll=53.504206,-2.136095&amp;sspn=0.01192,0.026007&amp;ie=UTF8&amp;hq=&amp;hnear=Medlock+Court+Welcomb+Street,+Manchester+M11+2NB,+United+Kingdom&amp;t=m&amp;z=14&amp;ll=53.472169,-2.181558&amp;output=embed"></iframe>
+<div id="map_canvas"></div>
-<div class="address">
+<div id="address">
<span class="company">UrbanLites Ltd</spa>
<span>Unit 10, Medlock Court</span>
<span>The City Works</span>
<span>Manchester</span>
<span>M11 2NB</span>
- <span>Tel: +44 (0)161 402 3271</span>
- <span>Email: chris@urbanlites.com</span>
+ <span>+44 (0)161 402 3271</span>
+ <span><%= mail_to "chris@urbanlites.com" %></span>
+</div>
+
+<div id="downloads">
+<%= link_to "Downloads", downloads_path %>
</div>
View
20 app/views/projects/_form.html.erb
@@ -35,6 +35,26 @@
<%= f.label :equipment_used %><br />
<%= f.text_area :equipment_used %>
</div>
+
+ <fieldset id="videos" class="">
+ <legend>Videos</legend>
+ <%= label_tag :video_url %>
+ <%= text_field_tag :video_url, nil, id: 'video_url', placeholder: 'http://www.youtube.com/watch?v=xCT-MB5wdj4' %>
+ <%= button_tag "Add Video", id: 'add_video' %>
+ <div class="hint">Paste in the youtube url</div>
+ <ul id="video_list"></ul>
+ </fieldset>
+
+ <fieldset id="photos" class="">
+ <legend>Photos</legend>
+ <%= label_tag :add_photo %>
+ <ul id="photo_list">
+ <%= f.fields_for :photos do |p| %>
+ <%= p.file_field :image %>
+ <% end %>
+ </ul>
+ </fieldset>
+
<div class="actions">
<%= f.submit %>
</div>
View
7 app/views/projects/index.html.erb
@@ -1,13 +1,14 @@
<% @projects.each do |project| %>
<div>
- <%= link_to project.name, project %>
+ <h3><%= link_to project.name, project %></h3>
+ <span><%= link_to 'Edit', edit_project_path(project) %></span>
+ <span><%= link_to 'Destroy', project, confirm: 'Are you sure?', method: :delete %></span>
+
<span><%= project.who %></span>
<span><%= project.where %></span>
<span><%= project.what %></span>
<span><%= project.when %></span>
<span><%= project.equipment_used %></span>
- <span><%= link_to 'Edit', edit_project_path(project) %></span>
- <span><%= link_to 'Destroy', project, confirm: 'Are you sure?', method: :delete %></span>
</div>
<% end %>
View
22 app/views/projects/show.html.erb
@@ -1,5 +1,25 @@
+<div id="my-slideshow">
<h1><%= @project.name %></h1>
+<ul class="bjqs">
+ <li>
+ <div id="window">
+ aa
+ </div>
+ </li>
+ <li>
+ <div id="window">
+ bb
+ </div>
+ </li>
+ <li>
+ <div id="window">
+ cc
+ </div>
+ </li>
+</ul>
+</div>
+<div>
<p>
<b>Who:</b>
<%= @project.who %>
@@ -24,6 +44,6 @@
<b>Equipment used:</b>
<%= @project.equipment_used %>
</p>
-
+</div>
<%= link_to 'Edit', edit_project_path(@project) %>
View
2  app/views/services/index.html.erb
@@ -8,4 +8,4 @@
<% end %>
</ul>
-<%= link_to 'New Service', new_service_path %>
+<%#= link_to 'New Service', new_service_path %>
View
6 config/routes.rb
@@ -1,9 +1,11 @@
Urbanlites::Application.routes.draw do
+ resources :downloads
+
resources :projects
resources :services
- get 'pages/contact', as: 'contact'
- get 'pages/our_ethos', as: 'our_ethos'
+ match 'contact' => 'pages#contact', as: 'contact'
+ match 'our-ethos' => 'pages#our_ethos', as: 'our_ethos'
root to: 'pages#home'
end
View
12 db/migrate/20120329110345_create_videos.rb
@@ -0,0 +1,12 @@
+class CreateVideos < ActiveRecord::Migration
+ def change
+ create_table :videos do |t|
+ t.string :name
+ t.string :url
+ t.references :project
+
+ t.timestamps
+ end
+ add_index :videos, :project_id
+ end
+end
View
12 db/migrate/20120329113301_create_photos.rb
@@ -0,0 +1,12 @@
+class CreatePhotos < ActiveRecord::Migration
+ def change
+ create_table :photos do |t|
+ t.string :name
+ t.string :image
+ t.integer :project_id
+ t.integer :ordinal
+
+ t.timestamps
+ end
+ end
+end
View
11 db/migrate/20120329130823_create_downloads.rb
@@ -0,0 +1,11 @@
+class CreateDownloads < ActiveRecord::Migration
+ def change
+ create_table :downloads do |t|
+ t.string :name
+ t.string :description
+ t.string :file
+
+ t.timestamps
+ end
+ end
+end
View
29 db/schema.rb
@@ -11,7 +11,24 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120329095849) do
+ActiveRecord::Schema.define(:version => 20120329130823) do
+
+ create_table "downloads", :force => true do |t|
+ t.string "name"
+ t.string "description"
+ t.string "file"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
+ create_table "photos", :force => true do |t|
+ t.string "name"
+ t.string "image"
+ t.integer "project_id"
+ t.integer "ordinal"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
create_table "projects", :force => true do |t|
t.string "slug"
@@ -38,4 +55,14 @@
add_index "services", ["ordinal"], :name => "index_services_on_ordinal"
+ create_table "videos", :force => true do |t|
+ t.string "name"
+ t.string "url"
+ t.integer "project_id"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
+ add_index "videos", ["project_id"], :name => "index_videos_on_project_id"
+
end
View
BIN  public/file/1/Brief_01.pdf
Binary file not shown
View
BIN  public/file/2/Wireframes_01.pdf
Binary file not shown
View
BIN  public/uploads/download/file/1/Brief_01.pdf
Binary file not shown
View
164 spec/controllers/downloads_controller_spec.rb
@@ -0,0 +1,164 @@
+require 'spec_helper'
+
+# This spec was generated by rspec-rails when you ran the scaffold generator.
+# It demonstrates how one might use RSpec to specify the controller code that
+# was generated by Rails when you ran the scaffold generator.
+#
+# It assumes that the implementation code is generated by the rails scaffold
+# generator. If you are using any extension libraries to generate different
+# controller code, this generated spec may or may not pass.
+#
+# It only uses APIs available in rails and/or rspec-rails. There are a number
+# of tools you can use to make these specs even more expressive, but we're
+# sticking to rails and rspec-rails APIs to keep things simple and stable.
+#
+# Compared to earlier versions of this generator, there is very limited use of
+# stubs and message expectations in this spec. Stubs are only used when there
+# is no simpler way to get a handle on the object needed for the example.
+# Message expectations are only used when there is no simpler way to specify
+# that an instance is receiving a specific message.
+
+describe DownloadsController do
+
+ # This should return the minimal set of attributes required to create a valid
+ # Download. As you add validations to Download, be sure to
+ # update the return value of this method accordingly.
+ def valid_attributes
+ {}
+ end
+
+ # This should return the minimal set of values that should be in the session
+ # in order to pass any filters (e.g. authentication) defined in
+ # DownloadsController. Be sure to keep this updated too.
+ def valid_session
+ {}
+ end
+
+ describe "GET index" do
+ it "assigns all downloads as @downloads" do
+ download = Download.create! valid_attributes
+ get :index, {}, valid_session
+ assigns(:downloads).should eq([download])
+ end
+ end
+
+ describe "GET show" do
+ it "assigns the requested download as @download" do
+ download = Download.create! valid_attributes
+ get :show, {:id => download.to_param}, valid_session
+ assigns(:download).should eq(download)
+ end
+ end
+
+ describe "GET new" do
+ it "assigns a new download as @download" do
+ get :new, {}, valid_session
+ assigns(:download).should be_a_new(Download)
+ end
+ end
+
+ describe "GET edit" do
+ it "assigns the requested download as @download" do
+ download = Download.create! valid_attributes
+ get :edit, {:id => download.to_param}, valid_session
+ assigns(:download).should eq(download)
+ end
+ end
+
+ describe "POST create" do
+ describe "with valid params" do
+ it "creates a new Download" do
+ expect {
+ post :create, {:download => valid_attributes}, valid_session
+ }.to change(Download, :count).by(1)
+ end
+
+ it "assigns a newly created download as @download" do
+ post :create, {:download => valid_attributes}, valid_session
+ assigns(:download).should be_a(Download)
+ assigns(:download).should be_persisted
+ end
+
+ it "redirects to the created download" do
+ post :create, {:download => valid_attributes}, valid_session
+ response.should redirect_to(Download.last)
+ end
+ end
+
+ describe "with invalid params" do
+ it "assigns a newly created but unsaved download as @download" do
+ # Trigger the behavior that occurs when invalid params are submitted
+ Download.any_instance.stub(:save).and_return(false)
+ post :create, {:download => {}}, valid_session
+ assigns(:download).should be_a_new(Download)
+ end
+
+ it "re-renders the 'new' template" do
+ # Trigger the behavior that occurs when invalid params are submitted
+ Download.any_instance.stub(:save).and_return(false)
+ post :create, {:download => {}}, valid_session
+ response.should render_template("new")
+ end
+ end
+ end
+
+ describe "PUT update" do
+ describe "with valid params" do
+ it "updates the requested download" do
+ download = Download.create! valid_attributes
+ # Assuming there are no other downloads in the database, this
+ # specifies that the Download created on the previous line
+ # receives the :update_attributes message with whatever params are
+ # submitted in the request.
+ Download.any_instance.should_receive(:update_attributes).with({'these' => 'params'})
+ put :update, {:id => download.to_param, :download => {'these' => 'params'}}, valid_session
+ end
+
+ it "assigns the requested download as @download" do
+ download = Download.create! valid_attributes
+ put :update, {:id => download.to_param, :download => valid_attributes}, valid_session
+ assigns(:download).should eq(download)
+ end
+
+ it "redirects to the download" do
+ download = Download.create! valid_attributes
+ put :update, {:id => download.to_param, :download => valid_attributes}, valid_session
+ response.should redirect_to(download)
+ end
+ end
+
+ describe "with invalid params" do
+ it "assigns the download as @download" do
+ download = Download.create! valid_attributes
+ # Trigger the behavior that occurs when invalid params are submitted
+ Download.any_instance.stub(:save).and_return(false)
+ put :update, {:id => download.to_param, :download => {}}, valid_session
+ assigns(:download).should eq(download)
+ end
+
+ it "re-renders the 'edit' template" do
+ download = Download.create! valid_attributes
+ # Trigger the behavior that occurs when invalid params are submitted
+ Download.any_instance.stub(:save).and_return(false)
+ put :update, {:id => download.to_param, :download => {}}, valid_session
+ response.should render_template("edit")
+ end
+ end
+ end
+
+ describe "DELETE destroy" do
+ it "destroys the requested download" do
+ download = Download.create! valid_attributes
+ expect {
+ delete :destroy, {:id => download.to_param}, valid_session
+ }.to change(Download, :count).by(-1)
+ end
+
+ it "redirects to the downloads list" do
+ download = Download.create! valid_attributes
+ delete :destroy, {:id => download.to_param}, valid_session
+ response.should redirect_to(downloads_url)
+ end
+ end
+
+end
View
15 spec/helpers/downloads_helper_spec.rb
@@ -0,0 +1,15 @@
+require 'spec_helper'
+
+# Specs in this file have access to a helper object that includes
+# the DownloadsHelper. For example:
+#
+# describe DownloadsHelper do
+# describe "string concat" do
+# it "concats two strings with spaces" do
+# helper.concat_strings("this","that").should == "this that"
+# end
+# end
+# end
+describe DownloadsHelper do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
View
5 spec/models/download_spec.rb
@@ -0,0 +1,5 @@
+require 'spec_helper'
+
+describe Download do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
View
5 spec/models/photo_spec.rb
@@ -0,0 +1,5 @@
+require 'spec_helper'
+
+describe Photo do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
View
5 spec/models/video_spec.rb
@@ -0,0 +1,5 @@
+require 'spec_helper'
+
+describe Video do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
View
11 spec/requests/downloads_spec.rb
@@ -0,0 +1,11 @@
+require 'spec_helper'
+
+describe "Downloads" do
+ describe "GET /downloads" do
+ it "works! (now write some real specs)" do
+ # Run the generator again with the --webrat flag if you want to use webrat methods/matchers
+ get downloads_path
+ response.status.should be(200)
+ end
+ end
+end
View
35 spec/routing/downloads_routing_spec.rb
@@ -0,0 +1,35 @@
+require "spec_helper"
+
+describe DownloadsController do
+ describe "routing" do
+
+ it "routes to #index" do
+ get("/downloads").should route_to("downloads#index")
+ end
+
+ it "routes to #new" do
+ get("/downloads/new").should route_to("downloads#new")
+ end
+
+ it "routes to #show" do
+ get("/downloads/1").should route_to("downloads#show", :id => "1")
+ end
+
+ it "routes to #edit" do
+ get("/downloads/1/edit").should route_to("downloads#edit", :id => "1")
+ end
+
+ it "routes to #create" do
+ post("/downloads").should route_to("downloads#create")
+ end
+
+ it "routes to #update" do
+ put("/downloads/1").should route_to("downloads#update", :id => "1")
+ end
+
+ it "routes to #destroy" do
+ delete("/downloads/1").should route_to("downloads#destroy", :id => "1")
+ end
+
+ end
+end
View
22 spec/views/downloads/edit.html.erb_spec.rb
@@ -0,0 +1,22 @@
+require 'spec_helper'
+
+describe "downloads/edit" do
+ before(:each) do
+ @download = assign(:download, stub_model(Download,
+ :name => "MyString",
+ :description => "MyString",
+ :file => "MyString"
+ ))
+ end
+
+ it "renders the edit download form" do
+ render
+
+ # Run the generator again with the --webrat flag if you want to use webrat matchers
+ assert_select "form", :action => downloads_path(@download), :method => "post" do
+ assert_select "input#download_name", :name => "download[name]"
+ assert_select "input#download_description", :name => "download[description]"
+ assert_select "input#download_file", :name => "download[file]"
+ end
+ end
+end
View
28 spec/views/downloads/index.html.erb_spec.rb
@@ -0,0 +1,28 @@
+require 'spec_helper'
+
+describe "downloads/index" do
+ before(:each) do
+ assign(:downloads, [
+ stub_model(Download,
+ :name => "Name",
+ :description => "Description",
+ :file => "File"
+ ),
+ stub_model(Download,
+ :name => "Name",
+ :description => "Description",
+ :file => "File"
+ )
+ ])
+ end
+
+ it "renders a list of downloads" do
+ render
+ # Run the generator again with the --webrat flag if you want to use webrat matchers
+ assert_select "tr>td", :text => "Name".to_s, :count => 2
+ # Run the generator again with the --webrat flag if you want to use webrat matchers
+ assert_select "tr>td", :text => "Description".to_s, :count => 2
+ # Run the generator again with the --webrat flag if you want to use webrat matchers
+ assert_select "tr>td", :text => "File".to_s, :count => 2
+ end
+end
View
22 spec/views/downloads/new.html.erb_spec.rb
@@ -0,0 +1,22 @@
+require 'spec_helper'
+
+describe "downloads/new" do
+ before(:each) do
+ assign(:download, stub_model(Download,
+ :name => "MyString",
+ :description => "MyString",
+ :file => "MyString"
+ ).as_new_record)
+ end
+
+ it "renders new download form" do
+ render
+
+ # Run the generator again with the --webrat flag if you want to use webrat matchers
+ assert_select "form", :action => downloads_path, :method => "post" do
+ assert_select "input#download_name", :name => "download[name]"
+ assert_select "input#download_description", :name => "download[description]"
+ assert_select "input#download_file", :name => "download[file]"
+ end
+ end
+end
View
21 spec/views/downloads/show.html.erb_spec.rb
@@ -0,0 +1,21 @@
+require 'spec_helper'
+
+describe "downloads/show" do
+ before(:each) do
+ @download = assign(:download, stub_model(Download,
+ :name => "Name",
+ :description => "Description",
+ :file => "File"
+ ))
+ end
+
+ it "renders attributes in <p>" do
+ render
+ # Run the generator again with the --webrat flag if you want to use webrat matchers
+ rendered.should match(/Name/)
+ # Run the generator again with the --webrat flag if you want to use webrat matchers
+ rendered.should match(/Description/)
+ # Run the generator again with the --webrat flag if you want to use webrat matchers
+ rendered.should match(/File/)
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.