diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 0801de8a3b31c748861bc92df20a3eb21bfafe54..cd5ec997e5b5ae085add7c2e6b0addbe3a0caf9c 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -2,7 +2,7 @@ image: ruby:2.3.1
 
 services:
   - postgres:9.5
-  - elasticsearch:2
+  - elasticsearch:6.5.1
   - redis:latest
 
 variables:
@@ -12,6 +12,8 @@ variables:
   ELASTICSEARCH_URL: http://elasticsearch:9200
   REDIS_HOST: redis:6379
   REDIS_RATE_LIMIT_URL: redis://redis:6379/0
+  DSPACE_LOGIN: '$mecdb1_login'
+  DSPACE_PASS: '$mecdb1_password'
 
 stages:
   - test
diff --git a/Gemfile b/Gemfile
index 665b8a784d8cae34703c6729e039849e1e927f51..4bec0e8676762299d5117446535c22fe73298c45 100644
--- a/Gemfile
+++ b/Gemfile
@@ -107,7 +107,7 @@ group :test do
 end
 
 group :development, :test do
-  gem 'rspec-rails', '~> 3.5'
+  gem 'rspec-rails', '~> 3.8' #original is 3.6
   gem 'rspec_api_documentation'
   gem 'factory_girl_rails'
 end
diff --git a/Gemfile.lock b/Gemfile.lock
index b347e1fac2d17a5897ca3cd89051d0bb28757588..77afc24f6eda1b1550643481ff9a09703900b8e0 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -391,27 +391,27 @@ GEM
       actionpack (>= 4.2.0, < 5.3)
       railties (>= 4.2.0, < 5.3)
     rmagick (2.16.0)
-    rspec (3.6.0)
-      rspec-core (~> 3.6.0)
-      rspec-expectations (~> 3.6.0)
-      rspec-mocks (~> 3.6.0)
-    rspec-core (3.6.0)
-      rspec-support (~> 3.6.0)
-    rspec-expectations (3.6.0)
+    rspec (3.8.0)
+      rspec-core (~> 3.8.0)
+      rspec-expectations (~> 3.8.0)
+      rspec-mocks (~> 3.8.0)
+    rspec-core (3.8.0)
+      rspec-support (~> 3.8.0)
+    rspec-expectations (3.8.1)
       diff-lcs (>= 1.2.0, < 2.0)
-      rspec-support (~> 3.6.0)
-    rspec-mocks (3.6.0)
+      rspec-support (~> 3.8.0)
+    rspec-mocks (3.8.0)
       diff-lcs (>= 1.2.0, < 2.0)
-      rspec-support (~> 3.6.0)
-    rspec-rails (3.6.0)
+      rspec-support (~> 3.8.0)
+    rspec-rails (3.8.0)
       actionpack (>= 3.0)
       activesupport (>= 3.0)
       railties (>= 3.0)
-      rspec-core (~> 3.6.0)
-      rspec-expectations (~> 3.6.0)
-      rspec-mocks (~> 3.6.0)
-      rspec-support (~> 3.6.0)
-    rspec-support (3.6.0)
+      rspec-core (~> 3.8.0)
+      rspec-expectations (~> 3.8.0)
+      rspec-mocks (~> 3.8.0)
+      rspec-support (~> 3.8.0)
+    rspec-support (3.8.0)
     rspec_api_documentation (5.0.0)
       activesupport (>= 3.0.0)
       mustache (~> 1.0, >= 0.99.4)
@@ -561,7 +561,7 @@ DEPENDENCIES
   rainbow
   rdoc
   rmagick
-  rspec-rails (~> 3.5)
+  rspec-rails (~> 3.8)
   rspec_api_documentation
   rubocop
   rubycritic
@@ -580,4 +580,4 @@ DEPENDENCIES
   whenever
 
 BUNDLED WITH
-   1.14.6
+   1.14.6
\ No newline at end of file
diff --git a/app/controllers/v1/learning_objects/uploads_controller.rb b/app/controllers/v1/learning_objects/uploads_controller.rb
index 6da88208a8933264b7c3e4ee4fe7eb7bce1b2588..a103f0d98fa27c619ab22cb9ad1257e5cf1cbda9 100644
--- a/app/controllers/v1/learning_objects/uploads_controller.rb
+++ b/app/controllers/v1/learning_objects/uploads_controller.rb
@@ -1,4 +1,4 @@
-
+#
 # Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre
 # Departamento de Informatica - Universidade Federal do Parana
 #
