mage-hand 0.4.4 → 0.4.5
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/Gemfile +5 -2
- data/Gemfile.lock +70 -3
- data/VERSION +1 -1
- data/lib/ob_port/base.rb +6 -4
- data/lib/ob_port/campaign.rb +2 -2
- data/lib/ob_port/client.rb +8 -10
- data/lib/ob_port/wiki_page.rb +12 -4
- data/mage-hand.gemspec +8 -8
- data/test/helper.rb +1 -0
- data/test/test_base.rb +6 -5
- data/test/test_campaign.rb +3 -3
- data/test/test_client.rb +12 -1
- data/test/test_mage_hand_controller.rb +30 -2
- metadata +8 -8
data/Gemfile
CHANGED
@@ -2,10 +2,13 @@ source "http://rubygems.org"
|
|
2
2
|
# Add dependencies required to use your gem here.
|
3
3
|
# Example:
|
4
4
|
# gem "activesupport", ">= 2.3.5"
|
5
|
-
gem "oauth", "
|
5
|
+
gem "oauth", "= 0.4.4"
|
6
6
|
gem "json"
|
7
7
|
gem 'i18n'
|
8
|
-
gem '
|
8
|
+
gem 'rails', ">= 3.0.0"
|
9
|
+
|
10
|
+
# gem 'actioncontroller'
|
11
|
+
# gem 'activesupport'
|
9
12
|
|
10
13
|
# Add dependencies to develop your gem here.
|
11
14
|
# Include everything needed to run rake, tests, features, etc.
|
data/Gemfile.lock
CHANGED
@@ -1,24 +1,81 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
+
actionmailer (3.2.2)
|
5
|
+
actionpack (= 3.2.2)
|
6
|
+
mail (~> 2.4.0)
|
7
|
+
actionpack (3.2.2)
|
8
|
+
activemodel (= 3.2.2)
|
9
|
+
activesupport (= 3.2.2)
|
10
|
+
builder (~> 3.0.0)
|
11
|
+
erubis (~> 2.7.0)
|
12
|
+
journey (~> 1.0.1)
|
13
|
+
rack (~> 1.4.0)
|
14
|
+
rack-cache (~> 1.1)
|
15
|
+
rack-test (~> 0.6.1)
|
16
|
+
sprockets (~> 2.1.2)
|
17
|
+
activemodel (3.2.2)
|
18
|
+
activesupport (= 3.2.2)
|
19
|
+
builder (~> 3.0.0)
|
20
|
+
activerecord (3.2.2)
|
21
|
+
activemodel (= 3.2.2)
|
22
|
+
activesupport (= 3.2.2)
|
23
|
+
arel (~> 3.0.2)
|
24
|
+
tzinfo (~> 0.3.29)
|
25
|
+
activeresource (3.2.2)
|
26
|
+
activemodel (= 3.2.2)
|
27
|
+
activesupport (= 3.2.2)
|
4
28
|
activesupport (3.2.2)
|
5
29
|
i18n (~> 0.6)
|
6
30
|
multi_json (~> 1.0)
|
7
31
|
addressable (2.2.7)
|
32
|
+
arel (3.0.2)
|
33
|
+
builder (3.0.0)
|
8
34
|
crack (0.3.1)
|
35
|
+
erubis (2.7.0)
|
9
36
|
git (1.2.5)
|
37
|
+
hike (1.2.1)
|
10
38
|
i18n (0.6.0)
|
11
39
|
jeweler (1.8.3)
|
12
40
|
bundler (~> 1.0)
|
13
41
|
git (>= 1.2.5)
|
14
42
|
rake
|
15
43
|
rdoc
|
44
|
+
journey (1.0.3)
|
16
45
|
json (1.6.5)
|
46
|
+
mail (2.4.4)
|
47
|
+
i18n (>= 0.4.0)
|
48
|
+
mime-types (~> 1.16)
|
49
|
+
treetop (~> 1.4.8)
|
17
50
|
metaclass (0.0.1)
|
51
|
+
mime-types (1.17.2)
|
18
52
|
mocha (0.10.5)
|
19
53
|
metaclass (~> 0.0.1)
|
20
54
|
multi_json (1.1.0)
|
21
|
-
oauth (0.4.
|
55
|
+
oauth (0.4.4)
|
56
|
+
polyglot (0.3.3)
|
57
|
+
rack (1.4.1)
|
58
|
+
rack-cache (1.2)
|
59
|
+
rack (>= 0.4)
|
60
|
+
rack-ssl (1.3.2)
|
61
|
+
rack
|
62
|
+
rack-test (0.6.1)
|
63
|
+
rack (>= 1.0)
|
64
|
+
rails (3.2.2)
|
65
|
+
actionmailer (= 3.2.2)
|
66
|
+
actionpack (= 3.2.2)
|
67
|
+
activerecord (= 3.2.2)
|
68
|
+
activeresource (= 3.2.2)
|
69
|
+
activesupport (= 3.2.2)
|
70
|
+
bundler (~> 1.0)
|
71
|
+
railties (= 3.2.2)
|
72
|
+
railties (3.2.2)
|
73
|
+
actionpack (= 3.2.2)
|
74
|
+
activesupport (= 3.2.2)
|
75
|
+
rack-ssl (~> 1.3.2)
|
76
|
+
rake (>= 0.8.7)
|
77
|
+
rdoc (~> 3.4)
|
78
|
+
thor (~> 0.14.6)
|
22
79
|
rake (0.9.2.2)
|
23
80
|
rdoc (3.12)
|
24
81
|
json (~> 1.4)
|
@@ -27,6 +84,16 @@ GEM
|
|
27
84
|
shoulda-matchers (~> 1.0.0)
|
28
85
|
shoulda-context (1.0.0)
|
29
86
|
shoulda-matchers (1.0.0)
|
87
|
+
sprockets (2.1.2)
|
88
|
+
hike (~> 1.2)
|
89
|
+
rack (~> 1.0)
|
90
|
+
tilt (~> 1.1, != 1.3.0)
|
91
|
+
thor (0.14.6)
|
92
|
+
tilt (1.3.3)
|
93
|
+
treetop (1.4.10)
|
94
|
+
polyglot
|
95
|
+
polyglot (>= 0.3.1)
|
96
|
+
tzinfo (0.3.32)
|
30
97
|
webmock (1.8.2)
|
31
98
|
addressable (>= 2.2.7)
|
32
99
|
crack (>= 0.1.7)
|
@@ -35,12 +102,12 @@ PLATFORMS
|
|
35
102
|
ruby
|
36
103
|
|
37
104
|
DEPENDENCIES
|
38
|
-
activesupport
|
39
105
|
bundler (~> 1.1.0)
|
40
106
|
i18n
|
41
107
|
jeweler (~> 1.8.0)
|
42
108
|
json
|
43
109
|
mocha (>= 0.9.8)
|
44
|
-
oauth (
|
110
|
+
oauth (= 0.4.4)
|
111
|
+
rails (>= 3.0.0)
|
45
112
|
shoulda
|
46
113
|
webmock (>= 1.6.2)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.5
|
data/lib/ob_port/base.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
module MageHand
|
2
2
|
class Base
|
3
|
+
attr_accessor :client
|
3
4
|
@@simple_attributes = {}
|
4
5
|
@@instance_attributes = {}
|
5
6
|
|
@@ -13,7 +14,8 @@ module MageHand
|
|
13
14
|
|
14
15
|
attr_simple :id
|
15
16
|
|
16
|
-
def initialize(attributes=nil)
|
17
|
+
def initialize(client, attributes=nil)
|
18
|
+
self.client = client
|
17
19
|
update_attributes!(attributes)
|
18
20
|
end
|
19
21
|
|
@@ -29,7 +31,7 @@ module MageHand
|
|
29
31
|
#if we don't have an id, the opject has not been created on the server yet
|
30
32
|
return unless self.id
|
31
33
|
|
32
|
-
hash = JSON.parse(
|
34
|
+
hash = JSON.parse(client.access_token.get(individual_url).body)
|
33
35
|
update_attributes!(hash)
|
34
36
|
end
|
35
37
|
|
@@ -82,7 +84,7 @@ module MageHand
|
|
82
84
|
end
|
83
85
|
|
84
86
|
def #{name}=(new_#{name})
|
85
|
-
@#{name} = #{class_name}.new(new_#{name.singularize})
|
87
|
+
@#{name} = #{class_name}.new(client, new_#{name.singularize})
|
86
88
|
end
|
87
89
|
CODE
|
88
90
|
puts code if ENV['DEBUG']
|
@@ -105,7 +107,7 @@ module MageHand
|
|
105
107
|
def #{name}=(new_#{name})
|
106
108
|
@#{name} = []
|
107
109
|
new_#{name}.each do |#{name.singularize}|
|
108
|
-
@#{name} << #{class_name}.new(#{name.singularize})
|
110
|
+
@#{name} << #{class_name}.new(client, #{name.singularize})
|
109
111
|
end
|
110
112
|
end
|
111
113
|
CODE
|
data/lib/ob_port/campaign.rb
CHANGED
@@ -21,12 +21,12 @@ module MageHand
|
|
21
21
|
inflate_if_nil :players
|
22
22
|
|
23
23
|
def self.find_by_slug(slug)
|
24
|
-
hash = JSON.parse(
|
24
|
+
hash = JSON.parse(client.access_token.get("/v1/campaigns/#{slug}.json?use_slug=true").body)
|
25
25
|
Campaign.new(hash)
|
26
26
|
end
|
27
27
|
|
28
28
|
def self.find(id)
|
29
|
-
hash = JSON.parse(
|
29
|
+
hash = JSON.parse(client.access_token.get("/v1/campaigns/#{id}.json").body)
|
30
30
|
Campaign.new(hash)
|
31
31
|
end
|
32
32
|
|
data/lib/ob_port/client.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
module MageHand
|
2
2
|
class Client
|
3
3
|
attr_accessor :request_token, :access_token_key, :access_token_secret
|
4
|
-
@@client = nil
|
5
4
|
|
6
5
|
def self.set_app_keys(key, secret)
|
7
6
|
@@key = key
|
@@ -10,12 +9,8 @@ module MageHand
|
|
10
9
|
|
11
10
|
def self.get_client(session_request_token=nil, session_access_token_key=nil, session_access_token_secret=nil,
|
12
11
|
callback=nil, params=nil)
|
13
|
-
|
14
|
-
|
15
|
-
@@client = Client.new(session_request_token, session_access_token_key,
|
16
|
-
session_access_token_secret, callback, params)
|
17
|
-
end
|
18
|
-
@@client
|
12
|
+
Client.new(session_request_token, session_access_token_key, session_access_token_secret,
|
13
|
+
callback, params)
|
19
14
|
end
|
20
15
|
|
21
16
|
def initialize(session_request_token=nil, session_access_token_key=nil, session_access_token_secret=nil,
|
@@ -53,12 +48,16 @@ module MageHand
|
|
53
48
|
end
|
54
49
|
|
55
50
|
def current_user
|
56
|
-
@current_user ||= MageHand::User.new(JSON.parse(access_token.get('/v1/users/me.json').body))
|
51
|
+
@current_user ||= MageHand::User.new(self, JSON.parse(access_token.get('/v1/users/me.json').body))
|
57
52
|
end
|
58
53
|
alias :me :current_user
|
59
54
|
|
60
55
|
def campaign(id)
|
61
|
-
MageHand::Campaign.new(JSON.parse(access_token.get("/v1/campaigns/#{id}.json").body))
|
56
|
+
MageHand::Campaign.new(self, JSON.parse(access_token.get("/v1/campaigns/#{id}.json").body))
|
57
|
+
end
|
58
|
+
|
59
|
+
def create_wiki_page(options)
|
60
|
+
MageHand::WikiPage.new(self, options)
|
62
61
|
end
|
63
62
|
|
64
63
|
protected
|
@@ -66,7 +65,6 @@ module MageHand
|
|
66
65
|
def self.reset_client
|
67
66
|
@@key = nil
|
68
67
|
@@secret = nil
|
69
|
-
@@client = nil
|
70
68
|
end
|
71
69
|
end
|
72
70
|
end
|
data/lib/ob_port/wiki_page.rb
CHANGED
@@ -20,13 +20,12 @@ module MageHand
|
|
20
20
|
inflate_if_nil :campaign
|
21
21
|
|
22
22
|
def self.load_wiki_pages(campaign_id)
|
23
|
-
wiki_hashes = JSON.parse(
|
24
|
-
MageHand::get_client.access_token.get(collection_url(campaign_id)).body)
|
23
|
+
wiki_hashes = JSON.parse(client.access_token.get(collection_url(campaign_id)).body)
|
25
24
|
wiki_hashes.map {|hash| WikiPage.new(hash)}
|
26
25
|
end
|
27
26
|
|
28
27
|
def campaign=(campaign_hash)
|
29
|
-
@campaign
|
28
|
+
@campaign = Campaign.new(client, campaign_hash)
|
30
29
|
end
|
31
30
|
|
32
31
|
def is_post?
|
@@ -50,9 +49,18 @@ module MageHand
|
|
50
49
|
if id # save existing wiki pae
|
51
50
|
|
52
51
|
else # create new wiki page
|
52
|
+
puts '#########'
|
53
|
+
puts client.logged_in?
|
54
|
+
puts self.campaign.inspect
|
55
|
+
puts self.class.collection_url(self.campaign.id)
|
56
|
+
puts client.access_token.inspect
|
57
|
+
puts client.campaign(self.campaign.id).name
|
58
|
+
|
53
59
|
json_body = {'wiki_page' => self.to_hash}.to_json
|
54
|
-
|
60
|
+
puts json_body
|
61
|
+
@response = client.access_token.post(self.class.collection_url(self.campaign.id),
|
55
62
|
json_body, {'content-type' => 'application/x-www-form-urlencoded'})
|
63
|
+
puts @response.inspect
|
56
64
|
self.update_attributes!(JSON.parse(@response.body))
|
57
65
|
end
|
58
66
|
end
|
data/mage-hand.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "mage-hand"
|
8
|
-
s.version = "0.4.
|
8
|
+
s.version = "0.4.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Steven Hammond"]
|
12
|
-
s.date = "2012-03-
|
12
|
+
s.date = "2012-03-20"
|
13
13
|
s.description = "mage-hand is a ghostly hand that reaches across the internet to access the Obsidian Portal API."
|
14
14
|
s.email = "shammond@northpub.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -54,10 +54,10 @@ Gem::Specification.new do |s|
|
|
54
54
|
s.specification_version = 3
|
55
55
|
|
56
56
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
57
|
-
s.add_runtime_dependency(%q<oauth>, ["
|
57
|
+
s.add_runtime_dependency(%q<oauth>, ["= 0.4.4"])
|
58
58
|
s.add_runtime_dependency(%q<json>, [">= 0"])
|
59
59
|
s.add_runtime_dependency(%q<i18n>, [">= 0"])
|
60
|
-
s.add_runtime_dependency(%q<
|
60
|
+
s.add_runtime_dependency(%q<rails>, [">= 3.0.0"])
|
61
61
|
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
62
62
|
s.add_development_dependency(%q<bundler>, ["~> 1.1.0"])
|
63
63
|
s.add_development_dependency(%q<jeweler>, ["~> 1.8.0"])
|
@@ -65,10 +65,10 @@ Gem::Specification.new do |s|
|
|
65
65
|
s.add_development_dependency(%q<webmock>, [">= 1.6.2"])
|
66
66
|
s.add_runtime_dependency(%q<oauth>, [">= 0.4.4"])
|
67
67
|
else
|
68
|
-
s.add_dependency(%q<oauth>, ["
|
68
|
+
s.add_dependency(%q<oauth>, ["= 0.4.4"])
|
69
69
|
s.add_dependency(%q<json>, [">= 0"])
|
70
70
|
s.add_dependency(%q<i18n>, [">= 0"])
|
71
|
-
s.add_dependency(%q<
|
71
|
+
s.add_dependency(%q<rails>, [">= 3.0.0"])
|
72
72
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
73
73
|
s.add_dependency(%q<bundler>, ["~> 1.1.0"])
|
74
74
|
s.add_dependency(%q<jeweler>, ["~> 1.8.0"])
|
@@ -77,10 +77,10 @@ Gem::Specification.new do |s|
|
|
77
77
|
s.add_dependency(%q<oauth>, [">= 0.4.4"])
|
78
78
|
end
|
79
79
|
else
|
80
|
-
s.add_dependency(%q<oauth>, ["
|
80
|
+
s.add_dependency(%q<oauth>, ["= 0.4.4"])
|
81
81
|
s.add_dependency(%q<json>, [">= 0"])
|
82
82
|
s.add_dependency(%q<i18n>, [">= 0"])
|
83
|
-
s.add_dependency(%q<
|
83
|
+
s.add_dependency(%q<rails>, [">= 3.0.0"])
|
84
84
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
85
85
|
s.add_dependency(%q<bundler>, ["~> 1.1.0"])
|
86
86
|
s.add_dependency(%q<jeweler>, ["~> 1.8.0"])
|
data/test/helper.rb
CHANGED
data/test/test_base.rb
CHANGED
@@ -4,7 +4,7 @@ class TestBase < Test::Unit::TestCase
|
|
4
4
|
context 'the Base class' do
|
5
5
|
should 'use the attr_simple method to add an attribute' do
|
6
6
|
MageHand::Base.attr_simple :test_attribute, :second_attribute
|
7
|
-
@instance = MageHand::Base.new
|
7
|
+
@instance = MageHand::Base.new(nil)
|
8
8
|
@instance.test_attribute = 'Hello'
|
9
9
|
@instance.second_attribute = 'World'
|
10
10
|
assert_equal 'Hello', @instance.test_attribute
|
@@ -13,7 +13,7 @@ class TestBase < Test::Unit::TestCase
|
|
13
13
|
|
14
14
|
should 'be able to get a list of simple attributes' do
|
15
15
|
MageHand::Base.attr_simple :test_attribute, :second_attribute
|
16
|
-
@instance = MageHand::Base.new
|
16
|
+
@instance = MageHand::Base.new(nil)
|
17
17
|
|
18
18
|
assert MageHand::Base.simple_attributes.include?(:test_attribute)
|
19
19
|
assert @instance.simple_attributes.include?(:test_attribute)
|
@@ -23,15 +23,16 @@ class TestBase < Test::Unit::TestCase
|
|
23
23
|
end
|
24
24
|
|
25
25
|
should 'be able to add an instance of another class as an attribute' do
|
26
|
+
# MageHand::Client.set_app_keys('asdfasdf', 'asdfasdfasdfasdfasdf')
|
26
27
|
MageHand::Base.attr_instance :test_campaign, :class_name => 'Campaign'
|
27
|
-
@instance = MageHand::Base.new
|
28
|
+
@instance = MageHand::Base.new(nil)
|
28
29
|
@instance.test_campaign = {:name => "A Great Time"}
|
29
30
|
assert_equal "A Great Time", @instance.test_campaign.name
|
30
31
|
end
|
31
32
|
|
32
33
|
should 'be able to get a list of instance attributes' do
|
33
34
|
MageHand::Base.attr_instance :test_campaign, :class_name => 'Campaign'
|
34
|
-
@instance = MageHand::Base.new
|
35
|
+
@instance = MageHand::Base.new(nil)
|
35
36
|
|
36
37
|
assert MageHand::Base.instance_attributes.include?(:test_campaign)
|
37
38
|
assert @instance.instance_attributes.include?(:test_campaign)
|
@@ -40,7 +41,7 @@ class TestBase < Test::Unit::TestCase
|
|
40
41
|
should 'be able to get a list of all declared attributes' do
|
41
42
|
MageHand::Base.attr_instance :test_campaign, :class_name => 'Campaign'
|
42
43
|
MageHand::Base.attr_simple :test_attribute
|
43
|
-
@instance = MageHand::Base.new
|
44
|
+
@instance = MageHand::Base.new(nil)
|
44
45
|
|
45
46
|
assert MageHand::Base.attributes.include?(:test_campaign)
|
46
47
|
assert @instance.attributes.include?(:test_campaign)
|
data/test/test_campaign.rb
CHANGED
@@ -4,7 +4,7 @@ class TestCampaign < Test::Unit::TestCase
|
|
4
4
|
context 'an instance of the Campaign class' do
|
5
5
|
should 'know its url' do
|
6
6
|
id_string = 'asdf12341asdf1234'
|
7
|
-
campaign = MageHand::Campaign.new(:id => id_string)
|
7
|
+
campaign = MageHand::Campaign.new(nil, :id => id_string)
|
8
8
|
assert_equal "/v1/campaigns/#{id_string}.json", campaign.send(:individual_url)
|
9
9
|
end
|
10
10
|
end
|
@@ -26,7 +26,7 @@ class TestCampaign < Test::Unit::TestCase
|
|
26
26
|
end
|
27
27
|
|
28
28
|
should 'be able to initialize from a mini object' do
|
29
|
-
campaign = MageHand::Campaign.new(@mini_fields)
|
29
|
+
campaign = MageHand::Campaign.new(nil, @mini_fields)
|
30
30
|
assert_not_nil campaign
|
31
31
|
@mini_fields.each do |key, value|
|
32
32
|
assert_equal campaign.send(key), value
|
@@ -34,7 +34,7 @@ class TestCampaign < Test::Unit::TestCase
|
|
34
34
|
end
|
35
35
|
|
36
36
|
should 'be able to initialize from a complete object' do
|
37
|
-
campaign = MageHand::Campaign.new(@full_fields)
|
37
|
+
campaign = MageHand::Campaign.new(nil, @full_fields)
|
38
38
|
assert_not_nil campaign
|
39
39
|
@full_fields.each do |key, value|
|
40
40
|
assert_equal campaign.send(key), value
|
data/test/test_client.rb
CHANGED
@@ -26,9 +26,9 @@ class TestClient < Test::Unit::TestCase
|
|
26
26
|
OAuth::AccessToken.any_instance.stubs(:post).returns(response)
|
27
27
|
OAuth::Consumer.any_instance.stubs(:get_request_token).returns(@request_token)
|
28
28
|
|
29
|
-
MageHand::Client.send(:reset_client)
|
30
29
|
MageHand::Client.set_app_keys('asdfasdf', 'asdfasdfasdfasdfasdf')
|
31
30
|
end
|
31
|
+
|
32
32
|
should "be configured to use different urls for authentication and api access" do
|
33
33
|
@client = MageHand::get_client(nil, nil, nil)
|
34
34
|
assert @client.consumer.site =~ /api\.obsidianportal\.com/
|
@@ -36,18 +36,21 @@ class TestClient < Test::Unit::TestCase
|
|
36
36
|
assert @client.consumer.authorize_url =~ /https:\/\/www\.obsidianportal\.com/
|
37
37
|
assert @client.consumer.access_token_url =~ /https:\/\/www\.obsidianportal\.com/
|
38
38
|
end
|
39
|
+
|
39
40
|
should "have a request_token, and not an access token, when authorizing" do
|
40
41
|
@client = MageHand::get_client(nil, nil, nil)
|
41
42
|
assert_not_nil @client
|
42
43
|
assert_equal @client.request_token, @request_token
|
43
44
|
assert_nil @client.access_token
|
44
45
|
end
|
46
|
+
|
45
47
|
should "create an access_token when an oauth_verifier and request_token is passed in" do
|
46
48
|
@client = MageHand::get_client(@request_token, nil, nil, nil, {:oauth_verifier => 'asdfasdf'})
|
47
49
|
assert_not_nil @client
|
48
50
|
assert_not_nil @client.access_token
|
49
51
|
assert @client.logged_in?
|
50
52
|
end
|
53
|
+
|
51
54
|
should "be logged in if initialized with an access_key and access_secret" do
|
52
55
|
@client = MageHand::get_client(nil, 'asdf', 'asdfasdfasdfasdf')
|
53
56
|
assert_not_nil @client
|
@@ -55,5 +58,13 @@ class TestClient < Test::Unit::TestCase
|
|
55
58
|
assert_equal @client.access_token.token, 'asdf'
|
56
59
|
assert_equal @client.access_token.secret, 'asdfasdfasdfasdf'
|
57
60
|
end
|
61
|
+
|
62
|
+
should 'be act as a factory for wiki page objects' do
|
63
|
+
@client = MageHand::get_client(nil, 'asdf', 'asdfasdfasdfasdf')
|
64
|
+
@page = @client.create_wiki_page(slug: 'test_page')
|
65
|
+
assert_not_nil @page
|
66
|
+
assert_equal @client, @page.client
|
67
|
+
assert_equal 'test_page', @page.slug
|
68
|
+
end
|
58
69
|
end
|
59
70
|
end
|
@@ -1,14 +1,42 @@
|
|
1
1
|
require 'helper'
|
2
|
+
require 'active_support'
|
3
|
+
require 'active_support/test_case'
|
4
|
+
require 'action_controller'
|
5
|
+
require 'action_controller/test_case'
|
2
6
|
|
3
|
-
class
|
7
|
+
class UnderTestController < ActionController::Base
|
4
8
|
include MageHandController
|
9
|
+
def current_user
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class TestMageHandController < ActionController::TestCase
|
15
|
+
tests UnderTestController
|
5
16
|
|
6
17
|
context 'The Mage Hand Controller Module' do
|
7
18
|
setup do
|
19
|
+
MageHand::Client.set_app_keys('asdfasdf', 'asdfasdfasdfasdfasdf')
|
20
|
+
stub_request(:post, "https://www.obsidianportal.com/oauth/request_token").
|
21
|
+
to_return(:status => 200, :body => "", :headers => {})
|
22
|
+
end
|
23
|
+
|
24
|
+
should 'return an obsidian portal client' do
|
25
|
+
assert @controller.send(:obsidian_portal).instance_of? MageHand::Client
|
26
|
+
end
|
27
|
+
|
28
|
+
should 'know if an op user is logged in' do
|
29
|
+
assert !@controller.send(:logged_in_op?)
|
8
30
|
|
31
|
+
@controller.send(:obsidian_portal).access_token_key = 'asdfasdf'
|
32
|
+
@controller.send(:obsidian_portal).access_token_secret = 'adsfasdfasdfasdf'
|
33
|
+
assert @controller.send(:logged_in_op?)
|
9
34
|
end
|
10
35
|
|
11
|
-
should 'be
|
36
|
+
should 'be able to store tokens on the user and the session' do
|
37
|
+
@controller.send(:obsidian_portal).access_token_key = 'asdfasdf'
|
38
|
+
@controller.send(:obsidian_portal).access_token_secret = 'adsfasdfasdfasdf'
|
39
|
+
assert @controller.send(:logged_in_op?)
|
12
40
|
end
|
13
41
|
end
|
14
42
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mage-hand
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,14 +9,14 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-03-
|
12
|
+
date: 2012-03-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: oauth
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - '='
|
20
20
|
- !ruby/object:Gem::Version
|
21
21
|
version: 0.4.4
|
22
22
|
type: :runtime
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - '='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: 0.4.4
|
30
30
|
- !ruby/object:Gem::Dependency
|
@@ -60,13 +60,13 @@ dependencies:
|
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
|
-
name:
|
63
|
+
name: rails
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
65
65
|
none: false
|
66
66
|
requirements:
|
67
67
|
- - ! '>='
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
69
|
+
version: 3.0.0
|
70
70
|
type: :runtime
|
71
71
|
prerelease: false
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -74,7 +74,7 @@ dependencies:
|
|
74
74
|
requirements:
|
75
75
|
- - ! '>='
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
version:
|
77
|
+
version: 3.0.0
|
78
78
|
- !ruby/object:Gem::Dependency
|
79
79
|
name: shoulda
|
80
80
|
requirement: !ruby/object:Gem::Requirement
|
@@ -221,7 +221,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
221
221
|
version: '0'
|
222
222
|
segments:
|
223
223
|
- 0
|
224
|
-
hash:
|
224
|
+
hash: 4602273356508008928
|
225
225
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
226
226
|
none: false
|
227
227
|
requirements:
|