diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 0000000000000000000000000000000000000000..8b853de93ba410e76ceadb358f44f597d41745c7
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,20 @@
+before_script:
+  - bundle install
+
+stages:
+  - test
+  - deploy
+
+test:
+  script:
+    - bundle exec rake db:migrate RAILS_ENV=test
+    - bundle exec rake test RAILS_ENV=test
+  only:
+    - master
+
+deploy:
+  only:
+    - master
+  script:
+    - bundle exec mina setup
+    - bundle exec mina deploy
diff --git a/Gemfile b/Gemfile
index 86a31c06d61db4e565f26cdac5846688844790e4..b8993b98bfd80fab314c2dea10104b9c94dc64f7 100644
--- a/Gemfile
+++ b/Gemfile
@@ -50,6 +50,10 @@ group :development, :test do
   gem 'sqlite3'
 end
 
+group :test do
+  gem 'shoulda'
+end
+
 # authentication
 gem 'devise'
 
@@ -65,4 +69,6 @@ gem 'gruff'
 gem 'chart-js-rails'
 
 #depoyment
-gem 'mina'
\ No newline at end of file
+gem 'mina'
+
+gem 'rubycritic', require: false
\ No newline at end of file
diff --git a/README b/README.md
similarity index 69%
rename from README
rename to README.md
index 82ec1f0fd4b1a00cbe95911579cb5434df2209bd..bf035b6e55056511c1c7e97bd2235d5f36240082 100644
--- a/README
+++ b/README.md
@@ -1,5 +1,6 @@
 # Portal MEC