@@ -17,6 +17,7 @@
 # You should have received a copy of the GNU Affero General Public License
 # along with portalmec.  If not, see <http://www.gnu.org/licenses/>.
 
+
 class V1::LearningObjects::UploadsController < ApplicationController
   before_action :set_learning_object
   before_action :authorize!
@@ -24,7 +25,6 @@ class V1::LearningObjects::UploadsController < ApplicationController
   # POST /learning_objects/:learning_object_id/upload
   def create
     return render status: :bad_request unless valid_file?
-
     publisher = LearningObjectPublisher.new(DspaceService.create_client)
     publisher.upload @learning_object, saved_file
 
diff --git a/app/services/dspace_service.rb b/app/services/dspace_service.rb
index 38da88c9a135cec15aed8ddcd2bb684477ab8fc9..ea9957a756b2406def3cc71338334d326d804fec 100644
--- a/app/services/dspace_service.rb
+++ b/app/services/dspace_service.rb
@@ -41,7 +41,7 @@ class DspaceService
 
   def self.config
     config = {}
-
+    
     if Rails.env.production?
       config['link'] = "https://#{ENV['PORTALMEC_DSPACE_HOST']}:#{ENV['PORTALMEC_DSPACE_PORT']}"
       config['login'] = ENV['PORTALMEC_DSPACE_LOGIN']
@@ -51,8 +51,14 @@ class DspaceService
       yml = yml_file.fetch(Rails.env)
 
       config['link'] = "https://#{yml['host']}:#{yml['port']}"
-      config['login'] = yml['login']
-      config['password'] = yml['password']
+
+      if  Rails.env.test?
+        config['login'] = ENV['DSPACE_LOGIN']
+        config['password'] = ENV['DSPACE_PASS']
+      else
+        config['login'] = yml['login']
+        config['password'] = yml['password']
+      end
     end
 
     config
diff --git a/config/dspace.yml b/config/dspace.yml
index 1fb7991e6a22410845d89e616104ee269d931513..52c8106b919e794c407456f15d203dd2c5302843 100644
--- a/config/dspace.yml
+++ b/config/dspace.yml
@@ -1,4 +1,3 @@
-
 # Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre
 # Departamento de Informatica - Universidade Federal do Parana
 #
@@ -18,13 +17,13 @@
 # along with portalmec.  If not, see <http://www.gnu.org/licenses/>.
 
 development:
-  host: mecdb3.c3sl.ufpr.br
+  host: mecdb1.c3sl.ufpr.br
   port: 8443
   login: admin
   password: password
 
 test:
-  host: portalmecdev.c3sl.ufpr.br
+  host: mecdb1.c3sl.ufpr.br
   port: 8443
   login: admin
-  password: password
+  password: password
\ No newline at end of file
diff --git a/config/initializers/elasticsearch.rb b/config/initializers/elasticsearch.rb
index 4190218e866e0cef4e93b3edcc180ec20d002985..2080bde48474465229d2e29d7998d358266d48b9 100644
--- a/config/initializers/elasticsearch.rb
+++ b/config/initializers/elasticsearch.rb
@@ -32,6 +32,11 @@ if Rails.env.production?
       }
     }
   )
