Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mindtonic/1663798 to your computer and use it in GitHub Desktop.
Save mindtonic/1663798 to your computer and use it in GitHub Desktop.
From 8142eb61d276cda63f11daf8da015455cd0aa93e Mon Sep 17 00:00:00 2001
From: Jay Sanders <mindtonic@gmail.com>
Date: Mon, 23 Jan 2012 10:32:41 -0500
Subject: [PATCH] Working out Facebook Galleries installation
---
Gemfile.lock | 8 +-
app/controllers/facebook_controller.rb | 2 +-
app/controllers/workspace/galleries_controller.rb | 53 +-
app/models/facebook/page.rb | 29 +
.../galleries/add_to_facebook_page.html.haml | 54 -
app/views/workspace/galleries/show.html.haml | 7 +-
.../galleries/xxx_add_to_facebook_page.html.haml | 39 +
.../galleries/xxx_get_facebook_page.js.haml | 1 +
app/views/workspace/galleries/xxx_page.html.haml | 8 +
config/routes.rb | 3 +-
lib/facebook.rb | 30 +-
public/javascripts/facebook.js | 71 ++-
.../workspace/galleries_controller_spec.rb | 1060 ++++++++++----------
spec/routing/workspace/galleries_routing_spec.rb | 4 -
14 files changed, 749 insertions(+), 620 deletions(-)
create mode 100644 app/models/facebook/page.rb
delete mode 100644 app/views/workspace/galleries/add_to_facebook_page.html.haml
create mode 100644 app/views/workspace/galleries/xxx_add_to_facebook_page.html.haml
create mode 100644 app/views/workspace/galleries/xxx_get_facebook_page.js.haml
create mode 100644 app/views/workspace/galleries/xxx_page.html.haml
diff --git a/Gemfile.lock b/Gemfile.lock
index d9451ed..8be952a 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -162,7 +162,7 @@ GEM
json (1.6.1)
json_pure (1.6.1)
kgio (2.6.0)
- koala (1.2.1)
+ koala (1.3.0)
faraday (~> 0.7.0)
multi_json (~> 1.0)
launchy (2.0.5)
@@ -187,9 +187,9 @@ GEM
activemodel (~> 3.0)
activesupport (~> 3.0)
plucky (~> 0.4.0)
- multi_json (1.0.3)
+ multi_json (1.0.4)
multi_xml (0.4.1)
- multipart-post (1.1.3)
+ multipart-post (1.1.4)
net-ldap (0.2.2)
nokogiri (1.5.0)
oa-basic (0.3.2)
@@ -244,7 +244,7 @@ GEM
mongo (~> 1.3)
polyglot (0.3.3)
pyu-ruby-sasl (0.0.3.3)
- rack (1.2.4)
+ rack (1.2.5)
rack-mount (0.6.14)
rack (>= 1.0.0)
rack-openid (1.3.1)
diff --git a/app/controllers/facebook_controller.rb b/app/controllers/facebook_controller.rb
index 3eb3fb7..34bec9b 100644
--- a/app/controllers/facebook_controller.rb
+++ b/app/controllers/facebook_controller.rb
@@ -11,7 +11,7 @@ class FacebookController < ApplicationController
@gallery = @tab.gallery
@creations = @gallery.creations.random
@site_title = @gallery.title
-
+
respond_to do |format|
format.html { render :layout => 'facebook' }
end
diff --git a/app/controllers/workspace/galleries_controller.rb b/app/controllers/workspace/galleries_controller.rb
index 84d7eb9..f5cb897 100644
--- a/app/controllers/workspace/galleries_controller.rb
+++ b/app/controllers/workspace/galleries_controller.rb
@@ -191,24 +191,53 @@ class Workspace::GalleriesController < Workspace::WorkspaceController
format.js { head :ok }
end
end
-
+
#
# Assign a Gallery to a Facebook Page
#
-
- def add_to_facebook_page
- if !@user.has_facebook?
- store_location
- redirect_to "/auth/facebook"
+
+ def publish_to_facebook_page
+ @page_id = params[:page_id]
+
+ @tab = Facebook::Tab.find_by_gallery_id_and_facebook_page_id(@gallery.id, @page_id)
+ puts @tab.inspect
+
+
+ if @tab = Facebook::Tab.find_by_gallery_id_and_facebook_page_id(@gallery.id, @page_id)
+ @result = :existing_join
+ elsif @tab = Facebook::Tab.where(:facebook_page_id => @page_id).first
+ @result = :existing_page
else
- @pages = @user.facebook_page_objects
+ @tab = Facebook::Tab.create(:user => @user, :facebook_page_id => params[:page_id], :gallery => @gallery)
+ @result = :new_join
end
+ puts @result
+
+ respond_to do |format|
+ if @result == :new_join
+ redirect_to "https://www.facebook.com/dialog/pagetab?app_id=247436055289326&next=#{CGI::escape('http://facebook.com')}"
+ else
+ format.js
+ end
+ end
end
-
- def publish_to_facebook_page
- Facebook::Tab.create(:user => @user, :facebook_page_id => params[:page], :gallery => @gallery)
- redirect_to facebook_tabs_instructions_path
- end
+
+# #
+# # Get Facebook Page
+# #
+#
+# def get_facebook_page
+# @graph = Koala::Facebook::API.new
+# begin
+# @page = Facebook::Page.find(params[:page_id])
+# rescue Koala::Facebook::APIError
+# @error = "Page Not Found"
+# end
+#
+# respond_to do |format|
+# format.js
+# end
+# end
private
diff --git a/app/models/facebook/page.rb b/app/models/facebook/page.rb
new file mode 100644
index 0000000..0d4fcac
--- /dev/null
+++ b/app/models/facebook/page.rb
@@ -0,0 +1,29 @@
+class Facebook::Page
+ attr_accessor :id, :name, :category, :link, :likes, :image
+
+ def initialize(id, page)
+ @id = id
+ @name = page["name"]
+ @category = page["category"]
+ @link = page["link"]
+ @likes = page["likes"]
+ @image = page["picture"]
+ end
+
+ def is_page?
+ @category.present?
+ end
+
+ def is_application?
+ @link.include?('application.php')
+ end
+
+ def is_linked?(user)
+ Facebook::Tab.where(:facebook_page_id => @id, :user_id => user.id).any?
+ end
+
+ def self.find(id)
+ object = Koala::Facebook::API.new.get_object(id)
+ return Facebook::Page.new(id, object)
+ end
+end
\ No newline at end of file
diff --git a/app/views/workspace/galleries/add_to_facebook_page.html.haml b/app/views/workspace/galleries/add_to_facebook_page.html.haml
deleted file mode 100644
index 7df19ef..0000000
--- a/app/views/workspace/galleries/add_to_facebook_page.html.haml
+++ /dev/null
@@ -1,54 +0,0 @@
-:css
- #whichPage { font-size: 19px; font-weight: bold; margin: 20px 0px 25px 0px; }
- #chooseThePage { float:left; margin-top: 45px; font-family: georgia; font-style: italic; font-weight: normal; font-size: 16px; color: #D24F22; text-align: center; margin-left: 120px;}
- #publishTheTab { float:left; margin-top: 45px; font-family: georgia; font-style: italic; font-weight: normal; font-size: 16px; color: #cccccc; text-align: center; }
- .steps { text-align: center; margin-top: 25px; float: left; }
- #lastStep { font-size: 32px; font-family: georgia; font-style: italic; margin-top: 10px; margin-bottom: 18px; text-align: left;}
- h2.instructions { text-align: left; border-bottom: 0px dotted #cccccc; margin: 0px 0px 20px 0px; padding: 0px 0px 5px 0px; width: 620px;}
- .page { width: 690px; text-align: center; margin:0 10px 40px 0; padding: 10px 0px 0px 0px; margin: 0px 10px 40px 0; border-top: dotted 2px #ccc; }
- #fbBorder { border: 5px solid #ccc; padding: 10px 0px 10px 10px; -webkit-border-radius:10px; -moz-border-radius:10px; border-radius:10px; }
- #fbBorder #btmBorder { border-bottom: 2px dotted #ccc; margin: 0px 10px 0px 0px; }
- #fbBorder .page li .image { width: 100px; height: 150px; margin: 5px auto; }
- #fbBorder .page li .name { font-size: 16px; margin-top: 5px; }
- #fbBorder .page li { display: inline-block; }
- #fbBorder .page li .link { font-size:14px; color:#d24f22; border:1px solid #d7d7d7; background:#F0F0F0; -moz-border-radius:16px; -webkit-border-radius:16px; border-radius:16px; behavior:url(/stylesheets/PIE.htc); display:block; padding:4px 10px; margin-right:10px; }
- #fbBorder .page .fbIcon { float: left; margin: 6px 5px 0px 0px; }
- #fbBorder .page .image { width: 100px; height: 150px; margin: 5px auto; float: left; }
- #fbBorder .page .name { float: left; font-size: 16px; margin-top: 5px; }
- #fbBorder .page .category { float: left; font-size: 12px; margin-left: 10px; color: #666666; margin-top: 6px; }
- #fbBorder .page .link { font-weight: bold; float: right; font-size:14px; color:#d24f22; border:1px solid #d7d7d7; background:#F0F0F0; -moz-border-radius:3px; -webkit-border-radius:3px; border-radius:3px; behavior:url(/stylesheets/PIE.htc); display:block; padding:4px 10px; margin-right:10px; width: 130px; }
-
-#chooseThePage
- choose the page
-.steps
- =image_tag "layout/1of2.jpg"
-#publishTheTab
- publish the tab
-.clear
-/#lastStep First step...
-/%h2.instructions Which Facebook page do you want to add "#{@gallery.display_name}" to?
-/.clear
-
-#whichPage
- Which Facebook page do you want to add "#{@gallery.display_name}" to?
-
-#fbBorder
- - if @pages and @pages.any?
- - for page in @pages
- .page[page]
-
- .fbIcon= image_tag "../../images/social_networks/facebookSM.jpg"
-
- /.image= image_tag page.image unless page.image.nil?
-
- .name= page.name
- .category= page.category
- - if page.is_linked?(@user)
- .link Already Linked
- -else
- .link= link_to "Add To This Page", publish_to_facebook_page_workspace_gallery_path(@gallery, :page => page.id), :method => :post
- .clear
-
- - else
- It seems you do not have any Facebook pages.
- #btmBorder
\ No newline at end of file
diff --git a/app/views/workspace/galleries/show.html.haml b/app/views/workspace/galleries/show.html.haml
index 5116e5b..aca2931 100644
--- a/app/views/workspace/galleries/show.html.haml
+++ b/app/views/workspace/galleries/show.html.haml
@@ -61,9 +61,14 @@
#facebookTab
#previewEmbed
= link_to image_tag("../../images/icons/questionMarkWhite.png"), "http://www.creativeallies.com/more/adding-a-gallery-to-facebook", :target => "_blank"
- .shareHeader #{link_to "Click here to publish this Gallery to your Facebook Tab", add_to_facebook_page_workspace_gallery_path(@gallery)}
+ .shareHeader= link_to "Click here to publish this Gallery to your Facebook Tab", "javascript:;", :onclick => "facebook.getFacebookUserPages('#{@gallery.to_param}');"
.description{:style => "font-size: 12px; color: #666; font-style: italic;"} This will only work on Facebook Pages, not on individual profiles. You must be a Page admin in order to add our tab to your Page.
+ #fbBorder{:style => "display: none;"}
+ = form_tag publish_to_facebook_page_workspace_gallery_path(@gallery), :remote => true do
+ %select{:id => "fbPages", :name => "page_id"}
+ = submit_tag "Publish"
+
#galleryRightColumn
#galleryDescription
%h2
diff --git a/app/views/workspace/galleries/xxx_add_to_facebook_page.html.haml b/app/views/workspace/galleries/xxx_add_to_facebook_page.html.haml
new file mode 100644
index 0000000..e5fee4e
--- /dev/null
+++ b/app/views/workspace/galleries/xxx_add_to_facebook_page.html.haml
@@ -0,0 +1,39 @@
+:css
+ #whichPage { font-size: 19px; font-weight: bold; margin: 20px 0px 25px 0px; }
+ #chooseThePage { float:left; margin-top: 45px; font-family: georgia; font-style: italic; font-weight: normal; font-size: 16px; color: #D24F22; text-align: center; margin-left: 120px;}
+ #publishTheTab { float:left; margin-top: 45px; font-family: georgia; font-style: italic; font-weight: normal; font-size: 16px; color: #cccccc; text-align: center; }
+ .steps { text-align: center; margin-top: 25px; float: left; }
+ #lastStep { font-size: 32px; font-family: georgia; font-style: italic; margin-top: 10px; margin-bottom: 18px; text-align: left;}
+ h2.instructions { text-align: left; border-bottom: 0px dotted #cccccc; margin: 0px 0px 20px 0px; padding: 0px 0px 5px 0px; width: 620px;}
+ .page { width: 690px; text-align: center; margin:0 10px 40px 0; padding: 10px 0px 0px 0px; margin: 0px 10px 40px 0; border-top: dotted 2px #ccc; }
+ #fbBorder { border: 5px solid #ccc; padding: 10px 0px 10px 10px; -webkit-border-radius:10px; -moz-border-radius:10px; border-radius:10px; }
+ #fbBorder #btmBorder { border-bottom: 2px dotted #ccc; margin: 0px 10px 0px 0px; }
+ #fbBorder .page li .image { width: 100px; height: 150px; margin: 5px auto; }
+ #fbBorder .page li .name { font-size: 16px; margin-top: 5px; }
+ #fbBorder .page li { display: inline-block; }
+ #fbBorder .page li .link { font-size:14px; color:#d24f22; border:1px solid #d7d7d7; background:#F0F0F0; -moz-border-radius:16px; -webkit-border-radius:16px; border-radius:16px; behavior:url(/stylesheets/PIE.htc); display:block; padding:4px 10px; margin-right:10px; }
+ #fbBorder .page .fbIcon { float: left; margin: 6px 5px 0px 0px; }
+ #fbBorder .page .image { width: 100px; height: 150px; margin: 5px auto; float: left; }
+ #fbBorder .page .name { float: left; font-size: 16px; margin-top: 5px; }
+ #fbBorder .page .category { float: left; font-size: 12px; margin-left: 10px; color: #666666; margin-top: 6px; }
+ #fbBorder .page .link { font-weight: bold; float: right; font-size:14px; color:#d24f22; border:1px solid #d7d7d7; background:#F0F0F0; -moz-border-radius:3px; -webkit-border-radius:3px; border-radius:3px; behavior:url(/stylesheets/PIE.htc); display:block; padding:4px 10px; margin-right:10px; width: 130px; }
+
+#chooseThePage
+ choose the page
+.steps
+ =image_tag "layout/1of2.jpg"
+#publishTheTab
+ publish the tab
+.clear
+/#lastStep First step...
+/%h2.instructions Which Facebook page do you want to add "#{@gallery.display_name}" to?
+/.clear
+
+#whichPage
+ = link_to "Click here to Connect to Facebook so you can choose which page you want to add your gallery to.", "javascript:;", :onclick => "facebook.getFacebookUserPages('#{@gallery.to_param}');"
+ /Which Facebook page do you want to add "#{@gallery.display_name}" to?
+
+#fbBorder{:style => "display: none;"}
+ #fbPages
+
+ #btmBorder
\ No newline at end of file
diff --git a/app/views/workspace/galleries/xxx_get_facebook_page.js.haml b/app/views/workspace/galleries/xxx_get_facebook_page.js.haml
new file mode 100644
index 0000000..ba0aec8
--- /dev/null
+++ b/app/views/workspace/galleries/xxx_get_facebook_page.js.haml
@@ -0,0 +1 @@
+$("#page_#{@page.id}").html("#{escape_javascript(render :partial => "page", :locals => {:page => @page, :gallery => @gallery, :error => @error})}");
\ No newline at end of file
diff --git a/app/views/workspace/galleries/xxx_page.html.haml b/app/views/workspace/galleries/xxx_page.html.haml
new file mode 100644
index 0000000..aafd4b9
--- /dev/null
+++ b/app/views/workspace/galleries/xxx_page.html.haml
@@ -0,0 +1,8 @@
+.fbIcon= image_tag "../../images/social_networks/facebookSM.jpg"
+
+.name= page.name
+.category= page.category
+- if page.is_linked?(current_user)
+ .link Already Linked
+-else
+ .link= link_to "Add To This Page", publish_to_facebook_page_workspace_gallery_path(@gallery, :page => page.id), :method => :post
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index 76efaf5..35366ea 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -318,8 +318,7 @@ Creativeallies2::Application.routes.draw do
post 'publish'
delete 'unpublish'
post 'update_order'
- get 'add_to_facebook_page' => :add_to_facebook_page, :as => :add_to_facebook_page
- post 'add_to_facebook_page' => :publish_to_facebook_page, :as => :publish_to_facebook_page #<---------------------------
+ post 'add_to_facebook_page' => :publish_to_facebook_page, :as => :publish_to_facebook_page
end
put 'hang/:creation_id' => :hang, :as => :hang
delete 'hang/:creation_id' => :remove, :as => :remove
diff --git a/lib/facebook.rb b/lib/facebook.rb
index 5373f22..0726118 100644
--- a/lib/facebook.rb
+++ b/lib/facebook.rb
@@ -41,7 +41,7 @@ module Facebook
#
def get_open_graph
- @graph ||= Koala::Facebook::GraphAPI.new(facebook_token)
+ @graph ||= Koala::Facebook::API.new(facebook_token)
end
def facebook_token
@@ -64,7 +64,7 @@ module Facebook
facebook_page_ids = page_ids
if facebook_page_ids.any?
page_objects = []
- @graph.get_objects(page_ids).each {|page| page_objects << Page.new(page[0], page[1])}
+ @graph.get_objects(page_ids).each {|page| page_objects << Facebook::Page.new(page[0], page[1])}
page_objects.delete_if {|page| !page.is_page? }
page_objects
end
@@ -72,30 +72,4 @@ module Facebook
page_objects || false
end
-
- class Page
- attr_accessor :id, :name, :category, :link, :likes, :image
-
- def initialize(id, page)
- @id = id
- @name = page["name"]
- @category = page["category"]
- @link = page["link"]
- @likes = page["likes"]
- @image = page["picture"]
- end
-
- def is_page?
- @category.present?
- end
-
- def is_application?
- @link.include?('application.php')
- end
-
- def is_linked?(user)
- Facebook::Tab.where(:facebook_page_id => @id, :user_id => user.id).any?
- end
- end
-
end
\ No newline at end of file
diff --git a/public/javascripts/facebook.js b/public/javascripts/facebook.js
index 1f99825..3fb27f4 100644
--- a/public/javascripts/facebook.js
+++ b/public/javascripts/facebook.js
@@ -5,13 +5,14 @@ var facebook = {
===== VARIABLES =====
*/
- debug: false, // Determines whether we should output data to the console
+ debug: true, // Determines whether we should output data to the console
type: 'small', // Used to carry data about the voting type so that we can create the proper response
fbStatus: false, // Tracks whether the user is logged into Facebook or not
caStatus: false, // Tracks whether or not the user is logged into CA
userID: false, // Holds the User's FB ID
token: false, // Holds the User's FB Token
connected: false, // Tracks whether the User has connected their Facebook account to CA
+ permissions: 'email', // Permissions that we ask for
/*
===== STATE METHODS =====
@@ -72,7 +73,6 @@ var facebook = {
function doLogin() {
if (facebook.debug) { $.d('doing login'); }
- var requestedPermissions = 'publish_stream,create_event,email';
FB.login(function(response) {
if (response.authResponse) {
@@ -308,6 +308,69 @@ var facebook = {
},
/*
+ ===== ADD GALLERY TO PAGE METHODS =====
+
+ */
+ gallery_id: false, // variable to hold the gallery_id
+ // Get Pages
+ getFacebookUserPages: function(id) {
+ if (this.debug) { $.d("Get Pages For User"); }
+
+ this.gallery_id = id;
+
+ $.when(this.logInToFacebook(), this.showPageGrid())
+ .pipe(function() { facebook.getFacebookPages(); })
+ .done(function () { if (this.debug) { $.d("All Good"); }})
+ .fail(function () { if (this.debug) { $.d("Something went wrong"); }});
+ },
+ getFacebookPages: function() {
+ if (facebook.debug) { $.d('getFacebookPages()'); }
+ var deferred = $.Deferred();
+
+ function getPages() {
+ if (facebook.debug) { $.d('getPages()'); }
+
+ FB.login(function(response) {
+ if (response.authResponse) {
+ if (facebook.debug) { $.d("Permission Granted"); }
+ FB.api('/me/accounts/', function(response) {
+ if (facebook.debug) { $.d("Pages Pulled: "); }
+ for(var i = 0; i < response.data.length; i++) {
+ if(!response.data[i].category.match(/application/i)) {
+ if (facebook.debug) {
+ $.d(response.data[i].name+" -- "+response.data[i].id);
+ $.d(response.data[i]);
+ }
+ $('#fbPages').append('<option value="'+response.data[i].id+'">'+response.data[i].name+'</option>');
+ }
+ }
+ deferred.resolve();
+ });
+ } else {
+ $.d("Permission Denied");
+ deferred.reject();
+ }
+ }, {scope: 'manage_pages'});
+ }
+
+ $.when(getPages())
+ .done(function() { deferred.resolve(); })
+ .fail(function() { deferred.reject(); });
+
+ if (this.debug) { $.d('getFacebookPages '+deferred.state()); }
+ return deferred.promise();
+ },
+ showPageGrid: function(id) {
+ if (this.debug) { $.d('showPageGrid()'); }
+ var deferred = $.Deferred();
+
+ $('#fbBorder').show('slow', deferred.resolve);
+
+ if (this.debug) { $.d('showPageGrid '+deferred.state()); }
+ return deferred.promise();
+ },
+ /*
+
===== REFLECTION METHODS =====
*/
@@ -406,5 +469,9 @@ var facebook = {
}
/* $(document).ready(function(){ facebook.inviteToWatch() }); */
+/* $(document).ready(function(){ facebook.getFacebookUserPages(); }); */
+
+
+
diff --git a/spec/controllers/workspace/galleries_controller_spec.rb b/spec/controllers/workspace/galleries_controller_spec.rb
index d2305b8..2edca93 100644
--- a/spec/controllers/workspace/galleries_controller_spec.rb
+++ b/spec/controllers/workspace/galleries_controller_spec.rb
@@ -3,537 +3,573 @@ require 'spec_helper'
describe Workspace::GalleriesController do
render_views
- share_examples_for "workspace galleries" do
- describe "PUT hang" do
- before(:each) { put :hang, :gallery_id => '54', :creation_id => "12" }
- it_should_behave_like "require user"
- end
-
- describe "DELETE remove" do
- before(:each) { delete :remove, :gallery_id => '54', :creation_id => "12" }
- it_should_behave_like "require user"
- end
-
- describe "POST update_order" do
- before(:each) { post :update_order, :id => "12" }
- it_should_behave_like "require user"
- end
-
- describe "GET search_creations" do
- before(:each) { get :search_creations, :id => "12" }
- it_should_behave_like "require user"
- end
-
- describe "POST search_creations" do
- before(:each) { post :search_creations, :id => "12" }
- it_should_behave_like "require user"
- end
-
- describe "PUT update_caption" do
- before(:each) { put :update_caption, :gallery_id => '54', :creations_galleries_id => "12" }
- it_should_behave_like "require user"
- end
-
- describe "GET new_from_creation" do
- before(:each) { get :new_from_creation, :creation_id => "12" }
- it_should_behave_like "require user"
- end
-
- describe "POST create_from_creation" do
- before(:each) { get :create_from_creation, :creation_id => "12" }
- it_should_behave_like "require user"
- end
-
- describe "POST curate" do
- before(:each) { post :curate, :gallery_id => '54', :creation_id => "12" }
- it_should_behave_like "require user"
- end
-
- describe "GET add_to_facebook_page" do
- before(:each) { get :add_to_facebook_page, :id => "12" }
- it_should_behave_like "require user"
- end
-
- describe "POST publish_to_facebook_page" do
- before(:each) { post :publish_to_facebook_page, :id => "12" }
- it_should_behave_like "require user"
- end
- end
-
- context "When not logged in" do
- it_should_behave_like "workspace show views"
- it_should_behave_like "workspace new"
- it_should_behave_like "workspace edit"
- it_should_behave_like "workspace destroy"
- it_should_behave_like "workspace galleries"
- end
-
- #
- # Index
- #
-
- context "GET index" do
- before(:each) do
- login_user
- @gallery = Factory(:gallery, :user => @user)
- get :index
- end
-
- it_should_behave_like "workspace user"
- it { should assign_to(:galleries).with([@gallery]) }
- it { should respond_with(:success) }
- it { should render_template(:index) }
- end
-
- context "search_creations" do
- before(:each) do
- login_user
- @gallery = Factory(:gallery, :user => @user)
- Creation.stub!(:search).and_return(mock_creation)
- end
-
- context "GET" do
- before(:each) do
- get :search_creations, :id => @gallery.passkey, :query => @user.unique_url
- end
-
- it { should assign_to(:query) }
- it { should assign_to(:creations) }
- it { should respond_with(:success) }
- it { should render_template(:show) }
- end
-
- context "POST" do
- before(:each) do
- post :search_creations, :id => @gallery.passkey, :query => @user.unique_url
- end
-
- it { should assign_to(:query) }
- it { should assign_to(:creations) }
- it { should respond_with(:success) }
- it { should render_template(:show) }
- end
- end
-
- #
- # Show
- #
-
- context "GET show" do
- before(:each) do
- login_user
- @gallery = Factory(:gallery, :user => @user)
- get :show, :id => @gallery.passkey
- end
-
- it_should_behave_like "workspace user"
- it { should assign_to(:gallery).with(@gallery) }
- it { should assign_to(:creations) }
- it { should respond_with(:success) }
- it { should render_template(:show) }
- end
-
- #
- # New
- #
-
- context "GET new" do
- before(:each) do
- login_user
- get :new
- end
-
- it_should_behave_like "workspace user"
- it { should respond_with(:success) }
- it { should render_template(:new) }
- end
-
- context "GET new_from_creation" do
- before(:each) do
- login_user
- Creation.stub(:find) { mock_creation }
- get :new_from_creation, :creation_id => "12"
- end
-
- it_should_behave_like "workspace user"
- it { should assign_to(:creation) }
- it { should respond_with(:success) }
- it { should render_template(:new_from_creation) }
- end
+# share_examples_for "workspace galleries" do
+# describe "PUT hang" do
+# before(:each) { put :hang, :gallery_id => '54', :creation_id => "12" }
+# it_should_behave_like "require user"
+# end
+#
+# describe "DELETE remove" do
+# before(:each) { delete :remove, :gallery_id => '54', :creation_id => "12" }
+# it_should_behave_like "require user"
+# end
+#
+# describe "POST update_order" do
+# before(:each) { post :update_order, :id => "12" }
+# it_should_behave_like "require user"
+# end
+#
+# describe "GET search_creations" do
+# before(:each) { get :search_creations, :id => "12" }
+# it_should_behave_like "require user"
+# end
+#
+# describe "POST search_creations" do
+# before(:each) { post :search_creations, :id => "12" }
+# it_should_behave_like "require user"
+# end
+#
+# describe "PUT update_caption" do
+# before(:each) { put :update_caption, :gallery_id => '54', :creations_galleries_id => "12" }
+# it_should_behave_like "require user"
+# end
+#
+# describe "GET new_from_creation" do
+# before(:each) { get :new_from_creation, :creation_id => "12" }
+# it_should_behave_like "require user"
+# end
+#
+# describe "POST create_from_creation" do
+# before(:each) { get :create_from_creation, :creation_id => "12" }
+# it_should_behave_like "require user"
+# end
+#
+# describe "POST curate" do
+# before(:each) { post :curate, :gallery_id => '54', :creation_id => "12" }
+# it_should_behave_like "require user"
+# end
+#
+# describe "POST publish_to_facebook_page" do
+# before(:each) { post :publish_to_facebook_page, :id => "12" }
+# it_should_behave_like "require user"
+# end
+# end
+#
+# context "When not logged in" do
+# it_should_behave_like "workspace show views"
+# it_should_behave_like "workspace new"
+# it_should_behave_like "workspace edit"
+# it_should_behave_like "workspace destroy"
+# it_should_behave_like "workspace galleries"
+# end
+#
+# #
+# # Index
+# #
+#
+# context "GET index" do
+# before(:each) do
+# login_user
+# @gallery = Factory(:gallery, :user => @user)
+# get :index
+# end
+#
+# it_should_behave_like "workspace user"
+# it { should assign_to(:galleries).with([@gallery]) }
+# it { should respond_with(:success) }
+# it { should render_template(:index) }
+# end
+#
+# context "search_creations" do
+# before(:each) do
+# login_user
+# @gallery = Factory(:gallery, :user => @user)
+# Creation.stub!(:search).and_return(mock_creation)
+# end
+#
+# context "GET" do
+# before(:each) do
+# get :search_creations, :id => @gallery.passkey, :query => @user.unique_url
+# end
+#
+# it { should assign_to(:query) }
+# it { should assign_to(:creations) }
+# it { should respond_with(:success) }
+# it { should render_template(:show) }
+# end
+#
+# context "POST" do
+# before(:each) do
+# post :search_creations, :id => @gallery.passkey, :query => @user.unique_url
+# end
+#
+# it { should assign_to(:query) }
+# it { should assign_to(:creations) }
+# it { should respond_with(:success) }
+# it { should render_template(:show) }
+# end
+# end
+#
+# #
+# # Show
+# #
+#
+# context "GET show" do
+# before(:each) do
+# login_user
+# @gallery = Factory(:gallery, :user => @user)
+# get :show, :id => @gallery.passkey
+# end
+#
+# it_should_behave_like "workspace user"
+# it { should assign_to(:gallery).with(@gallery) }
+# it { should assign_to(:creations) }
+# it { should respond_with(:success) }
+# it { should render_template(:show) }
+# end
+#
+# #
+# # New
+# #
+#
+# context "GET new" do
+# before(:each) do
+# login_user
+# get :new
+# end
+#
+# it_should_behave_like "workspace user"
+# it { should respond_with(:success) }
+# it { should render_template(:new) }
+# end
+#
+# context "GET new_from_creation" do
+# before(:each) do
+# login_user
+# Creation.stub(:find) { mock_creation }
+# get :new_from_creation, :creation_id => "12"
+# end
+#
+# it_should_behave_like "workspace user"
+# it { should assign_to(:creation) }
+# it { should respond_with(:success) }
+# it { should render_template(:new_from_creation) }
+# end
+#
+# #
+# # Create
+# #
+#
+# context "POST create" do
+# describe "with valid params" do
+# before(:each) do
+# login_user
+# post :create, :gallery => Factory.attributes_for(:gallery)
+# end
+#
+# it_should_behave_like "workspace user"
+# it { should assign_to(:gallery) }
+# it { should respond_with(:redirect) }
+# it { should redirect_to(workspace_gallery_path(assigns(:gallery))) }
+#
+# it "should assign the current_user to the Gallery as the User" do
+# assigns(:gallery).user.should be == @user
+# end
+# end
+#
+# describe "with invalid params" do
+# before(:each) do
+# login_user
+# post :create, :gallery => Factory.attributes_for(:gallery, :title => nil)
+# end
+#
+# it_should_behave_like "workspace user"
+# it { should assign_to(:gallery) }
+# it { should respond_with(:success) }
+# it { should render_template(:new) }
+# end
+# end
+#
+# context "POST create_from_creation" do
+# describe "with valid params" do
+# before(:each) do
+# login_user
+# @creation = Factory(:test_creation)
+# post :create_from_creation, :gallery => Factory.attributes_for(:gallery), :creation_id => @creation.id
+# end
+#
+# it_should_behave_like "workspace user"
+# it { should assign_to(:gallery) }
+# it { should assign_to(:creation) }
+# it { should respond_with(:redirect) }
+# it { should redirect_to(creation_path(assigns(:creation).passkey)) }
+#
+# it "should assign the current_user to the Gallery as the User" do
+# assigns(:gallery).user.should be == @user
+# end
+#
+# it "should assign the creation to the gallery" do
+# assigns(:gallery).creations.include?(assigns(:creation)).should == true
+# end
+# end
+#
+# describe "with invalid params" do
+# before(:each) do
+# login_user
+# @creation = Factory(:test_creation)
+# post :create_from_creation, :gallery => Factory.attributes_for(:gallery, :title => nil), :creation_id => @creation.id
+# end
+#
+# it_should_behave_like "workspace user"
+# it { should assign_to(:gallery) }
+# it { should assign_to(:creation) }
+# it { should respond_with(:success) }
+# it { should render_template(:new_from_creation) }
+# end
+# end
+#
+# #
+# # Edit
+# #
+#
+# context "GET edit" do
+# before(:each) do
+# login_user
+# @gallery = Factory(:gallery, :user => @user)
+# get :edit, :id => @gallery.passkey
+# end
+#
+# it_should_behave_like "workspace user"
+# it { should assign_to(:gallery).with(@gallery) }
+# it { should respond_with(:success) }
+# it { should render_template(:edit) }
+# end
+#
+# #
+# # Update
+# #
+#
+# context "PUT update" do
+# before(:each) do
+# login_user
+# @gallery = Factory(:gallery, :user => @user)
+# end
+#
+# describe "with valid params" do
+# before(:each) do
+# put :update, :id => @gallery.passkey, :gallery => {'description' => "New Description"}
+# end
+#
+# it_should_behave_like "workspace user"
+# it { should assign_to(:gallery).with(@gallery) }
+# it { should respond_with(:redirect) }
+# it { should redirect_to(workspace_gallery_path(assigns(:gallery))) }
+#
+# it "updates the requested gallery" do
+# assigns(:gallery).description.should == "New Description"
+# end
+# end
+#
+# describe "with invalid params" do
+# before(:each) do
+# put :update, :id => @gallery.passkey, :gallery => {'title' => nil}
+# end
+#
+# it_should_behave_like "workspace user"
+# it { should assign_to(:gallery).with(@gallery) }
+# it { should respond_with(:success) }
+# it { should render_template(:edit) }
+# end
+# end
+#
+# #
+# #
+# # Destroy
+#
+# context "DELETE destroy" do
+# before(:each) do
+# login_user
+# @gallery = Factory(:gallery, :user => @user)
+# delete :destroy, :id => @gallery.passkey
+# end
+#
+# it_should_behave_like "workspace user"
+# it { should assign_to(:gallery).with(@gallery) }
+# it { should respond_with(:redirect) }
+# it { should redirect_to(workspace_galleries_path) }
+#
+# it "should set the flash" do
+# flash[:notice].should =~ /has been destroyed/
+# end
+# end
+#
+# #
+# # State Methods
+# #
+#
+# context "State Methods" do
+# before(:each) do
+# login_user
+# @gallery = Factory(:gallery, :user => @user)
+# end
+#
+# describe "POST 'publish'" do
+# before(:each) do
+# post :publish, :id => @gallery.passkey
+# end
+#
+# it_should_behave_like "workspace user"
+# it { should assign_to(:gallery) }
+# it { should respond_with(:redirect) }
+# it { should redirect_to(workspace_gallery_path(assigns(:gallery))) }
+#
+# it "should mark the gallery as published" do
+# assigns(:gallery).published?.should be true
+# end
+# end
+#
+# describe "DELETE 'unpublish'" do
+# before(:each) do
+# @gallery.publish
+# delete :unpublish, :id => @gallery.passkey
+# end
+#
+# it_should_behave_like "workspace user"
+# it { should assign_to(:gallery) }
+# it { should respond_with(:redirect) }
+# it { should redirect_to(workspace_gallery_path(assigns(:gallery))) }
+#
+# it "should mark the gallery as unpublished" do
+# assigns(:gallery).unpublished?.should be true
+# end
+# end
+# end
+#
+# #
+# # Hang and Remove
+# #
+#
+# context "Hang and Remove Elements" do
+# before(:each) do
+# login_user
+# @gallery = Factory(:gallery, :user => @user)
+# test_creation
+# end
+#
+# describe "PUT 'hang'" do
+# before(:each) do
+# put :hang, :gallery_id => @gallery.passkey, :creation_id => @creation.id
+# end
+#
+# it_should_behave_like "workspace user"
+# it { should assign_to(:gallery).with(@gallery) }
+# it { should assign_to(:creation).with(@creation) }
+# it { should respond_with(:redirect) }
+# it { should redirect_to(workspace_gallery_path(assigns(:gallery))) }
+#
+# it "should add the creation to the gallery" do
+# assigns(:gallery).creations.include?(@creation).should be true
+# end
+# end
+#
+# describe "DELETE 'remove'" do
+# before(:each) do
+# @gallery.hang @creation
+# delete :remove, :gallery_id => @gallery.passkey, :creation_id => @creation.id
+# end
+#
+# it_should_behave_like "workspace user"
+# it { should assign_to(:gallery).with(@gallery) }
+# it { should assign_to(:creation).with(@creation) }
+# it { should respond_with(:redirect) }
+# it { should redirect_to(workspace_gallery_path(assigns(:gallery))) }
+#
+# it "should remove the creation from the gallery" do
+# assigns(:gallery).creations.include?(@creation).should be false
+# end
+# end
+# end
+#
+# #
+# # Update Element Order
+# #
+#
+# context "POST update_order" do
+# before(:each) do
+# login_user
+# @gallery = Factory(:gallery, :user => @user)
+# test_creation
+# end
+#
+# describe "with valid params" do
+# before(:each) do
+# @gallery.hang @creation
+# post :update_order, :id => @gallery.passkey, :order => "creation_#{@creation.id}"
+# end
+#
+# it { should assign_to(:gallery).with(@gallery) }
+# it { should respond_with(200) }
+#
+# it "updates the requested gallery" do
+# assigns(:gallery).creations_galleries.first.order.should == 1
+# end
+# end
+#
+# describe "with invalid params" do
+# before(:each) do
+# @gallery.hang @creation
+# post :update_order, :id => @gallery.passkey, :order => "jeremiah was a bullfrog"
+# end
+#
+# it { should assign_to(:gallery).with(@gallery) }
+# it { should respond_with(200) }
+#
+# it "does not update the requested collection" do
+# assigns(:gallery).creations_galleries.first.order.should == 1
+# end
+# end
+# end
+#
+# #
+# # Update Element Caption
+# #
+#
+# context "PUT 'update_caption'" do
+# before(:each) do
+# login_user
+# @gallery = Factory(:gallery, :user => @user)
+# test_creation
+# @creations_gallery = CreationsGallery.create(:gallery => @gallery, :creation => @creation)
+# put :update_caption, :gallery_id => @gallery.passkey, :creations_galleries_id => @creations_gallery.id, :creations_gallery => {:caption => "I like rice!"}
+# end
+#
+# it { should assign_to(:gallery).with(@gallery) }
+# it { should assign_to(:creations_gallery).with(@creations_gallery) }
+# it { should respond_with(:redirect) }
+# it { should redirect_to(workspace_gallery_path(assigns(:gallery))) }
+#
+# it "should set the caption on the element" do
+# assigns(:creations_gallery).caption.should == "I like rice!"
+# end
+# end
+#
+# #
+# # Curate Creations From The Gallery Show Page
+# #
+#
+# context "Curate Creations" do
+# before(:each) do
+# login_user
+# @gallery = Factory(:gallery, :user => @user)
+# test_creation
+# end
+#
+# describe "POST 'curate' when adding the Creation to the Gallery" do
+# before(:each) do
+# post :curate, :gallery_id => @gallery.passkey, :creation_id => @creation.id
+# end
+#
+# it_should_behave_like "workspace user"
+# it { should assign_to(:gallery).with(@gallery) }
+# it { should assign_to(:creation).with(@creation) }
+# it { should respond_with(:redirect) }
+# it { should redirect_to(creation_path(assigns(:creation).passkey)) }
+#
+# it "should add the creation to the gallery" do
+# assigns(:gallery).creations.include?(@creation).should be true
+# end
+# end
+#
+# describe "POST 'curate' when removing the Creation from the Gallery" do
+# before(:each) do
+# @gallery.hang @creation
+# post :curate, :gallery_id => @gallery.passkey, :creation_id => @creation.id
+# end
+#
+# it_should_behave_like "workspace user"
+# it { should assign_to(:gallery).with(@gallery) }
+# it { should assign_to(:creation).with(@creation) }
+# it { should respond_with(:redirect) }
+# it { should redirect_to(creation_path(assigns(:creation).passkey)) }
+#
+# it "should remove the creation from the gallery" do
+# assigns(:gallery).creations.include?(@creation).should be false
+# end
+# end
+# end
#
- # Create
+ # Publish To Facebook Page
#
- context "POST create" do
- describe "with valid params" do
- before(:each) do
- login_user
- post :create, :gallery => Factory.attributes_for(:gallery)
- end
-
- it_should_behave_like "workspace user"
- it { should assign_to(:gallery) }
- it { should respond_with(:redirect) }
- it { should redirect_to(workspace_gallery_path(assigns(:gallery))) }
+ share_examples_for "publish Facebook page" do
+ it { should assign_to(:gallery).with(@gallery) }
+ it { should assign_to(:tab) }
- it "should assign the current_user to the Gallery as the User" do
- assigns(:gallery).user.should be == @user
- end
- end
-
- describe "with invalid params" do
- before(:each) do
- login_user
- post :create, :gallery => Factory.attributes_for(:gallery, :title => nil)
- end
-
- it_should_behave_like "workspace user"
- it { should assign_to(:gallery) }
- it { should respond_with(:success) }
- it { should render_template(:new) }
+ it "should create a Facebook::Tab" do
+ assigns(:tab).should be_a_kind_of Facebook::Tab
end
end
- context "POST create_from_creation" do
- describe "with valid params" do
- before(:each) do
- login_user
- @creation = Factory(:test_creation)
- post :create_from_creation, :gallery => Factory.attributes_for(:gallery), :creation_id => @creation.id
- end
-
- it_should_behave_like "workspace user"
- it { should assign_to(:gallery) }
- it { should assign_to(:creation) }
- it { should respond_with(:redirect) }
- it { should redirect_to(creation_path(assigns(:creation).passkey)) }
-
- it "should assign the current_user to the Gallery as the User" do
- assigns(:gallery).user.should be == @user
- end
-
- it "should assign the creation to the gallery" do
- assigns(:gallery).creations.include?(assigns(:creation)).should == true
- end
- end
-
- describe "with invalid params" do
- before(:each) do
- login_user
- @creation = Factory(:test_creation)
- post :create_from_creation, :gallery => Factory.attributes_for(:gallery, :title => nil), :creation_id => @creation.id
- end
-
- it_should_behave_like "workspace user"
- it { should assign_to(:gallery) }
- it { should assign_to(:creation) }
- it { should respond_with(:success) }
- it { should render_template(:new_from_creation) }
- end
- end
-
- #
- # Edit
- #
-
- context "GET edit" do
- before(:each) do
- login_user
- @gallery = Factory(:gallery, :user => @user)
- get :edit, :id => @gallery.passkey
- end
-
- it_should_behave_like "workspace user"
- it { should assign_to(:gallery).with(@gallery) }
- it { should respond_with(:success) }
- it { should render_template(:edit) }
- end
-
- #
- # Update
- #
-
- context "PUT update" do
+ describe "POST publish_to_facebook_page" do
before(:each) do
- login_user
- @gallery = Factory(:gallery, :user => @user)
- end
-
- describe "with valid params" do
- before(:each) do
- put :update, :id => @gallery.passkey, :gallery => {'description' => "New Description"}
- end
-
- it_should_behave_like "workspace user"
- it { should assign_to(:gallery).with(@gallery) }
- it { should respond_with(:redirect) }
- it { should redirect_to(workspace_gallery_path(assigns(:gallery))) }
-
- it "updates the requested gallery" do
- assigns(:gallery).description.should == "New Description"
- end
- end
-
- describe "with invalid params" do
- before(:each) do
- put :update, :id => @gallery.passkey, :gallery => {'title' => nil}
- end
-
- it_should_behave_like "workspace user"
- it { should assign_to(:gallery).with(@gallery) }
- it { should respond_with(:success) }
- it { should render_template(:edit) }
- end
- end
-
- #
- #
- # Destroy
-
- context "DELETE destroy" do
- before(:each) do
login_user
@gallery = Factory(:gallery, :user => @user)
- delete :destroy, :id => @gallery.passkey
+ @page_id = 354706162147
end
-
- it_should_behave_like "workspace user"
- it { should assign_to(:gallery).with(@gallery) }
- it { should respond_with(:redirect) }
- it { should redirect_to(workspace_galleries_path) }
-
- it "should set the flash" do
- flash[:notice].should =~ /has been destroyed/
- end
- end
-
- #
- # State Methods
- #
-
- context "State Methods" do
- before(:each) do
- login_user
- @gallery = Factory(:gallery, :user => @user)
- end
-
- describe "POST 'publish'" do
- before(:each) do
- post :publish, :id => @gallery.passkey
- end
-
- it_should_behave_like "workspace user"
- it { should assign_to(:gallery) }
- it { should respond_with(:redirect) }
- it { should redirect_to(workspace_gallery_path(assigns(:gallery))) }
-
- it "should mark the gallery as published" do
- assigns(:gallery).published?.should be true
- end
- end
-
- describe "DELETE 'unpublish'" do
- before(:each) do
- @gallery.publish
- delete :unpublish, :id => @gallery.passkey
- end
-
- it_should_behave_like "workspace user"
- it { should assign_to(:gallery) }
- it { should respond_with(:redirect) }
- it { should redirect_to(workspace_gallery_path(assigns(:gallery))) }
-
- it "should mark the gallery as unpublished" do
- assigns(:gallery).unpublished?.should be true
- end
- end
- end
-
- #
- # Hang and Remove
- #
-
- context "Hang and Remove Elements" do
- before(:each) do
- login_user
- @gallery = Factory(:gallery, :user => @user)
- test_creation
- end
-
- describe "PUT 'hang'" do
- before(:each) do
- put :hang, :gallery_id => @gallery.passkey, :creation_id => @creation.id
- end
-
- it_should_behave_like "workspace user"
- it { should assign_to(:gallery).with(@gallery) }
- it { should assign_to(:creation).with(@creation) }
- it { should respond_with(:redirect) }
- it { should redirect_to(workspace_gallery_path(assigns(:gallery))) }
-
- it "should add the creation to the gallery" do
- assigns(:gallery).creations.include?(@creation).should be true
- end
- end
-
- describe "DELETE 'remove'" do
- before(:each) do
- @gallery.hang @creation
- delete :remove, :gallery_id => @gallery.passkey, :creation_id => @creation.id
- end
-
- it_should_behave_like "workspace user"
- it { should assign_to(:gallery).with(@gallery) }
- it { should assign_to(:creation).with(@creation) }
- it { should respond_with(:redirect) }
- it { should redirect_to(workspace_gallery_path(assigns(:gallery))) }
-
- it "should remove the creation from the gallery" do
- assigns(:gallery).creations.include?(@creation).should be false
- end
- end
- end
-
- #
- # Update Element Order
- #
-
- context "POST update_order" do
- before(:each) do
- login_user
- @gallery = Factory(:gallery, :user => @user)
- test_creation
- end
-
- describe "with valid params" do
- before(:each) do
- @gallery.hang @creation
- post :update_order, :id => @gallery.passkey, :order => "creation_#{@creation.id}"
- end
-
- it { should assign_to(:gallery).with(@gallery) }
- it { should respond_with(200) }
-
- it "updates the requested gallery" do
- assigns(:gallery).creations_galleries.first.order.should == 1
- end
- end
-
- describe "with invalid params" do
- before(:each) do
- @gallery.hang @creation
- post :update_order, :id => @gallery.passkey, :order => "jeremiah was a bullfrog"
- end
-
- it { should assign_to(:gallery).with(@gallery) }
- it { should respond_with(200) }
-
- it "does not update the requested collection" do
- assigns(:gallery).creations_galleries.first.order.should == 1
- end
- end
- end
-
- #
- # Update Element Caption
- #
-
- context "PUT 'update_caption'" do
- before(:each) do
- login_user
- @gallery = Factory(:gallery, :user => @user)
- test_creation
- @creations_gallery = CreationsGallery.create(:gallery => @gallery, :creation => @creation)
- put :update_caption, :gallery_id => @gallery.passkey, :creations_galleries_id => @creations_gallery.id, :creations_gallery => {:caption => "I like rice!"}
- end
-
- it { should assign_to(:gallery).with(@gallery) }
- it { should assign_to(:creations_gallery).with(@creations_gallery) }
- it { should respond_with(:redirect) }
- it { should redirect_to(workspace_gallery_path(assigns(:gallery))) }
-
- it "should set the caption on the element" do
- assigns(:creations_gallery).caption.should == "I like rice!"
- end
- end
-
- #
- # Curate Creations From The Gallery Show Page
- #
-
- context "Curate Creations" do
- before(:each) do
- login_user
- @gallery = Factory(:gallery, :user => @user)
- test_creation
- end
-
- describe "POST 'curate' when adding the Creation to the Gallery" do
- before(:each) do
- post :curate, :gallery_id => @gallery.passkey, :creation_id => @creation.id
- end
-
- it_should_behave_like "workspace user"
- it { should assign_to(:gallery).with(@gallery) }
- it { should assign_to(:creation).with(@creation) }
- it { should respond_with(:redirect) }
- it { should redirect_to(creation_path(assigns(:creation).passkey)) }
-
- it "should add the creation to the gallery" do
- assigns(:gallery).creations.include?(@creation).should be true
- end
- end
-
- describe "POST 'curate' when removing the Creation from the Gallery" do
- before(:each) do
- @gallery.hang @creation
- post :curate, :gallery_id => @gallery.passkey, :creation_id => @creation.id
+
+ context "Testing the Saving / Finding of Tabs in the test environment" do
+ before(:each) do
+ @tab = Facebook::Tab.create(:user => @user, :facebook_page_id => @page_id, :gallery => @gallery)
+ post :publish_to_facebook_page, :page => @page_id, :id => @gallery.to_param
end
- it_should_behave_like "workspace user"
- it { should assign_to(:gallery).with(@gallery) }
- it { should assign_to(:creation).with(@creation) }
- it { should respond_with(:redirect) }
- it { should redirect_to(creation_path(assigns(:creation).passkey)) }
-
- it "should remove the creation from the gallery" do
- assigns(:gallery).creations.include?(@creation).should be false
+ it_should_behave_like "publish Facebook page"
+ it { should assign_to(:result).with(:existing_join) }
+ it { should assign_to(:tab).with(@tab) }
+ it { should respond_with(:success) }
+
+ it "should pull the tab" do
+ Facebook::Tab.where(:gallery_id => @gallery.id, :facebook_page_id => @page_id).first.should == @tab
end
end
- end
-
- #
- # Add To Facebook Page
- #
- context "GET add_to_facebook_page" do
- before(:each) do
- login_user
- @gallery = Factory(:gallery, :user => @user)
- end
-
-# describe "When the user has Facebook Authenticated and has Pages" do
-# before(:each) do
-# @authentication = Factory(:authentication, :user => @user)
-# get :add_to_facebook_page, :id => @gallery.passkey
-# end
-#
-# it_should_behave_like "workspace user"
-# it { should assign_to(:gallery).with(@gallery) }
-# it { should assign_to(:pages) }
+# context "When it is a fresh new tab" do
+# before(:each){ post :publish_to_facebook_page, :page => @page_id, :id => @gallery.to_param }
+#
+# it_should_behave_like "publish Facebook page"
+# it { should assign_to(:result).with(:new_join) }
+# it { should respond_with(:redirect) }
+# it { should redirect_to("https://www.facebook.com/dialog/pagetab?app_id=247436055289326&next=#{CGI::escape(workspace_gallery_url(assigns(:gallery).to_param))}") }
+# end
+#
+# context "When the tab has been previously created for the Gallery and the Page" do
+# before(:each) do
+# @tab = Facebook::Tab.create(:user => @user, :facebook_page_id => @page_id, :gallery => @gallery)
+# post :publish_to_facebook_page, :page => @page_id, :id => @gallery.to_param
+# end
+#
+# it_should_behave_like "publish Facebook page"
+# it { should assign_to(:result).with(:existing_join) }
+# it { should assign_to(:tab).with(@tab) }
+# it { should respond_with(:success) }
+#
+# it "should pull the tab" do
+# Facebook::Tab.where(:gallery_id => @gallery.id, :facebook_page_id => @page_id).first.should == @tab
+# end
+# end
+#
+# context "When the tab has been previously created for the Page" do
+# before(:each) do
+# @tab = Facebook::Tab.create(:user => @user, :facebook_page_id => @page_id, :gallery_id => 8675309)
+# post :publish_to_facebook_page, :page => @page_id, :id => @gallery.to_param
+# end
+#
+# it_should_behave_like "publish Facebook page"
+# it { should assign_to(:result).with(:existing_page) }
+# it { should assign_to(:tab).with(@tab) }
# it { should respond_with(:success) }
-# it { should render_template(:add_to_facebook_page) }
# end
-
- describe "when the user does not have Facebook Authenticated" do
- before(:each) { get :add_to_facebook_page, :id => @gallery.passkey }
-
- it_should_behave_like "workspace user"
- it { should assign_to(:gallery).with(@gallery) }
- it { should respond_with(:redirect) }
- it { should redirect_to("/auth/facebook") }
- end
end
end
\ No newline at end of file
diff --git a/spec/routing/workspace/galleries_routing_spec.rb b/spec/routing/workspace/galleries_routing_spec.rb
index 4ae558a..0694a8e 100644
--- a/spec/routing/workspace/galleries_routing_spec.rb
+++ b/spec/routing/workspace/galleries_routing_spec.rb
@@ -75,10 +75,6 @@ describe Workspace::GalleriesController do
{ :post => "/workspace/galleries/54/curate/206" }.should route_to(:controller => "workspace/galleries", :action => "curate", :gallery_id => "54", :creation_id => "206")
end
- it "recognizes and generates #add_to_facebook_page" do
- { :get => "/workspace/galleries/1/add_to_facebook_page" }.should route_to(:controller => "workspace/galleries", :action => "add_to_facebook_page", :id => "1")
- end
-
it "recognizes and generates #publish_to_facebook_page" do
{ :post => "/workspace/galleries/1/add_to_facebook_page" }.should route_to(:controller => "workspace/galleries", :action => "publish_to_facebook_page", :id => "1")
end
--
1.7.4.4+GitX
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment