mosaic-facebook 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +3 -1
- data/lib/mosaic/facebook/graph.rb +2 -1
- data/lib/mosaic/facebook/graph/event.rb +10 -0
- data/lib/mosaic/facebook/graph/page.rb +4 -0
- data/lib/mosaic/facebook/object.rb +1 -1
- data/lib/mosaic/facebook/version.rb +1 -1
- data/spec/facebook_config.yml.example +3 -0
- data/spec/mosaic-facebook/notification_spec.rb +5 -6
- data/spec/mosaic-facebook/page_spec.rb +17 -0
- data/spec/spec_helper.rb +7 -1
- metadata +7 -4
- data/spec/facebook_credentials.yml.example +0 -1
data/.gitignore
CHANGED
@@ -5,6 +5,7 @@ require 'mosaic/facebook/graph/application'
|
|
5
5
|
require 'mosaic/facebook/graph/comment'
|
6
6
|
require 'mosaic/facebook/graph/insights'
|
7
7
|
require 'mosaic/facebook/graph/page'
|
8
|
+
require 'mosaic/facebook/graph/event'
|
8
9
|
require 'mosaic/facebook/graph/post'
|
9
10
|
require 'mosaic/facebook/graph/subscription'
|
10
|
-
require 'mosaic/facebook/graph/user'
|
11
|
+
require 'mosaic/facebook/graph/user'
|
@@ -4,6 +4,10 @@ module Mosaic
|
|
4
4
|
class Page < Mosaic::Facebook::Graph::GraphObject
|
5
5
|
attr_accessor :id, :name, :picture, :link, :likes, :category, :can_post, :type, :from, :to
|
6
6
|
|
7
|
+
def events
|
8
|
+
@events ||= AssociationProxy.new(Mosaic::Facebook::Graph::Event, "/#{self.id}/events")
|
9
|
+
end
|
10
|
+
|
7
11
|
def feed
|
8
12
|
@feed ||= AssociationProxy.new(Mosaic::Facebook::Graph::Post, "/#{self.id}/feed")
|
9
13
|
end
|
@@ -3,24 +3,23 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper.rb
|
|
3
3
|
|
4
4
|
describe Mosaic::Facebook::Notification do
|
5
5
|
def options
|
6
|
-
options = {:recipients => "
|
6
|
+
options = {:recipients => "000000000", :subject => "testing", :text => "ajit", :access_token => "xxx"}
|
7
7
|
end
|
8
8
|
|
9
9
|
context "when no or invalid token is passed" do
|
10
10
|
it "should require an access_token" do
|
11
|
-
lambda { Mosaic::Facebook::Notification.send_email(options.merge(:access_token => nil)) }.should raise_error(Mosaic::Facebook::AccessTokenError, /
|
11
|
+
lambda { Mosaic::Facebook::Notification.send_email(options.merge(:access_token => nil)) }.should raise_error(Mosaic::Facebook::AccessTokenError, /Invalid application ID/i)
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should require a valid access_token" do
|
15
|
-
lambda {Mosaic::Facebook::Notification.send_email(options)}.should raise_error(Mosaic::Facebook::AccessTokenError, /INVALID OAUTH ACCESS TOKEN/i)
|
15
|
+
lambda {Mosaic::Facebook::Notification.send_email(options.merge(:recipients => RSpec.configuration.user_id))}.should raise_error(Mosaic::Facebook::AccessTokenError, /INVALID OAUTH ACCESS TOKEN/i)
|
16
16
|
end
|
17
17
|
|
18
18
|
end
|
19
19
|
|
20
|
-
|
21
20
|
context "when a valid access_token is provided" do
|
22
21
|
it "should send a notification" do
|
23
|
-
Mosaic::Facebook::Notification.send_email(options.merge(:access_token =>
|
22
|
+
Mosaic::Facebook::Notification.send_email(options.merge(:recipients => RSpec.configuration.user_id, :access_token => RSpec.configuration.access_token))
|
24
23
|
end
|
25
24
|
end
|
26
|
-
end
|
25
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper.rb'))
|
2
|
+
|
3
|
+
describe Mosaic::Facebook::Graph::Page do
|
4
|
+
context "when a valid token and page id are passed" do
|
5
|
+
it "should return a page feed" do
|
6
|
+
feed = Mosaic::Facebook::Graph::Page.new().feed.all({ :access_token => RSpec.configuration.access_token, :id => RSpec.configuration.page_id })
|
7
|
+
feed.should be_an_instance_of Array
|
8
|
+
feed.first.should be_an_instance_of Mosaic::Facebook::Graph::Post
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should return a event list" do
|
12
|
+
events = Mosaic::Facebook::Graph::Page.new().events.all({ :access_token => RSpec.configuration.access_token, :id => RSpec.configuration.page_id })
|
13
|
+
events.should be_an_instance_of Array
|
14
|
+
events.first.should be_an_instance_of Mosaic::Facebook::Graph::Event
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -11,4 +11,10 @@ SPEC_DIR = File.dirname(__FILE__)
|
|
11
11
|
# $LOAD_PATH.unshift lib_path unless $LOAD_PATH.include?(lib_path)
|
12
12
|
|
13
13
|
require 'mosaic-facebook'
|
14
|
-
|
14
|
+
FACEBOOK_CONFIG = YAML.load(File.open("#{SPEC_DIR}/facebook_config.yml", 'r'))
|
15
|
+
|
16
|
+
RSpec.configure do |config|
|
17
|
+
config.add_setting :access_token, :default => FACEBOOK_CONFIG["access_token"]
|
18
|
+
config.add_setting :user_id, :default => FACEBOOK_CONFIG["user_id"]
|
19
|
+
config.add_setting :page_id, :default => FACEBOOK_CONFIG["page_id"]
|
20
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mosaic-facebook
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-04-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
@@ -87,6 +87,7 @@ files:
|
|
87
87
|
- lib/mosaic/facebook/graph/application.rb
|
88
88
|
- lib/mosaic/facebook/graph/association_proxy.rb
|
89
89
|
- lib/mosaic/facebook/graph/comment.rb
|
90
|
+
- lib/mosaic/facebook/graph/event.rb
|
90
91
|
- lib/mosaic/facebook/graph/graph_object.rb
|
91
92
|
- lib/mosaic/facebook/graph/insights.rb
|
92
93
|
- lib/mosaic/facebook/graph/page.rb
|
@@ -98,8 +99,9 @@ files:
|
|
98
99
|
- lib/mosaic/facebook/version.rb
|
99
100
|
- lib/mosaic_facebook.rb
|
100
101
|
- mosaic-facebook.gemspec
|
101
|
-
- spec/
|
102
|
+
- spec/facebook_config.yml.example
|
102
103
|
- spec/mosaic-facebook/notification_spec.rb
|
104
|
+
- spec/mosaic-facebook/page_spec.rb
|
103
105
|
- spec/mosaic-facebook_spec.rb
|
104
106
|
- spec/spec.opts
|
105
107
|
- spec/spec_helper.rb
|
@@ -128,8 +130,9 @@ signing_key:
|
|
128
130
|
specification_version: 3
|
129
131
|
summary: gem/plugin to connect to facebook graph api
|
130
132
|
test_files:
|
131
|
-
- spec/
|
133
|
+
- spec/facebook_config.yml.example
|
132
134
|
- spec/mosaic-facebook/notification_spec.rb
|
135
|
+
- spec/mosaic-facebook/page_spec.rb
|
133
136
|
- spec/mosaic-facebook_spec.rb
|
134
137
|
- spec/spec.opts
|
135
138
|
- spec/spec_helper.rb
|
@@ -1 +0,0 @@
|
|
1
|
-
token: "Your token goes here"
|