+elsif Rails.env.test?
+  elasticsearch_client = Elasticsearch::Client.new(
+    url: 'elasticsearch:9200',
+    transport_options: {request: {timeout: 550}}
+  )
 else
   elasticsearch_client = Elasticsearch::Client.new(
     url: 'localhost:9200',
diff --git a/lib/tasks/dspace_collection.rake b/lib/tasks/dspace_collection.rake
new file mode 100644
index 0000000000000000000000000000000000000000..97590640ee0668d94721210340365fe7cf22dae5
--- /dev/null
+++ b/lib/tasks/dspace_collection.rake
@@ -0,0 +1,121 @@
+# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre
+# Departamento de Informatica - Universidade Federal do Parana
+#
+# This file is part of portalmec.
+#
+# portalmec is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# portalmec is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with portalmec.  If not, see <http://www.gnu.org/licenses/>.
+
+
+require 'dspace'
+
+
+namespace :dspace do
+  
+  desc 'Test id\'s Collection and Community'
+  task view_collection: :environment do
+    # ============================================================================ #
+    # Create Dspace Client
+    client = DspaceService.create_client
+    if !client.is_running?
+      raise 'Can\'t connect to DSpace API.'
+    end
+
+    client.communities.all.each do |community|
+      puts "-> #{community.name} id = #{community.id}"
+
+      # GET ALL COMMUNITIES's COLLECTIONS
+      client.communities.collections(:id => community.id).each do |collection|
+        puts "\t->#{collection.name} id= #{collection.id}"
+
+        # GET ALL COLLECTIONS's ITEMS
+        client.collections.items(:id => collection.id, limit: 10, offset: 0, expand: "metadata").each do |item|
+          puts "\t\t->#{item.name} id = #{item.id}"
+
+          # GET ALL ITEMS's BITSTREAMS
+          client.items.bitstreams(:id => item.id).each do |bitstream|
+            puts "\t\t\t->#{bitstream.name}"
+
+          end
+        end
+      end
+    end
+  end
+
+
+  desc 'Create DSpace Collection'
+  task create_collection: :environment do
+
+    # ============================================================================ #
+    # Create Dspace Client
+    client = DspaceService.create_client
+    if !client.is_running?
+      raise 'Can\'t connect to DSpace API.'
+    end
+
+    p "------------ Communities"
+    p client.communities.all
+
+    # ============================================================================ #
+    community = client.communities.create(
+      Dspace::Community.new(
+        {
+          'name' => "Test Community 1",
+          'introductoryText' => "This it a test!",
+          'shortDescription' => "This is a test!",
+          'sidebarText' => "Thist is a test!"
+        }
+      )
+    )
+    p "------------ Community created"
+    p community
+    # ============================================================================ #
+
+    # ============================================================================ #
+    # Create COLLECTION
+    collection = client.communities.create_collection(
+      Dspace::Collection.new(
+        {
+          'name' => "TEST_COLLECTION",
+          'introductoryText' => "This is a test for collection!",
+          'shortDescription' => "This is a test for collection!",
+          'sidebarText' => "This is a test for collection!"
+        }
+      ),
+      id: community.id
+    )
+    p "------------ Collection created"
+    p collection
+
+    # ============================================================================ #
+  end
+
+  desc 'Delete DSpace Collection'
+  task delete_collection: :environment do
+# ============================================================================ #
+    # Create Dspace Client
+    client = DspaceService.create_client
+    if !client.is_running?
+      raise 'Can\'t connect to DSpace API.'
+    end
+# ============================================================================= #
+    community = client.communities.all.last
+    # p community
+    # collection = client.collections.all.last
+    # p collection
+   
+    # teste = client.collections.delete(id: collection.id)
+    # p teste
+    client.communities.delete(id: community.id)
+  end
+end
diff --git a/spec/acceptance/downloads_spec.rb b/spec/acceptance/downloads_spec.rb
index 948910cd14315b0f3bdbac0d2c05b303701bee90..cbef92a2d220628273da23808728dece02a29606 100644
--- a/spec/acceptance/downloads_spec.rb
+++ b/spec/acceptance/downloads_spec.rb
@@ -20,10 +20,13 @@
 require 'acceptance_helpers'
 require 'shared/contexts'
 
+
 resource 'Downloads' do
 
   explanation "An user can download the content of a learning object or collection."
 
+  let(:learning_objects) { LearningObject.all }
+
   get '/v1/:type/:id/download' do
     include_context "authenticate_user"
 
@@ -31,15 +34,14 @@ resource 'Downloads' do
     parameter :id, "The id of object", scope: :download
 
     let(:type) { 'learning_objects' }
-    let(:id) { @learning_object.id }
-
+    let(:id) {  @learning_object.id }
 
     before do
       @learning_object = create(:learning_object, publisher: @user)
-      create(:attachment, learning_object: @learning_object)
+      create(:attachment, learning_object: @learning_object )
     end
 
-    example_request 'Download an object' do
+      example_request 'Download an object' do
       expect(status).to eq(302)
     end
   end
diff --git a/spec/factories/attachments.rb b/spec/factories/attachments.rb
index e8826fb61b8644830003830779dc1ee404b2f26d..a15496db7c3e4ebcae886d0ac757dfe9f5408f1c 100644
--- a/spec/factories/attachments.rb
+++ b/spec/factories/attachments.rb
@@ -21,7 +21,8 @@ FactoryGirl.define do
 
   factory :attachment, class: LearningObject::Attachment do |f|
   	f.name { Faker::Name.name }
-  	f.retrieve_link { Faker::File.file_name }
+  	f.bundle_name { "ORIGINAL" }
+  	f.retrieve_link { "/bitstreams/17834/retrieve" }
     f.mime_type { Faker::File.mime_type }
   end