diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..d25c7f3 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,8 @@ +language: ruby +services: + - postgresql +before_script: + - psql -c "CREATE USER askthem SUPERUSER;" -U postgres + - psql -c 'create database "askthem-test";' -U askthem -d postgres + - bin/rails db:migrate RAILS_ENV=test + diff --git a/config/database.yml b/config/database.yml index 0ff84b7..e61d0eb 100644 --- a/config/database.yml +++ b/config/database.yml @@ -17,4 +17,4 @@ test: production: <<: *default - database: askthem-test + database: askthem-production diff --git a/config/routes.rb b/config/routes.rb index 43d6afd..88de13a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,5 +4,5 @@ resources :questions, :only => [:index, :new, :create] resources :votes, :only => :create - get 'search', to: 'search#index' + get 'search', to: 'search#index', as: :search end diff --git a/test/controllers/search_controller_test.rb b/test/controllers/search_controller_test.rb index 9341b7a..6331ea0 100644 --- a/test/controllers/search_controller_test.rb +++ b/test/controllers/search_controller_test.rb @@ -1,7 +1,11 @@ require 'test_helper' class SearchControllerTest < ActionDispatch::IntegrationTest - # test "the truth" do - # assert true - # end + test "returns results from database" do + get search_url, params: {q: 'Washington'} + result = JSON.parse(response.body) + assert_equal result['results'].size, 1 + assert_equal result['results'].first['text'], + "U.S. Representative - Washington's 4th congressional district" + end end diff --git a/test/fixtures/contests.yml b/test/fixtures/contests.yml index 80aed36..3cd3093 100644 --- a/test/fixtures/contests.yml +++ b/test/fixtures/contests.yml @@ -4,8 +4,7 @@ # model remove the '{}' from the fixture names and add the columns immediately # below each fixture, per the syntax in the comments below # -one: {} -# column: value -# -two: {} -# column: value +one: + name: U.S. Representative + electoral_district_name: Washington's 4th congressional district + electoral_district_type: congressional diff --git a/test/fixtures/questions.yml b/test/fixtures/questions.yml deleted file mode 100644 index 80aed36..0000000 --- a/test/fixtures/questions.yml +++ /dev/null @@ -1,11 +0,0 @@ -# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html - -# This model initially had no columns defined. If you add columns to the -# model remove the '{}' from the fixture names and add the columns immediately -# below each fixture, per the syntax in the comments below -# -one: {} -# column: value -# -two: {} -# column: value diff --git a/test/fixtures/techandciviclife/candidate_contests.yml b/test/fixtures/techandciviclife/candidate_contests.yml deleted file mode 100644 index 80aed36..0000000 --- a/test/fixtures/techandciviclife/candidate_contests.yml +++ /dev/null @@ -1,11 +0,0 @@ -# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html - -# This model initially had no columns defined. If you add columns to the -# model remove the '{}' from the fixture names and add the columns immediately -# below each fixture, per the syntax in the comments below -# -one: {} -# column: value -# -two: {} -# column: value diff --git a/test/fixtures/techandciviclife/candidate_selections.yml b/test/fixtures/techandciviclife/candidate_selections.yml deleted file mode 100644 index 80aed36..0000000 --- a/test/fixtures/techandciviclife/candidate_selections.yml +++ /dev/null @@ -1,11 +0,0 @@ -# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html - -# This model initially had no columns defined. If you add columns to the -# model remove the '{}' from the fixture names and add the columns immediately -# below each fixture, per the syntax in the comments below -# -one: {} -# column: value -# -two: {} -# column: value diff --git a/test/fixtures/techandciviclife/candidates.yml b/test/fixtures/techandciviclife/candidates.yml deleted file mode 100644 index 80aed36..0000000 --- a/test/fixtures/techandciviclife/candidates.yml +++ /dev/null @@ -1,11 +0,0 @@ -# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html - -# This model initially had no columns defined. If you add columns to the -# model remove the '{}' from the fixture names and add the columns immediately -# below each fixture, per the syntax in the comments below -# -one: {} -# column: value -# -two: {} -# column: value diff --git a/test/fixtures/techandciviclife/electoral_districts.yml b/test/fixtures/techandciviclife/electoral_districts.yml deleted file mode 100644 index 80aed36..0000000 --- a/test/fixtures/techandciviclife/electoral_districts.yml +++ /dev/null @@ -1,11 +0,0 @@ -# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html - -# This model initially had no columns defined. If you add columns to the -# model remove the '{}' from the fixture names and add the columns immediately -# below each fixture, per the syntax in the comments below -# -one: {} -# column: value -# -two: {} -# column: value diff --git a/test/fixtures/techandciviclife/offices.yml b/test/fixtures/techandciviclife/offices.yml deleted file mode 100644 index 80aed36..0000000 --- a/test/fixtures/techandciviclife/offices.yml +++ /dev/null @@ -1,11 +0,0 @@ -# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html - -# This model initially had no columns defined. If you add columns to the -# model remove the '{}' from the fixture names and add the columns immediately -# below each fixture, per the syntax in the comments below -# -one: {} -# column: value -# -two: {} -# column: value diff --git a/test/fixtures/techandciviclife/parties.yml b/test/fixtures/techandciviclife/parties.yml deleted file mode 100644 index 80aed36..0000000 --- a/test/fixtures/techandciviclife/parties.yml +++ /dev/null @@ -1,11 +0,0 @@ -# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html - -# This model initially had no columns defined. If you add columns to the -# model remove the '{}' from the fixture names and add the columns immediately -# below each fixture, per the syntax in the comments below -# -one: {} -# column: value -# -two: {} -# column: value diff --git a/test/fixtures/techandciviclife/people.yml b/test/fixtures/techandciviclife/people.yml deleted file mode 100644 index 80aed36..0000000 --- a/test/fixtures/techandciviclife/people.yml +++ /dev/null @@ -1,11 +0,0 @@ -# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html - -# This model initially had no columns defined. If you add columns to the -# model remove the '{}' from the fixture names and add the columns immediately -# below each fixture, per the syntax in the comments below -# -one: {} -# column: value -# -two: {} -# column: value diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml index 80aed36..d27d4d4 100644 --- a/test/fixtures/users.yml +++ b/test/fixtures/users.yml @@ -4,8 +4,5 @@ # model remove the '{}' from the fixture names and add the columns immediately # below each fixture, per the syntax in the comments below # -one: {} -# column: value -# -two: {} -# column: value +one: + email: test@foo.com