grin 1.0.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -34,5 +34,9 @@ module Grin
34
34
  end
35
35
  end
36
36
 
37
+ def destroy
38
+ delete("albums/#{id}.json")
39
+ end
40
+
37
41
  end
38
42
  end
@@ -16,5 +16,9 @@ module Grin
16
16
  return albums
17
17
  end
18
18
 
19
+ def destroy
20
+ delete("categories/#{id}.json")
21
+ end
22
+
19
23
  end
20
24
  end
@@ -72,5 +72,9 @@ module Grin
72
72
  JSON.parse(RestClient.post("http://#{@@auth_string}.#{DOMAIN}/api/#{API_VERSION}/#{path}", params))
73
73
  end
74
74
 
75
+ def delete(path)
76
+ JSON.parse(RestClient.delete("http://#{@@auth_string}.#{DOMAIN}/api/#{API_VERSION}/#{path}"))
77
+ end
78
+
75
79
  end
76
80
  end
@@ -3,3 +3,4 @@ require 'grin'
3
3
 
4
4
  @fotogger = Grin::Client.new("bensie", "bensie@gmail.com", "jkmeslyl")
5
5
  p @fotogger.albums
6
+ p @fotogger.category(17).destroy
@@ -18,22 +18,35 @@ class TestGrin < Test::Unit::TestCase
18
18
  end
19
19
  end
20
20
 
21
- context "creating albums and categories" do
21
+ context "creating and deleting albums and categories" do
22
22
  setup do
23
23
  @category = @fotogger.find_or_create_category("My Category")
24
24
  @album = @fotogger.find_or_create_album("My Album", @category.id)
25
25
  end
26
26
 
27
27
  should "return the category name" do
28
+ assert_kind_of Grin::Category, @category
28
29
  assert_equal @category.name, "My Category"
29
30
  end
30
31
 
31
32
  should "return the album title and category name" do
32
- @category = @fotogger.find_or_create_category("My Category")
33
-
33
+ assert_kind_of Grin::Album, @album
34
34
  assert_equal @album.title, "My Album"
35
35
  assert_equal @album.category['name'], @category.name
36
36
  end
37
+
38
+ should "not allow you to delete the category when the album exists" do
39
+ response = @category.destroy
40
+ assert_equal "Cannot delete category that contains albums", response['error']
41
+ end
42
+
43
+ should "delete the album followed by the category" do
44
+ album_response = @album.destroy
45
+ category_response = @category.destroy
46
+ assert_equal "ok", album_response['status']
47
+ assert_equal "ok", category_response['status']
48
+ end
49
+
37
50
  end
38
51
 
39
52
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grin
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
- - 0
9
- - 0
10
- version: 1.0.0
8
+ - 1
9
+ - 1
10
+ version: 1.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - James Miller
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-26 00:00:00 -07:00
18
+ date: 2010-08-27 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency