publish_my_data 0.0.20 → 0.0.21
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/app/controllers/publish_my_data/datasets_controller.rb +9 -33
- data/app/controllers/publish_my_data/information_resources_controller.rb +18 -0
- data/app/controllers/publish_my_data/resources_controller.rb +2 -18
- data/app/models/publish_my_data/dataset.rb +10 -5
- data/app/models/publish_my_data/resource.rb +18 -4
- data/app/views/publish_my_data/datasets/index.html.erb +1 -1
- data/app/views/publish_my_data/datasets/show.html.erb +4 -4
- data/config/routes.rb +5 -4
- data/lib/publish_my_data/concerns/controllers/resource.rb +23 -0
- data/lib/publish_my_data/concerns.rb +2 -0
- data/lib/publish_my_data/render_params/concept_render_params.rb +6 -0
- data/lib/publish_my_data/render_params/concept_scheme_render_params.rb +6 -0
- data/lib/publish_my_data/render_params/dataset_render_params.rb +34 -0
- data/lib/publish_my_data/render_params/ontology_class_render_params.rb +6 -0
- data/lib/publish_my_data/render_params/ontology_render_params.rb +6 -0
- data/lib/publish_my_data/render_params/property_render_params.rb +6 -0
- data/lib/publish_my_data/render_params/resource_render_params.rb +6 -0
- data/lib/publish_my_data/render_params/theme_render_params.rb +1 -1
- data/lib/publish_my_data/render_params.rb +1 -0
- data/lib/publish_my_data/version.rb +1 -1
- data/spec/controllers/publish_my_data/datasets_controller_spec.rb +11 -100
- data/spec/controllers/publish_my_data/information_resources_controller_spec.rb +159 -0
- data/spec/dummy/log/test.log +67692 -0
- data/spec/factories/dataset_factories.rb +4 -4
- data/spec/factories/resource_factories.rb +11 -0
- data/spec/models/publish_my_data/dataset_spec.rb +5 -5
- metadata +20 -15
@@ -0,0 +1,159 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module PublishMyData
|
4
|
+
describe InformationResourcesController do
|
5
|
+
|
6
|
+
describe "showing an information resource" do
|
7
|
+
let!(:resource) { FactoryGirl.create(:information_resource) }
|
8
|
+
|
9
|
+
shared_examples_for "resource show" do
|
10
|
+
|
11
|
+
context "for an existing resource" do
|
12
|
+
it "should respond successfully" do
|
13
|
+
get :show, id: "information/resource", use_route: :publish_my_data, :format => format
|
14
|
+
response.should be_success
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context "with a non-existent dataset slug" do
|
19
|
+
it "should respond with not found" do
|
20
|
+
get :show, id: "non-existent/resource", use_route: :publish_my_data, :format => format
|
21
|
+
response.should be_not_found
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
shared_examples_for "html format" do
|
27
|
+
it "should render the resource show template" do
|
28
|
+
get :show, id: "information/resource", use_route: :publish_my_data, :format => format
|
29
|
+
response.should render_template("publish_my_data/resources/show")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
shared_examples_for "a non html format" do
|
34
|
+
|
35
|
+
context "for an existing resource" do
|
36
|
+
it "should return the resource in that format" do
|
37
|
+
get :show, id: "information/resource", use_route: :publish_my_data, :format => format
|
38
|
+
response.body.should == resource.send("to_#{format}")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context "for a non-existent resource" do
|
43
|
+
it "should return a blank body" do
|
44
|
+
get :show, id: "non-existent/resource", use_route: :publish_my_data, :format => format
|
45
|
+
response.body.should == "Not Found"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context "for html format" do
|
51
|
+
let(:format){ 'html' }
|
52
|
+
it_should_behave_like "html format"
|
53
|
+
it_should_behave_like "resource show"
|
54
|
+
end
|
55
|
+
|
56
|
+
# try another format.
|
57
|
+
context "for rdf format" do
|
58
|
+
let(:format){ 'rdf' }
|
59
|
+
it_should_behave_like "a non html format"
|
60
|
+
it_should_behave_like "resource show"
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
describe "showing a dataset" do
|
66
|
+
|
67
|
+
let(:dataset) { FactoryGirl.create(:my_dataset) }
|
68
|
+
|
69
|
+
shared_examples_for "dataset show" do
|
70
|
+
|
71
|
+
context "for an existing dataset" do
|
72
|
+
it "should respond successfully" do
|
73
|
+
get :show, id: dataset.slug, use_route: :publish_my_data, :format => format
|
74
|
+
response.should be_success
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
context "with a non-existent dataset slug" do
|
79
|
+
it "should respond with not found" do
|
80
|
+
get :show, id: "slug-that-doesnt-exist", use_route: :publish_my_data, :format => format
|
81
|
+
response.should be_not_found
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
shared_examples_for "html format" do
|
87
|
+
it "should render the dataset show template" do
|
88
|
+
get :show, id: dataset.slug, use_route: :publish_my_data, :format => format
|
89
|
+
response.should render_template("publish_my_data/datasets/show")
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
shared_examples_for "a non html format" do
|
94
|
+
|
95
|
+
context "for an existing dataset" do
|
96
|
+
it "should return the dataset dtls in that format" do
|
97
|
+
get :show, id: dataset.slug, use_route: :publish_my_data, :format => format
|
98
|
+
response.body.should == dataset.send("to_#{format}")
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
context "for a non-existent dataset slug" do
|
103
|
+
it "should return a blank body" do
|
104
|
+
get :show, id: "slug-that-doesnt-exist", use_route: :publish_my_data, :format => format
|
105
|
+
response.body.should == "Not Found"
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
context "for html format" do
|
111
|
+
let(:format){ 'html' }
|
112
|
+
it_should_behave_like "html format"
|
113
|
+
it_should_behave_like "dataset show"
|
114
|
+
end
|
115
|
+
|
116
|
+
context "for rdf format" do
|
117
|
+
let(:format){ 'rdf' }
|
118
|
+
it_should_behave_like "a non html format"
|
119
|
+
it_should_behave_like "dataset show"
|
120
|
+
end
|
121
|
+
|
122
|
+
context "for json format" do
|
123
|
+
let(:format){ 'json' }
|
124
|
+
|
125
|
+
# note: we don't use the shared example group here because the JSON format sometimes brings stuff back in different orders!
|
126
|
+
|
127
|
+
context "for an existing dataset" do
|
128
|
+
it "should return the dataset dtls in that format" do
|
129
|
+
get :show, id: dataset.slug, use_route: :publish_my_data, :format => format
|
130
|
+
JSON.parse(response.body).should == JSON.parse(dataset.send("to_#{format}"))
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
context "for a non-existent dataset slug" do
|
135
|
+
it "should return a blank body" do
|
136
|
+
get :show, id: "slug-that-doesnt-exist", use_route: :publish_my_data, :format => format
|
137
|
+
response.body.should == "Not Found"
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
it_should_behave_like "dataset show"
|
142
|
+
end
|
143
|
+
|
144
|
+
context "for ttl format" do
|
145
|
+
let(:format){ 'ttl' }
|
146
|
+
it_should_behave_like "a non html format"
|
147
|
+
it_should_behave_like "dataset show"
|
148
|
+
end
|
149
|
+
|
150
|
+
context "for ntriples format" do
|
151
|
+
let(:format){ 'nt' }
|
152
|
+
it_should_behave_like "a non html format"
|
153
|
+
it_should_behave_like "dataset show"
|
154
|
+
end
|
155
|
+
|
156
|
+
end
|
157
|
+
|
158
|
+
end
|
159
|
+
end
|