Commit a928d4da
Changed files (10)
app
assets
javascripts
backbone
templates
cakes
controllers
views
cakes
my
cakes
spec
controllers
app/assets/javascripts/backbone/templates/cakes/cake.jst.ejs
@@ -7,6 +7,7 @@
<h3><a href="#/<%= id %>"><%= name %></a></h3>
<p><a href="#/<%= id %>/edit">(edit)</a></p>
<p><%= story %></p>
+ <span class="badge badge-warning"><i class="icon-comments"> <a href="<%= Routes.creation_path(id) %>#disqus_thread" data-disqus-identifier="c-<%= id %>"></a></i></span>
</div>
</div>
</div>
app/assets/javascripts/backbone/templates/cakes/index.jst.ejs
@@ -1,6 +1,11 @@
<div class="row">
<div class="span12">
- <a href="#/new">New Cake</a>
+ <a href="#/new" class="btn pull-right">Upload Cake</a>
+ <% if ( _.any(cakes) === false) { %>
+ <p>You haven't uploaded any cakes yet. <a href="#/new" class="btn pull-right">Get Started</a>.</p>
+ <% } %>
+ </div>
+ <div class="span12">
<div class="thumbnails"></div>
</div>
</div>
app/controllers/my/cakes_controller.rb
@@ -1,7 +1,6 @@
module My
class CakesController < BaseController
def index
- @creations = current_user.creations.includes([:user]).page(params[:page]).per(12)
end
end
end
app/controllers/cakes_controller.rb
@@ -1,7 +0,0 @@
-class CakesController < ApplicationController
- before_filter :authenticate_user!
-
- def index
- @cakes = current_user.creations
- end
-end
app/controllers/photos_controller.rb
@@ -1,6 +1,4 @@
class PhotosController < ApplicationController
- before_filter :authenticate_user!
-
def index
@creation = Creation.find(params[:creation_id])
@photos = @creation.photos
app/views/cakes/index.html.erb
@@ -1,7 +0,0 @@
-<%= content_for :javascript do -%>
- <%= javascript_tag do %>
- Cake.initialize({ access_token: '<%= current_user.authentication_token %>' });
- <% end %>
-<% end -%>
-
-<div id="cakes"></div>
app/views/my/cakes/index.html.erb
@@ -1,12 +1,8 @@
-<%= render :partial => "shared/account_nav", :locals => { :selected => :creations } %>
-<div class="row">
- <div class="span12">
- <%= link_to "Upload Cake", new_creation_path, :class => "btn pull-right" %>
- <% unless @creations.any? %>
- <p>You haven't uploaded any cakes yet. <%= link_to "Get Started", new_creation_path %>.</p>
- <% end %>
- </div>
- <div class="span12">
- <%= render "shared/creation_image_gallery" %>
- </div>
-</div>
+<%= content_for :javascript do -%>
+ <%= javascript_tag do %>
+ Cake.initialize({ access_token: '<%= current_user.authentication_token %>' });
+ <% end %>
+<% end -%>
+
+<%= render partial: "shared/account_nav", locals: { selected: :creations } %>
+<div id="cakes"></div>
spec/controllers/api/v1/cakes_controller_spec.rb
@@ -0,0 +1,23 @@
+require "rails_helper"
+
+describe Api::V1::CakesController do
+ context "when signed in" do
+ let(:user) { create(:user) }
+ let!(:my_cake) { create(:creation) }
+ let!(:other_cake) { create(:creation) }
+
+ before :each do
+ request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Token.encode_credentials(user.authentication_token)
+ user.creations << my_cake
+ get :index, :format => :json
+ end
+
+ it "should return all of my cakes" do
+ assigns(:cakes).should include(my_cake)
+ end
+
+ it "should not return any other cakes" do
+ assigns(:cakes).should_not include(other_cake)
+ end
+ end
+end
spec/controllers/api/v1/creations_controller_spec.rb
@@ -1,20 +0,0 @@
-require "rails_helper"
-
-describe Api::V1::CreationsController do
- context "when signed in" do
- let(:creation) { create(:creation) }
- let(:user) { create(:user) }
- let(:repository) { double }
-
- before :each do
- request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Token.encode_credentials(user.authentication_token)
- CreationRepository.any_instance.stub(:visible_creations).and_return([creation])
-
- get :index, :format => :json
- end
-
- it "should return all viewable creations" do
- assigns(:creations).should include(creation)
- end
- end
-end
spec/controllers/my/cakes_controller_spec.rb
@@ -6,20 +6,9 @@ describe My::CakesController do
before { http_login(user) }
describe "#index" do
- let!(:my_creation) { create(:creation) }
- let!(:other_creation) { create(:creation) }
-
- before :each do
- user.creations << my_creation
+ it "should let me int" do
get :index
- end
-
- it "should return all of my creations" do
- assigns(:creations).should include(my_creation)
- end
-
- it "should not return any other creations" do
- assigns(:creations).should_not include(other_creation)
+ expect(response).to be_success
end
end
end