spec/controllers/downloads_controller_spec.rb in curate-0.3.2 vs spec/controllers/downloads_controller_spec.rb in curate-0.4.2
- old
+ new
@@ -2,13 +2,14 @@
describe DownloadsController do
describe '#show' do
let(:user) { FactoryGirl.create(:user) }
let(:another_user) { FactoryGirl.create(:user) }
- let(:visibility) { AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE }
+ let(:visibility) { Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE }
+ let(:image_file) { File.open(Rails.root.join('../fixtures/files/image.png')) }
let(:generic_file) {
- FactoryGirl.create_generic_file(:mock_curation_concern, user) {|g|
+ FactoryGirl.create_generic_file(:generic_work, user) {|g|
g.visibility = visibility
}
}
it "raise not_found if the object does not exist" do
@@ -35,8 +36,16 @@
it 'sends the file if the user has access' do
generic_file
sign_in user
get :show, id: generic_file.to_param
response.body.should == generic_file.content.content
+ end
+
+ it 'sends requested datastream content' do
+ generic_file.datastreams['thumbnail'].content = image_file
+ generic_file.save!
+ sign_in user
+ get :show, id: generic_file.to_param, datastream_id: 'thumbnail'
+ response.body.should == generic_file.thumbnail.content
end
end
end