taskmapper-trello 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,68 @@
1
+ {
2
+ "id": "4ea4f9b1ad8ba68c10013887",
3
+ "avatarHash": "",
4
+ "bio": "",
5
+ "bioData": null,
6
+ "confirmed": true,
7
+ "fullName": "Test User",
8
+ "idPremOrgsAdmin": [
9
+
10
+ ],
11
+ "initials": "AS",
12
+ "memberType": "normal",
13
+ "products": [
14
+
15
+ ],
16
+ "status": "disconnected",
17
+ "url": "https:\/\/trello.com\/test_user",
18
+ "username": "test_user",
19
+ "avatarSource": "none",
20
+ "email": null,
21
+ "gravatarHash": "4490da1a9bfe605a1971632d1646635b",
22
+ "idBoards": [
23
+ "4ea4fa0cd791269d4e29a176",
24
+ "4ea4fd11fc8f1d3999192a7d",
25
+ "4f0b8693acbcd9212e362eae",
26
+ "4f0f2f4508f28652554231d2",
27
+ "4f1ef9220dc5a4633b3e9d9b",
28
+ "4f225e83ed560e771605d318",
29
+ "4f26e22814cd935006633fd9",
30
+ "4f2ac73accc68eeb0b24fc44"
31
+ ],
32
+ "idBoardsInvited": [
33
+
34
+ ],
35
+ "idBoardsPinned": [
36
+ "4f1ef9220dc5a4633b3e9d9b",
37
+ "4f225e83ed560e771605d318",
38
+ "4f26e22814cd935006633fd9"
39
+ ],
40
+ "idOrganizations": [
41
+ "4ee269e0c9feba4446044c2f"
42
+ ],
43
+ "idOrganizationsInvited": [
44
+
45
+ ],
46
+ "loginTypes": null,
47
+ "newEmail": null,
48
+ "oneTimeMessagesDismissed": [
49
+
50
+ ],
51
+ "prefs": {
52
+ "sendSummaries": true,
53
+ "minutesBetweenSummaries": 60,
54
+ "minutesBeforeDeadlineToNotify": 1440,
55
+ "colorBlind": false,
56
+ "timezoneInfo": {
57
+ "timezoneNext": "PST",
58
+ "dateNext": "2013-11-03T09:00:00.000Z",
59
+ "offsetNext": 480,
60
+ "timezoneCurrent": "PDT",
61
+ "offsetCurrent": 420
62
+ }
63
+ },
64
+ "trophies": [
65
+
66
+ ],
67
+ "uploadedAvatarHash": null
68
+ }
@@ -0,0 +1,58 @@
1
+ require 'spec_helper'
2
+
3
+ describe TaskMapper::Provider::Trello::Project do
4
+ let(:tm) { create_instance }
5
+ let(:project_class) { TaskMapper::Provider::Trello::Project }
6
+
7
+ describe "#project" do
8
+ context "with a project ID" do
9
+ let(:project) { tm.project("4f0f2f4508f28652554231d2") }
10
+
11
+ it "returns the requested project" do
12
+ expect(project).to be_a project_class
13
+ expect(project.id).to eq "4f0f2f4508f28652554231d2"
14
+ end
15
+ end
16
+
17
+ context "with a hash containing a project ID" do
18
+ let(:project) { tm.project(:id => "4f0f2f4508f28652554231d2") }
19
+
20
+ it "returns the requested project" do
21
+ expect(project).to be_a project_class
22
+ expect(project.id).to eq "4f0f2f4508f28652554231d2"
23
+ end
24
+ end
25
+ end
26
+
27
+ describe "#projects" do
28
+ context "without params" do
29
+ let(:projects) { tm.projects }
30
+
31
+ it "returns an array of Projects" do
32
+ expect(projects).to be_an Array
33
+ expect(projects.first).to be_a project_class
34
+ end
35
+ end
36
+
37
+ context "with an array of IDs" do
38
+ let(:ids) { %w(4f0f2f4508f28652554231d2 4ea4fa0cd791269d4e29a176) }
39
+ let(:projects) { tm.projects(ids) }
40
+
41
+ it "returns an array of requested Projects" do
42
+ expect(projects).to be_an Array
43
+ expect(projects.first.id).to eq "4f0f2f4508f28652554231d2"
44
+ expect(projects.last.id).to eq "4ea4fa0cd791269d4e29a176"
45
+ end
46
+ end
47
+
48
+ context "with a hash" do
49
+ let(:projects) { tm.projects(:id => "4f0f2f4508f28652554231d2") }
50
+
51
+ it "returns the requested project in an Array" do
52
+ expect(projects).to be_an Array
53
+ expect(projects.length).to eq 1
54
+ expect(projects.first.id).to eq "4f0f2f4508f28652554231d2"
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,107 @@
1
+ require 'spec_helper'
2
+
3
+ describe TaskMapper::Provider::Trello::Project do
4
+ let(:tm) { create_instance }
5
+ let(:ticket_class) { TaskMapper::Provider::Trello::Ticket }
6
+ let(:project) { tm.project "4ea4fa0cd791269d4e29a176" }
7
+
8
+ describe "#tickets" do
9
+ context "with no arguments" do
10
+ let(:tickets) { project.tickets }
11
+ let(:ticket) { project.tickets.first }
12
+
13
+ it "returns all tickets" do
14
+ expect(tickets).to be_an Array
15
+ expect(tickets).to_not be_empty
16
+ expect(ticket).to be_a ticket_class
17
+ end
18
+
19
+ it "contains the expected values" do
20
+ expect(ticket.id).to eq "4ea4fa0cd791269d4e29a198"
21
+ expect(ticket.name).to eq "This is a card."
22
+ expect(ticket.description).to eq "People can vote on cards."
23
+ expect(ticket.project_id).to eq project.id
24
+ expect(ticket.status).to eq 'open'
25
+ expect(ticket.updated_at).to_not be_nil
26
+ end
27
+ end
28
+
29
+ context "with an array of IDs" do
30
+ let(:ids) { %w(4ea4fa0cd791269d4e29a198 4ea4fa0dd791269d4e29a1bd) }
31
+ let(:tickets) { project.tickets ids }
32
+
33
+ it "returns the requested tickets" do
34
+ expect(tickets).to be_an Array
35
+ expect(tickets.length).to eq 2
36
+ expect(tickets[0].id).to eq "4ea4fa0cd791269d4e29a198"
37
+ expect(tickets[1].id).to eq "4ea4fa0dd791269d4e29a1bd"
38
+ end
39
+ end
40
+
41
+ context "with a hash containing an ID" do
42
+ let(:tickets) { project.tickets(:id => '4ea4fa0cd791269d4e29a198' ) }
43
+
44
+ it "returns the requested ticket" do
45
+ expect(tickets).to be_an Array
46
+ expect(tickets.length).to eq 1
47
+ expect(tickets.first.id).to eq "4ea4fa0cd791269d4e29a198"
48
+ end
49
+ end
50
+ end
51
+
52
+ describe "#ticket!" do
53
+ context "with a title and description" do
54
+ let(:ticket) do
55
+ project.ticket!(:name => "New Ticket", :description => "Desc")
56
+ end
57
+
58
+ it "creates a new ticket" do
59
+ expect(ticket).to be_a ticket_class
60
+ expect(ticket.name).to eq "New Ticket"
61
+ expect(ticket.desc).to eq "Desc"
62
+ expect(ticket.description).to eq "Desc"
63
+ end
64
+ end
65
+ end
66
+
67
+ describe "#ticket" do
68
+ describe "#save" do
69
+ let(:ticket) { project.tickets.first }
70
+
71
+ it "updates the ticket in Trello" do
72
+ expect_any_instance_of(::Trello::Card).to receive(:save)
73
+ ticket.name = "New Name!"
74
+ ticket.save
75
+ expect(ticket.name).to eq "New Name!"
76
+ end
77
+ end
78
+
79
+ describe "#close" do
80
+ let(:ticket) { project.tickets.first }
81
+
82
+ before do
83
+ expect_any_instance_of(::Trello::Card).to receive(:save)
84
+ end
85
+
86
+ it "updates the status and saves the ticket" do
87
+ expect(ticket.status).to eq "open"
88
+ ticket.close
89
+ expect(ticket.status).to eq 'closed'
90
+ end
91
+ end
92
+
93
+ describe "#reopen" do
94
+ let(:ticket) { project.tickets.last }
95
+
96
+ before do
97
+ expect_any_instance_of(::Trello::Card).to receive(:save)
98
+ end
99
+
100
+ it "updates the status and saves the ticket" do
101
+ expect(ticket.status).to eq "closed"
102
+ ticket.reopen
103
+ expect(ticket.status).to eq 'open'
104
+ end
105
+ end
106
+ end
107
+ end
@@ -0,0 +1,42 @@
1
+ require 'spec_helper'
2
+
3
+ describe TaskMapper::Provider::Trello do
4
+ let(:tm) { create_instance }
5
+
6
+ describe "#new" do
7
+ context "with correct params" do
8
+ it "creates a new TaskMapper instance" do
9
+ expect(tm).to be_a TaskMapper
10
+ end
11
+
12
+ it "can be called explicitly as a provider" do
13
+ tm = TaskMapper::Provider::Trello.new(
14
+ :developer_public_key => key,
15
+ :member_token => token,
16
+ :username => username
17
+ )
18
+ expect(tm).to be_a TaskMapper
19
+ end
20
+ end
21
+
22
+ context "with missing params" do
23
+ it "raises an error" do
24
+ expect {
25
+ TaskMapper.new(:trello, :developer_public_key => key)
26
+ }.to raise_error(TaskMapper::Exception)
27
+ end
28
+ end
29
+
30
+ context "without a username" do
31
+ it "raises an error" do
32
+ expect {
33
+ TaskMapper.new(
34
+ :trello,
35
+ :developer_public_key => key,
36
+ :member_token => token
37
+ )
38
+ }.to raise_error(TaskMapper::Exception)
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ module TaskMapper::Provider
4
+ describe Trello do
5
+ it "has a version string" do
6
+ expect(Trello::VERSION).to be_a String
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,74 @@
1
+ require 'taskmapper-trello'
2
+ require 'rspec'
3
+ require 'fakeweb'
4
+
5
+ FakeWeb.allow_net_connect = false
6
+
7
+ def fixture_file(filename)
8
+ return '' if filename == ''
9
+ file_path = File.expand_path "#{File.dirname(__FILE__)}/fixtures/#{filename}"
10
+ File.read(file_path)
11
+ end
12
+
13
+ def key
14
+ "test"
15
+ end
16
+
17
+ def token
18
+ "test"
19
+ end
20
+
21
+ def username
22
+ "test_user"
23
+ end
24
+
25
+ credentials_file = "#{File.dirname(__FILE__)}/credentials.rb"
26
+ require(credentials_file) if File.exists?(credentials_file)
27
+
28
+ def stub_request(method, url, filename, status=nil)
29
+ options = {:body => ""}
30
+ options.merge!({:body => fixture_file(filename)}) if filename
31
+ options.merge!({:body => status.last}) if status
32
+ options.merge!({:status => status}) if status
33
+ options.merge!({:content_type => 'application/json'})
34
+
35
+ FakeWeb.register_uri method, url, options
36
+ end
37
+
38
+ def stub_get(*args); stub_request(:get, *args) end
39
+ def stub_post(*args); stub_request(:post, *args) end
40
+ def stub_put(*args); stub_request(:put, *args) end
41
+ def stub_delete(*args); stub_request(:delete, *args) end
42
+
43
+ def create_instance
44
+ TaskMapper.new(
45
+ :trello,
46
+ :developer_public_key => key,
47
+ :member_token => token,
48
+ :username => username
49
+ )
50
+ end
51
+
52
+ RSpec.configure do |c|
53
+ c.before do
54
+ stub_get(
55
+ "https://api.trello.com/1/members/#{username}?key=#{key}&token=#{token}",
56
+ 'member.json'
57
+ )
58
+
59
+ stub_get(
60
+ "https://api.trello.com/1/members/4ea4f9b1ad8ba68c10013887/boards?filter=all&key=#{key}&token=#{token}",
61
+ "boards.json"
62
+ )
63
+
64
+ stub_get(
65
+ "https://api.trello.com/1/boards/4ea4fa0cd791269d4e29a176/cards?filter=open&key=#{key}&token=#{token}",
66
+ "cards.json"
67
+ )
68
+
69
+ stub_post(
70
+ "https://api.trello.com/1/cards?key=#{key}&token=#{token}",
71
+ 'card.json'
72
+ )
73
+ end
74
+ end
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path '../lib/provider/version', __FILE__
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = "taskmapper-trello"
6
+ spec.version = TaskMapper::Provider::Trello::VERSION
7
+ spec.authors = ["www.hybridgroup.com"]
8
+ spec.email = ["info@hybridgroup.com"]
9
+ spec.description = %q{A TaskMapper provider for interfacing with Trello.}
10
+ spec.summary = %q{A TaskMapper provider for interfacing with Trello.}
11
+ spec.homepage = "http://ticketrb.com"
12
+ spec.license = "MIT"
13
+
14
+ spec.files = `git ls-files`.split($/)
15
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
+ spec.require_paths = ["lib"]
18
+
19
+ spec.add_dependency "ruby-trello", "~> 1.0.4"
20
+ spec.add_dependency "taskmapper", "~> 1.0"
21
+ spec.add_development_dependency "rake"
22
+ spec.add_development_dependency "rspec", "~> 2.14.1"
23
+ spec.add_development_dependency "fakeweb", "~> 1.3.0"
24
+ end
metadata ADDED
@@ -0,0 +1,146 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: taskmapper-trello
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - www.hybridgroup.com
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ruby-trello
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.4
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.4
27
+ - !ruby/object:Gem::Dependency
28
+ name: taskmapper
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 2.14.1
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 2.14.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: fakeweb
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: 1.3.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 1.3.0
83
+ description: A TaskMapper provider for interfacing with Trello.
84
+ email:
85
+ - info@hybridgroup.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - .gitignore
91
+ - .travis.yml
92
+ - Gemfile
93
+ - LICENSE.txt
94
+ - README.md
95
+ - Rakefile
96
+ - lib/provider/project.rb
97
+ - lib/provider/ticket.rb
98
+ - lib/provider/trello.rb
99
+ - lib/provider/version.rb
100
+ - lib/taskmapper-trello.rb
101
+ - spec/credentials.rb.example
102
+ - spec/fixtures/boards.json
103
+ - spec/fixtures/card.json
104
+ - spec/fixtures/cards.json
105
+ - spec/fixtures/member.json
106
+ - spec/lib/project_spec.rb
107
+ - spec/lib/ticket_spec.rb
108
+ - spec/lib/trello_spec.rb
109
+ - spec/lib/version_spec.rb
110
+ - spec/spec_helper.rb
111
+ - taskmapper-trello.gemspec
112
+ homepage: http://ticketrb.com
113
+ licenses:
114
+ - MIT
115
+ metadata: {}
116
+ post_install_message:
117
+ rdoc_options: []
118
+ require_paths:
119
+ - lib
120
+ required_ruby_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ required_rubygems_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - '>='
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ requirements: []
131
+ rubyforge_project:
132
+ rubygems_version: 2.1.2
133
+ signing_key:
134
+ specification_version: 4
135
+ summary: A TaskMapper provider for interfacing with Trello.
136
+ test_files:
137
+ - spec/credentials.rb.example
138
+ - spec/fixtures/boards.json
139
+ - spec/fixtures/card.json
140
+ - spec/fixtures/cards.json
141
+ - spec/fixtures/member.json
142
+ - spec/lib/project_spec.rb
143
+ - spec/lib/ticket_spec.rb
144
+ - spec/lib/trello_spec.rb
145
+ - spec/lib/version_spec.rb
146
+ - spec/spec_helper.rb