datacatalog 0.4.16 → 0.4.17

Sign up to get free protection for your applications and to get access to all the features.
@@ -23,6 +23,15 @@ describe Download do
23
23
  )
24
24
  end
25
25
 
26
+ describe ".all" do
27
+ it "should return an enumeration of downloads" do
28
+ downloads = Download.all(:source_id => @source.id)
29
+ downloads.each do |o|
30
+ o.should be_an_instance_of(Download)
31
+ end
32
+ end
33
+ end
34
+
26
35
  describe ".create" do
27
36
  it "should create a download when valid params are passed in" do
28
37
  refreshed_source = Source.get(@source.id)
@@ -30,6 +39,18 @@ describe Download do
30
39
  end
31
40
  end
32
41
 
42
+ describe ".destroy" do
43
+ it "should destroy an existing download as an admin" do
44
+ Download.destroy(@download.id).should be_true
45
+ end
46
+
47
+ it "should raise NotFound when attempting to destroy non-existing download" do
48
+ executing do
49
+ Download.destroy(mangle(@download.id))
50
+ end.should raise_error(NotFound)
51
+ end
52
+ end
53
+
33
54
  describe ".get" do
34
55
  it "should return a download" do
35
56
  download = Download.get(@download.id)
@@ -44,15 +65,6 @@ describe Download do
44
65
  end
45
66
  end
46
67
 
47
- describe ".all" do
48
- it "should return an enumeration of downloads" do
49
- downloads = Download.all(:source_id => @source.id)
50
- downloads.each do |o|
51
- o.should be_an_instance_of(Download)
52
- end
53
- end
54
- end
55
-
56
68
  describe ".update" do
57
69
  it "should update an existing download with valid params" do
58
70
  Download.update(@download.id, :preview => "10,11,12,13")
@@ -61,16 +73,4 @@ describe Download do
61
73
  end
62
74
  end
63
75
 
64
- describe ".destroy" do
65
- it "should destroy an existing download as an admin" do
66
- Download.destroy(@download.id).should be_true
67
- end
68
-
69
- it "should raise NotFound when attempting to destroy non-existing download" do
70
- executing do
71
- Download.destroy(mangle(@download.id))
72
- end.should raise_error(NotFound)
73
- end
74
- end
75
-
76
76
  end
@@ -20,45 +20,23 @@ describe Favorite do
20
20
  end
21
21
  end
22
22
 
23
- describe ".create" do
24
-
25
- it "should create a favorite when valid params are passed in" do
26
- refreshed_user = User.get(@user.id)
27
- refreshed_user.favorites.first.title.should == "Some FCC Data"
28
- end
29
-
30
- end # describe ".create"
31
-
32
- describe ".get" do
33
-
34
- it "should return a favorite" do
35
- favorite = Favorite.get(@favorite.id)
36
- favorite.should be_an_instance_of(Favorite)
37
- favorite.user_id.should == @user.id
38
- end
39
-
40
- it "should raise NotFound if no favorite exists" do
41
- executing do
42
- Favorite.get(mangle(@favorite.id))
43
- end.should raise_error(NotFound)
44
- end
45
-
46
- end # describe ".get"
47
-
48
23
  describe ".all" do
49
-
50
24
  it "should return an enumeration of favorites" do
51
25
  favorites = Favorite.all(:user_id => @user.id)
52
26
  favorites.each do |o|
53
27
  o.should be_an_instance_of(Favorite)
54
28
  end
55
29
  end
30
+ end
56
31
 
57
- end # describe ".all"
58
-
32
+ describe ".create" do
33
+ it "should create a favorite when valid params are passed in" do
34
+ refreshed_user = User.get(@user.id)
35
+ refreshed_user.favorites.first.title.should == "Some FCC Data"
36
+ end
37
+ end
59
38
 
60
39
  describe ".destroy" do
61
-
62
40
  it "should destroy an existing favorite as an admin" do
63
41
  Favorite.destroy(@favorite.id).should be_true
64
42
  end
@@ -74,7 +52,26 @@ describe Favorite do
74
52
  Favorite.destroy(mangle(@favorite.id))
75
53
  end.should raise_error(NotFound)
76
54
  end
55
+ end
56
+
57
+ describe ".first" do
58
+ it "should return the first Favorite" do
59
+ Favorite.first.id.should == @favorite.id
60
+ end
61
+ end
77
62
 
78
- end # describe ".destroy"
63
+ describe ".get" do
64
+ it "should return a favorite" do
65
+ favorite = Favorite.get(@favorite.id)
66
+ favorite.should be_an_instance_of(Favorite)
67
+ favorite.user_id.should == @user.id
68
+ end
69
+
70
+ it "should raise NotFound if no favorite exists" do
71
+ executing do
72
+ Favorite.get(mangle(@favorite.id))
73
+ end.should raise_error(NotFound)
74
+ end
75
+ end
79
76
 
80
- end
77
+ end
data/spec/import_spec.rb CHANGED
@@ -16,32 +16,26 @@ describe Import do
16
16
  @imports = [
17
17
  Import.create({
18
18
  :importer_id => @importer.id,
19
- :status => 'success',
19
+ :status => 'succeeded',
20
20
  :started_at => timestamp - 3645,
21
21
  :finished_at => timestamp - 3600,
22
22
  }),
23
23
  Import.create({
24
24
  :importer_id => @importer.id,
25
- :status => 'success',
25
+ :status => 'succeeded',
26
26
  :started_at => timestamp - 45,
27
27
  :finished_at => timestamp,
28
28
  }),
29
29
  ]
30
30
  end
31
31
 
32
- describe ".get" do
33
- it "should return an import as a basic user" do
34
- import = DataCatalog.with_key(@user.primary_api_key) do
35
- Import.get(@imports[0].id)
32
+ describe ".all" do
33
+ it "should return an enumeration of 2 imports" do
34
+ imports = Import.all
35
+ imports.length.should == 2
36
+ imports.each do |o|
37
+ o.should be_an_instance_of(Import)
36
38
  end
37
- import.should be_an_instance_of(Import)
38
- import.id.should == @imports[0].id
39
- end
40
-
41
- it "should raise NotFound if no import exists" do
42
- executing do
43
- Import.get(mangle(@imports[0].id))
44
- end.should raise_error(NotFound)
45
39
  end
46
40
  end
47
41
 
@@ -69,33 +63,6 @@ describe Import do
69
63
  end
70
64
  end
71
65
 
72
- describe ".all" do
73
- it "should return an enumeration of 2 imports" do
74
- imports = Import.all
75
- imports.length.should == 2
76
- imports.each do |o|
77
- o.should be_an_instance_of(Import)
78
- end
79
- end
80
- end
81
-
82
- describe ".update" do
83
- it "a basic user should be unauthorized" do
84
- executing do
85
- DataCatalog.with_key(@user.primary_api_key) do
86
- Import.update(@imports[0].id, :status => 'failure')
87
- end
88
- end.should raise_error(Unauthorized)
89
- end
90
-
91
- it "should update an existing import with valid params" do
92
- @imports[0].status.should == 'success'
93
- Import.update(@imports[0].id, :status => 'failure')
94
- import = Import.get(@imports[0].id)
95
- import.status.should == 'failure'
96
- end
97
- end
98
-
99
66
  describe ".destroy" do
100
67
  it "should destroy an existing import as an admin" do
101
68
  Import.destroy(@imports[0].id).should be_true
@@ -116,4 +83,37 @@ describe Import do
116
83
  end
117
84
  end
118
85
 
86
+ describe ".get" do
87
+ it "should return an import as a basic user" do
88
+ import = DataCatalog.with_key(@user.primary_api_key) do
89
+ Import.get(@imports[0].id)
90
+ end
91
+ import.should be_an_instance_of(Import)
92
+ import.id.should == @imports[0].id
93
+ end
94
+
95
+ it "should raise NotFound if no import exists" do
96
+ executing do
97
+ Import.get(mangle(@imports[0].id))
98
+ end.should raise_error(NotFound)
99
+ end
100
+ end
101
+
102
+ describe ".update" do
103
+ it "a basic user should be unauthorized" do
104
+ executing do
105
+ DataCatalog.with_key(@user.primary_api_key) do
106
+ Import.update(@imports[0].id, :status => 'failure')
107
+ end
108
+ end.should raise_error(Unauthorized)
109
+ end
110
+
111
+ it "should update an existing import with valid params" do
112
+ @imports[0].status.should == 'succeeded'
113
+ Import.update(@imports[0].id, :status => 'failed')
114
+ import = Import.get(@imports[0].id)
115
+ import.status.should == 'failed'
116
+ end
117
+ end
118
+
119
119
  end
@@ -16,19 +16,13 @@ describe Importer do
16
16
  ]
17
17
  end
18
18
 
19
- describe ".get" do
20
- it "should return an importer as a basic user" do
21
- importer = DataCatalog.with_key(@user.primary_api_key) do
22
- Importer.get(@importers[0].id)
19
+ describe ".all" do
20
+ it "should return an enumeration of 2 importers" do
21
+ importers = Importer.all
22
+ importers.length.should == 2
23
+ importers.each do |o|
24
+ o.should be_an_instance_of(Importer)
23
25
  end
24
- importer.should be_an_instance_of(Importer)
25
- importer.id.should == @importers[0].id
26
- end
27
-
28
- it "should raise NotFound if no importer exists" do
29
- executing do
30
- Importer.get(mangle(@importers[0].id))
31
- end.should raise_error(NotFound)
32
26
  end
33
27
  end
34
28
 
@@ -56,13 +50,39 @@ describe Importer do
56
50
  end
57
51
  end
58
52
 
59
- describe ".all" do
60
- it "should return an enumeration of 2 importers" do
61
- importers = Importer.all
62
- importers.length.should == 2
63
- importers.each do |o|
64
- o.should be_an_instance_of(Importer)
53
+ describe ".destroy" do
54
+ it "should destroy an existing importer as an admin" do
55
+ Importer.destroy(@importers[0].id).should be_true
56
+ end
57
+
58
+ it "should not destroy an existing importer as a basic user" do
59
+ DataCatalog.with_key(@user.primary_api_key) do
60
+ executing do
61
+ Importer.destroy(@importers[0].id)
62
+ end.should raise_error(Unauthorized)
63
+ end
64
+ end
65
+
66
+ it "should raise NotFound when attempting to destroy non-existing importer" do
67
+ executing do
68
+ Importer.destroy(mangle(@importers[0].id))
69
+ end.should raise_error(NotFound)
70
+ end
71
+ end
72
+
73
+ describe ".get" do
74
+ it "should return an importer as a basic user" do
75
+ importer = DataCatalog.with_key(@user.primary_api_key) do
76
+ Importer.get(@importers[0].id)
65
77
  end
78
+ importer.should be_an_instance_of(Importer)
79
+ importer.id.should == @importers[0].id
80
+ end
81
+
82
+ it "should raise NotFound if no importer exists" do
83
+ executing do
84
+ Importer.get(mangle(@importers[0].id))
85
+ end.should raise_error(NotFound)
66
86
  end
67
87
  end
68
88
 
@@ -83,24 +103,4 @@ describe Importer do
83
103
  end
84
104
  end
85
105
 
86
- describe ".destroy" do
87
- it "should destroy an existing importer as an admin" do
88
- Importer.destroy(@importers[0].id).should be_true
89
- end
90
-
91
- it "should not destroy an existing importer as a basic user" do
92
- DataCatalog.with_key(@user.primary_api_key) do
93
- executing do
94
- Importer.destroy(@importers[0].id)
95
- end.should raise_error(Unauthorized)
96
- end
97
- end
98
-
99
- it "should raise NotFound when attempting to destroy non-existing importer" do
100
- executing do
101
- Importer.destroy(mangle(@importers[0].id))
102
- end.should raise_error(NotFound)
103
- end
104
- end
105
-
106
106
  end
data/spec/note_spec.rb CHANGED
@@ -23,19 +23,43 @@ describe Note do
23
23
  end
24
24
  end
25
25
 
26
- describe ".create" do
26
+ describe ".all" do
27
+ it "should return an enumeration of notes" do
28
+ notes = Note.all(:user_id => @user.id)
29
+ notes.each do |o|
30
+ o.should be_an_instance_of(Note)
31
+ end
32
+ end
33
+ end
27
34
 
35
+ describe ".create" do
28
36
  it "should create a note when valid params are passed in" do
29
37
  DataCatalog.with_key(@user.primary_api_key) do
30
38
  refreshed_source = Source.get(@source.id)
31
39
  refreshed_source.notes.first.text.should == "This is my note."
32
40
  end
33
41
  end
42
+ end
34
43
 
35
- end # describe ".create"
44
+ describe ".destroy" do
45
+ it "should destroy an existing note as an admin" do
46
+ Note.destroy(@note.id).should be_true
47
+ end
36
48
 
37
- describe ".get" do
49
+ it "should destroy an existing note as the user" do
50
+ DataCatalog.with_key(@user.primary_api_key) do
51
+ Note.destroy(@note.id).should be_true
52
+ end
53
+ end
54
+
55
+ it "should raise NotFound when attempting to destroy non-existing note" do
56
+ executing do
57
+ Note.destroy(mangle(@note.id))
58
+ end.should raise_error(NotFound)
59
+ end
60
+ end
38
61
 
62
+ describe ".get" do
39
63
  it "should return a note" do
40
64
  note = Note.get(@note.id)
41
65
  note.should be_an_instance_of(Note)
@@ -47,22 +71,9 @@ describe Note do
47
71
  Note.get(mangle(@note.id))
48
72
  end.should raise_error(NotFound)
49
73
  end
50
-
51
- end # describe ".get"
52
-
53
- describe ".all" do
54
-
55
- it "should return an enumeration of notes" do
56
- notes = Note.all(:user_id => @user.id)
57
- notes.each do |o|
58
- o.should be_an_instance_of(Note)
59
- end
60
- end
61
-
62
- end # describe ".all"
74
+ end
63
75
 
64
76
  describe ".update" do
65
-
66
77
  it "should update an existing note with valid params" do
67
78
  DataCatalog.with_key(@user.primary_api_key) do
68
79
  Note.update(@note.id, :text => "This is my updated note.")
@@ -71,27 +82,6 @@ describe Note do
71
82
  refreshed_note = Note.get(@note.id)
72
83
  refreshed_note.text.should == "This is my updated note."
73
84
  end
85
+ end
74
86
 
75
- end # describe ".update"
76
-
77
- describe ".destroy" do
78
-
79
- it "should destroy an existing note as an admin" do
80
- Note.destroy(@note.id).should be_true
81
- end
82
-
83
- it "should destroy an existing note as the user" do
84
- DataCatalog.with_key(@user.primary_api_key) do
85
- Note.destroy(@note.id).should be_true
86
- end
87
- end
88
-
89
- it "should raise NotFound when attempting to destroy non-existing note" do
90
- executing do
91
- Note.destroy(mangle(@note.id))
92
- end.should raise_error(NotFound)
93
- end
94
-
95
- end # describe ".destroy"
96
-
97
- end
87
+ end