-Breve descrição
+
+[![build status](https://ci.gitlab.c3sl.ufpr.br/projects/19/status.png?ref=master)](https://ci.gitlab.c3sl.ufpr.br/projects/19?ref=master)
 
 ## Requirements
  * ruby >=2.2
diff --git a/app/controllers/management/highlights_controller.rb b/app/controllers/management/highlights_controller.rb
index 967c8b2946752c6a4b13d7e610d0a7fd589a4a3a..5c00b068add9488623c35b34216cb5c22dc45f7a 100644
--- a/app/controllers/management/highlights_controller.rb
+++ b/app/controllers/management/highlights_controller.rb
@@ -1,25 +1,18 @@
 class Management::HighlightsController < ManagementController
 
 
-
   def index
-    #rep = repository.for(:user)
-    db = OrientDb::HighlightRepository.new
-    @highlights = db.find_all
+    @highlights = highlight_repository.find_all
   end
 
   def show
   end
 
   def new
-
   end
 
-
-
   def delete
-    db = OrientDb::HighlightRepository.new
-    @highlights = db.find_all
+    @highlights = highlight_repository.find_all
   end
 
   def create
@@ -29,9 +22,12 @@ class Management::HighlightsController < ManagementController
     db = OrientDb::HighlightRepository.new
     db.insert_data(@name,@url)
 
-
   end
 
+  private
 
+  def highlight_repository
+    repository.for :highlight
+  end
 
 end
diff --git a/app/controllers/universities_controller.rb b/app/controllers/universities_controller.rb
index 3e677851fb00c79021d2857e17d5c5133c859f21..de948add54c9b5a51a9d3fc5633f339f942191a3 100644
--- a/app/controllers/universities_controller.rb
+++ b/app/controllers/universities_controller.rb
@@ -1,7 +1,7 @@
 class UniversitiesController < ApplicationController
 
   def index
-    @universities = university_repository.find_all
+    @universities = university_repository.find_all || []
   end
 
   def show
diff --git a/app/repositories/active_record/country_repository.rb b/app/repositories/active_record/country_repository.rb
new file mode 100644
index 0000000000000000000000000000000000000000..6c2f6ec3be1eec57fb47bb2016908f19c10f3ad1
--- /dev/null
+++ b/app/repositories/active_record/country_repository.rb
@@ -0,0 +1,11 @@
+module ActiveRecord
+  class CountryRepository
+
+    def find_all
+    end
+
+    def find_by_id(rid)
+    end
+
+  end
+end
diff --git a/app/repositories/active_record/highlight_repository.rb b/app/repositories/active_record/highlight_repository.rb
new file mode 100644
index 0000000000000000000000000000000000000000..39afb4fc9432756044326b33dd6a197b7968c12b
--- /dev/null
+++ b/app/repositories/active_record/highlight_repository.rb
@@ -0,0 +1,11 @@
+module ActiveRecord
+  class HighlightRepository
+
+    def find_all
+    end
+
+    def insert_data(name, url)
+    end
+
+  end
+end
diff --git a/app/repositories/active_record/university_repository.rb b/app/repositories/active_record/university_repository.rb
new file mode 100644
index 0000000000000000000000000000000000000000..af12cb1dd05913918b71d0b787071d1da8a49919
--- /dev/null
+++ b/app/repositories/active_record/university_repository.rb
@@ -0,0 +1,14 @@
+module ActiveRecord
+  class UniversityRepository
+
+    def find_all
+    end
+
+    def find_by_id(rid)
+    end
+
+    def has(rid)
+    end
+
+  end
+end
diff --git a/app/repositories/active_record/user_repository.rb b/app/repositories/active_record/user_repository.rb
index 5354ec2f9ec97f14211f59a125b746149c84901c..0f9109e58ecae8e5eec4375024b1f0b046b2371d 100644
--- a/app/repositories/active_record/user_repository.rb
+++ b/app/repositories/active_record/user_repository.rb
@@ -1,11 +1,14 @@
-class ActiveRecord::UserRepository
+module ActiveRecord
+  class UserRepository
 
-  def all
-    User.all
-  end
+    def find_by_id(rid)
+    end
 
-  def create!(attributes={})
-    User.create! attributes
-  end
+    def author_of(rid)
+    end
 
+    def has(rid)
+    end
+
+  end
 end
\ No newline at end of file
diff --git a/app/repositories/orient_db/base.rb b/app/repositories/orient_db/base.rb
index 3bec60afad5b12613559148d7502cd343565911e..ff4a148e7c7a17dbd8d6dc11d0ec8e0ce07b0b7d 100644
--- a/app/repositories/orient_db/base.rb
+++ b/app/repositories/orient_db/base.rb
@@ -1,15 +1,13 @@
 class OrientDb::Base
-
   attr_reader :connection
 
-  def initialize(connection = nil)
-    @connection ||= Orientdb4r.client
-    @connection.connect :database => "teste", :user => "root", :password => "root"
+  def initialize(connection)
+    @connection = connection
 
-    rescue => e
-        puts "Error at connection"
-        puts e.message
-        puts e.backtrace
+  rescue => e
+    puts "Fail to connect OrientDb"
+    puts e.message
+    puts e.backtrace
   end
 
 end
diff --git a/app/repositories/orient_db/country_repository.rb b/app/repositories/orient_db/country_repository.rb
index 7b11e80f1a761287d3fd10ab698c415f408062ee..02e23a04d32a028734e78d4dc909939881780417 100644
--- a/app/repositories/orient_db/country_repository.rb
+++ b/app/repositories/orient_db/country_repository.rb
@@ -2,12 +2,12 @@ module OrientDb
   class CountryRepository < Base
 
     def find_all
-      return @connection.query "SELECT * FROM Country LIMIT 100 OFFSET 20"
+      return connection.query "SELECT * FROM Country LIMIT 100 OFFSET 20"
     end
 
     def find_by_id(rid)
-      res = @connection.query "SELECT title FROM Country WHERE @rid=##{rid}"
-      res[0]["has"] = @connection.query "SELECT expand(in) from (SELECT expand(out_has) FROM Country WHERE @rid=##{rid} LIMIT 30)"
+      res = connection.query "SELECT title FROM Country WHERE @rid=##{rid}"
+      res[0]["has"] = connection.query "SELECT expand(in) from (SELECT expand(out_has) FROM Country WHERE @rid=##{rid} LIMIT 30)"
       res[0]
     end
   end
diff --git a/app/repositories/orient_db/highlight_repository.rb b/app/repositories/orient_db/highlight_repository.rb
index 2fde09314516c44b28b67825d1ae90103c2999f9..473c457d4b5d3c45c0ddb85bacd299a935812711 100644
--- a/app/repositories/orient_db/highlight_repository.rb
+++ b/app/repositories/orient_db/highlight_repository.rb
@@ -6,11 +6,12 @@ module OrientDb
     end
 
     def find_all
-        return @connection.query "SELECT FROM Highlight"
-      rescue
-        return nil
+      return connection.query "SELECT FROM Highlight"
+    rescue
+      return nil
     end
 
+
     def insert_data (name,url)
         return @connection.command "INSERT INTO Highlight (name,URL) VALUES ('#{name}','#{url}')"
       rescue
@@ -20,6 +21,7 @@ module OrientDb
     def remove_data
 
     #return @connection.command "DELETE FROM Highlight (name)"
+
     end
 
   end
diff --git a/app/repositories/orient_db/university_repository.rb b/app/repositories/orient_db/university_repository.rb
index a15ba1f769077461f08d90e35361e7954cd67e22..864ecf15e59f33c613b79e9137f990978a48260b 100644
--- a/app/repositories/orient_db/university_repository.rb
+++ b/app/repositories/orient_db/university_repository.rb
@@ -6,25 +6,25 @@ module OrientDb
     end
 
     def find_all
-        return @connection.query "SELECT FROM University LIMIT 100"
+      return connection.query "SELECT FROM University LIMIT 100"
     end
 
     def find_by_id(rid)
-        res = @connection.query "SELECT title FROM University WHERE @rid=##{rid}"
+      res = connection.query "SELECT title FROM University WHERE @rid=##{rid}"
 
-        localized = @connection.query "SELECT expand(out) from (SELECT expand(in_has) FROM University WHERE @rid=##{rid})"
+      localized = connection.query "SELECT expand(out) from (SELECT expand(in_has) FROM University WHERE @rid=##{rid})"
 
-        #aux = @connection.query "SELECT FROM University WHERE @rid=##{rid}"
-        comments = @connection.query "SELECT expand(in_commented) FROM University WHERE @rid=##{rid}"
+      #aux = connection.query "SELECT FROM University WHERE @rid=##{rid}"
+      comments = connection.query "SELECT expand(in_commented) FROM University WHERE @rid=##{rid}"
 
-        res[0]["comments"] = comments[0];
-        res[0]["localized_in"] = localized[0];
+      res[0]["comments"] = comments[0];
+      res[0]["localized_in"] = localized[0];
 
-        return res[0];
+      return res[0];
     end
 
     def has(rid)
-        @connection.query "SELECT expand(in) FROM (SELECT expand(out_has) FROM University WHERE @rid=#{rid})"
+      connection.query "SELECT expand(in) FROM (SELECT expand(out_has) FROM University WHERE @rid=#{rid})"
     end
   end
 end
diff --git a/app/repositories/orient_db/user_repository.rb b/app/repositories/orient_db/user_repository.rb
index f202f540067896f33fe53f608117503b536fcd10..981554bba1c9e28295ad0f0dffa41c8da102d648 100644
--- a/app/repositories/orient_db/user_repository.rb
+++ b/app/repositories/orient_db/user_repository.rb
@@ -1,20 +1,17 @@
 module OrientDb
   class UserRepository < Base
 
-    def register(attributes={})
-
-    end
-
     def find_by_id(rid)
-        return @connection.query "SELECT FROM User WHERE @rid=#{rid}"
+      return connection.query "SELECT FROM User WHERE @rid=#{rid}"
     end
 
     def author_of(rid)
-        return @connection.query "SELECT expand(in) FROM (SELECT expand(out_author_of) FROM User WHERE @rid=#{rid})"
+      return connection.query "SELECT expand(in) FROM (SELECT expand(out_author_of) FROM User WHERE @rid=#{rid})"
     end
 
     def has(rid)
-        return @connection.query "SELECT expand(in) FROM (SELECT expand(out_has) FROM User WHERE @rid=#{rid})"
+      return connection.query "SELECT expand(in) FROM (SELECT expand(out_has) FROM User WHERE @rid=#{rid})"
     end
+
   end
 end
diff --git a/config/database.yml b/config/database.yml
index b6e0c01802bd1e93f0aaf2323854bb06ce275830..fd49fafb912ad8dda530f0855280d222b08329a0 100644
--- a/config/database.yml
+++ b/config/database.yml
@@ -17,4 +17,4 @@ production:
   <<: *default
   database: portalmec_production
   username: portalmec
-  password: <%= ENV['PORTALMEC_DATABASE_PASSWORD'] %>
+  password: <%= ENV['PORTALMEC_DATABASE_PASSWORD'] %>
\ No newline at end of file
diff --git a/config/deploy.rb b/config/deploy.rb
index 6576ff5e0e49e0e85401b38bef2f08f462196a4d..bb8a24112c0d802fbedeeb3149bfd6858e23e380 100644
--- a/config/deploy.rb
+++ b/config/deploy.rb
@@ -4,22 +4,31 @@ require 'mina/git'
 
 set :rails_env, 'production'
 
-set :domain,     'portalmecdev.c3sl.ufpr.br'
-set :deploy_to,  "/home/portalmec/#{rails_env}"
-set :app_path,   "#{deploy_to}/#{current_path}"
+set :domain, 'portalmecdev.c3sl.ufpr.br'
+set :deploy_to, "/home/portalmec/#{rails_env}"
+set :app_path, "#{deploy_to}/#{current_path}"
 set :repository, 'git@gitlab.c3sl.ufpr.br:portalmec/portalmec.git'
-set :branch,     'master'
-set :user,       'portalmec'
+set :branch, 'master'
+set :user, 'portalmec'
 
 task :environment do
   #invoke :'rbenv:load'
 end
 
 task deploy: :environment do
-
   deploy do
     invoke :'git:clone'
-    execute 'bundle install --binstubs'
-    execute 'rake daily:stats'
+
+    queue %[echo "-----> Installing ruby gems"]
+    execute 'bundle install --deployment --without development test'
+
+    queue %[echo "-----> Migrating database"]
+    execute 'bundle exec rake db:migrate'
+
+    queue %[echo "-----> Populate database with db/seeds.rb"]
+    execute 'bundle exec rake db:seed'
+
+    queue %[echo "----------> Pre compiling assets"]
+    execute 'bundle exec rake assets:precompile'
   end
 end
diff --git a/config/initializers/orientdb.rb b/config/initializers/orientdb.rb
new file mode 100644
index 0000000000000000000000000000000000000000..8068c3593b63baeb8dad3f5d3d776bac957842e9
--- /dev/null
+++ b/config/initializers/orientdb.rb
@@ -0,0 +1,9 @@
+require 'yaml'
+
+orientdb_configs = YAML.load_file(Rails.root.join('config').to_s.concat('/orient_db.yml'))
+env_config = orientdb_configs.fetch(Rails.env)
+
+OrientDb::Config.host = env_config['host']
+OrientDb::Config.database = env_config['database']
+OrientDb::Config.user = env_config['username']
+OrientDb::Config.password = env_config['password']
\ No newline at end of file
diff --git a/config/initializers/repositories.rb b/config/initializers/repositories.rb
index 3ab22356399d1e6e764536d20c881752e1d962ae..daa9705118a97141d06576f6c6c35a799f822131 100644
--- a/config/initializers/repositories.rb
+++ b/config/initializers/repositories.rb
@@ -1,20 +1,22 @@
+orientdb_instance = OrientDb::Client.instance
+
 Repository::Environments.create :development do |repository|
-  repository.register :user, OrientDb::UserRepository.new
-  repository.register :university, OrientDb::UniversityRepository.new
-  repository.register :highlight, OrientDb::HighlightRepository.new
-  repository.register :country, OrientDb::CountryRepository.new
+  repository.register :user, OrientDb::UserRepository.new(orientdb_instance)
+  repository.register :university, OrientDb::UniversityRepository.new(orientdb_instance)
+  repository.register :highlight, OrientDb::HighlightRepository.new(orientdb_instance)
+  repository.register :country, OrientDb::CountryRepository.new(orientdb_instance)
 end
 
 Repository::Environments.create :test do |repository|
-  repository.register :user, OrientDb::UserRepository.new
-  repository.register :university, OrientDb::UniversityRepository.new
-  repository.register :highlight, OrientDb::HighlightRepository.new
-  repository.register :country, OrientDb::CountryRepository.new
+  repository.register :user, OrientDb::UserRepository.new(orientdb_instance)
+  repository.register :university, OrientDb::UniversityRepository.new(orientdb_instance)
+  repository.register :highlight, OrientDb::HighlightRepository.new(orientdb_instance)
+  repository.register :country, OrientDb::CountryRepository.new(orientdb_instance)
 end
 
 Repository::Environments.create :production do |repository|
-  repository.register :user, OrientDb::UserRepository.new
-  repository.register :university, OrientDb::UniversityRepository.new
-  repository.register :highlight, OrientDb::HighlightRepository.new
-  repository.register :country, OrientDb::CountryRepository.new
-end
+  repository.register :user, OrientDb::UserRepository.new(orientdb_instance)
+  repository.register :university, OrientDb::UniversityRepository.new(orientdb_instance)
+  repository.register :highlight, OrientDb::HighlightRepository.new(orientdb_instance)
+  repository.register :country, OrientDb::CountryRepository.new(orientdb_instance)
+end
\ No newline at end of file
diff --git a/config/orient_db.yml b/config/orient_db.yml
new file mode 100644
index 0000000000000000000000000000000000000000..502d9c5ccd0fa1bdd2ec5113821e7afea0ecf16e
--- /dev/null
+++ b/config/orient_db.yml
@@ -0,0 +1,17 @@
+development: &development
+  host: mecdb2.c3sl.ufpr.br
+  database: PortalMEC
+  username: admin
+  password: admin
+
+test:
+  host: mecdb2.c3sl.ufpr.br
+  database: PortalMEC
+  username: admin
+  password: admin
+
+production:
+  host: mecdb2.c3sl.ufpr.br
+  database: PortalMEC
+  username: admin
+  password: admin
\ No newline at end of file
diff --git a/lib/orient_db/client.rb b/lib/orient_db/client.rb
new file mode 100644
index 0000000000000000000000000000000000000000..fdce7f7249e64b1192ad1fca8f9d450e5ae9b17a
--- /dev/null
+++ b/lib/orient_db/client.rb
@@ -0,0 +1,17 @@
+class OrientDb::Client
+  @@client = nil
+
+  def self.instance
+    if !@@client.nil?
+      return @@client
+    end
+
+    begin
+      @@client = Orientdb4r.client :host => OrientDb::Config::host, :port => OrientDb::Config::port, :ssl => OrientDb::Config::ssl
+      @@client.connect(database: OrientDb::Config::database, user: OrientDb::Config::user, password: OrientDb::Config::password)
+    rescue Orientdb4r::UnauthorizedError => e
+      raise 'Wrong orient db credentials'
+    end
+  end
+
+end
\ No newline at end of file
diff --git a/lib/orient_db/config.rb b/lib/orient_db/config.rb
new file mode 100644
index 0000000000000000000000000000000000000000..bc27ae91af79a92bae1e1df67db13cce7513f870
--- /dev/null
+++ b/lib/orient_db/config.rb
@@ -0,0 +1,53 @@
+module OrientDb::Config
+  @@ssl = false
+  @@port = 2480
+
+  def self.database
+    @@database
+  end
+
+  def self.user
+    @@user
+  end
+
+  def self.password
+    @@password
+  end
+
+  def self.database=(database)
+    @@database = database
+  end
+
+  def self.user=(username)
+    @@user = username
+  end
+
+  def self.password=(password)
+    @@password = password
+  end
+
+  def self.host=(host)
+    @@host = host
+  end
+
+  def self.port=(port)
+    @@port = port
+  end
+
+  def self.ssl=(ssl)
+    @@ssl = ssl
+  end
+
+  def self.host
+    @@host
+  end
+
+  def self.port
+    @@port || 2480
+  end
+
+  def self.ssl
+    @@ssl || false
+  end
+
+end
\ No newline at end of file
diff --git a/lib/repository/environments.rb b/lib/repository/environments.rb
index f6cda9af7ec7989c50407402f18c1acb5a20476f..55ea9ae9aa68f66c9838c73c42728a4baecbbd71 100644
--- a/lib/repository/environments.rb
+++ b/lib/repository/environments.rb
@@ -2,6 +2,7 @@
 class Repository::Environments
 
   def self.create(env)
+    env = env
     environments[env] = Repository::Repository.new
     yield(environments[env]) if block_given?
   end
@@ -11,7 +12,7 @@ class Repository::Environments
   end
 
   def self.fetch(env)
-    environments.fetch env
+    environments.fetch env.to_sym
   end
 
 end
\ No newline at end of file
diff --git a/test/controllers/university_controller_test.rb b/test/controllers/university_controller_test.rb
index 54e3468466a9def971808572f59465b3f15103a7..747c990f3abc2a6eb3c26f96a5f57eaf27e36395 100644
--- a/test/controllers/university_controller_test.rb
+++ b/test/controllers/university_controller_test.rb
@@ -1,6 +1,8 @@
 require 'test_helper'
 
 class UniversityControllerTest < ActionController::TestCase
+  tests UniversitiesController
+
   test "should get index" do
     get :index
     assert_response :success
diff --git a/test/models/user_test.rb b/test/models/user_test.rb
index 82f61e0109663ddb34c9850653978c5280db0d59..636d460edad619b8548abaec67554f4a442598ba 100644
--- a/test/models/user_test.rb
+++ b/test/models/user_test.rb
@@ -1,7 +1,7 @@
 require 'test_helper'
 
 class UserTest < ActiveSupport::TestCase
-  # test "the truth" do
-  #   assert true
-  # end
+  test 'true' do
+    assert true
+  end
 end
diff --git a/test/repositories/active_record/user_repository_test.rb b/test/repositories/active_record/user_repository_test.rb
index e495d0e677ea79cf617a53b22bbcba7302b95b3a..d473b4bad2e948134c2bced3ffeaa4969d1ca366 100644
--- a/test/repositories/active_record/user_repository_test.rb
+++ b/test/repositories/active_record/user_repository_test.rb
@@ -6,9 +6,4 @@ class ActiveRecord::UserRepositoryTest < ActiveSupport::TestCase
     @repo = ActiveRecord::UserRepository.new
   end
 
-  test 'get all users' do
-    # number of users fixtures
-    assert_equal 2, @repo.all.count
-  end
-
 end
\ No newline at end of file