Skip to content

Commit

Permalink
Move to Postgresql DB.
Browse files Browse the repository at this point in the history
Pour facilité l'aspect "PRO", et la perf, on bascule sur PostGreSQL. Les
hébergeurs propose en général cette base.
  • Loading branch information
yaf committed Aug 28, 2014
1 parent 1759a7f commit fcf5da5
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 27 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ dump.rdb
*.swp
public/exercice
public/uploads
.env
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ source 'https://rubygems.org'
ruby '2.1.2'

gem 'rails', '4.1.1'
gem 'sqlite3'
gem 'pg'

gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
Expand All @@ -29,6 +29,8 @@ gem 'nested_form'

gem 'bcrypt'

gem 'dotenv-rails', :groups => [:development, :test]

group :development do
gem 'spring'
gem 'rails-clean-logs'
Expand Down
7 changes: 5 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ GEM
dotenv (0.11.1)
dotenv-deployment (~> 0.0.2)
dotenv-deployment (0.0.2)
dotenv-rails (0.11.1)
dotenv (= 0.11.1)
erubis (2.7.0)
execjs (2.2.0)
factory_girl (4.4.0)
Expand Down Expand Up @@ -108,6 +110,7 @@ GEM
nested_form (0.3.2)
nokogiri (1.6.3.1)
mini_portile (= 0.6.0)
pg (0.17.1)
polyglot (0.3.5)
pry (0.9.12.6)
coderay (~> 1.0)
Expand Down Expand Up @@ -175,7 +178,6 @@ GEM
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (~> 2.8)
sqlite3 (1.3.9)
therubyracer (0.12.1)
libv8 (~> 3.16.14.0)
ref
Expand Down Expand Up @@ -205,13 +207,15 @@ DEPENDENCIES
coffee-rails (~> 4.0.0)
cucumber-rails
database_cleaner
dotenv-rails
factory_girl_rails
font-awesome-sass
foreman
haml
jbuilder (~> 2.0)
jquery-rails
nested_form
pg
pry-rescue
rails (= 4.1.1)
rails-clean-logs
Expand All @@ -221,7 +225,6 @@ DEPENDENCIES
sidekiq
sinatra (>= 1.3.0)
spring
sqlite3
therubyracer
turbolinks
uglifier (>= 1.3.0)
2 changes: 1 addition & 1 deletion app/models/answer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ def is_valid?
end

def chosen_choice_ids
chosen_choices.split(",").map{|id| id.to_i}
chosen_choices.split(",").map{|id| id.to_i}
end
end
19 changes: 0 additions & 19 deletions config/database.yml

This file was deleted.

5 changes: 4 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

ActiveRecord::Schema.define(version: 20140827122851) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"

create_table "answers", force: true do |t|
t.string "chosen_choices"
t.integer "question_id"
Expand All @@ -38,7 +41,7 @@
t.integer "user_id"
end

add_index "essais", ["user_id"], name: "index_essais_on_user_id"
add_index "essais", ["user_id"], name: "index_essais_on_user_id", using: :btree

create_table "exercices", force: true do |t|
t.text "consigne"
Expand Down
1 change: 1 addition & 0 deletions dotenv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DATABASE_PASSWORD="something"
6 changes: 3 additions & 3 deletions test/models/answer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class AnswerTest < ActiveSupport::TestCase
test "valid if question with one valid choice" do
question = FactoryGirl.create(:question)
FactoryGirl.create(:choice, valid_answer: true, question: question)
answer = FactoryGirl.create(:answer, chosen_choices: "1", question: question)
answer = FactoryGirl.create(:answer, chosen_choices: "1", question: question)
assert_equal true, answer.is_valid?
end

Expand All @@ -30,15 +30,15 @@ class AnswerTest < ActiveSupport::TestCase
question = FactoryGirl.create(:question)
FactoryGirl.create(:choice, valid_answer: true, question: question)
FactoryGirl.create(:choice, valid_answer: true, question: question)
answer = FactoryGirl.create(:answer, chosen_choices: "2", question: question)
answer = FactoryGirl.create(:answer, chosen_choices: "2", question: question)
assert ! answer.is_valid?
end

test "valid for a question with one invalid choice amongs 2" do
question = FactoryGirl.create(:question)
FactoryGirl.create(:choice, valid_answer: false, question: question)
FactoryGirl.create(:choice, valid_answer: true, question: question)
answer = FactoryGirl.create(:answer, chosen_choices: "2", question: question)
answer = FactoryGirl.create(:answer, chosen_choices: "2", question: question)
assert answer.is_valid?
end
end

0 comments on commit fcf5da5

Please sign in to comment.