Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'rails_helper'
- describe "Emissions upload" do
- describe "POST /emissions" do
- before(:all) do
- params=eval(File.read("spec/fixtures/postparams.txt"))
- @user=User.create username:"Ville", password:"TestiPosti1", password_confirmation:"TestiPosti1"
- post emissions_path, params
- end
- it "uploads the pictures" do
- expect(DownloadableFile.count).to eq(13)
- end
- it "has the cities set u correctly" do
- expect(City.count).to eq(3)
- city_names=City.all.map(&:name)
- expect(city_names).to include("Helsinki")
- expect(city_names).to include("Tampere")
- expect(city_names).to include("Timbutku")
- expect(city_names).not_to include("skrikidii")
- end
- it "has the city_spots set up correctly" do
- expect(CitySpot.count).to eq(6)
- tampere=City.find_by_name "Tampere"
- helsinki=City.find_by_name "Helsinki"
- expect(helsinki.city_spots.count).to eq(4)
- expect(tampere.city_spots.count).to eq(2)
- helsinki_city_spot_names=helsinki.city_spots.map(&:name)
- expect(helsinki_city_spot_names).to include("EspooLeppavaara")
- expect(helsinki_city_spot_names).to include("Ranta")
- tampere_city_spot_names=tampere.city_spots.map(&:name)
- expect(tampere_city_spot_names).to include("Ranta")
- expect(tampere_city_spot_names).to include("Manse")
- expect(tampere_city_spot_names).not_to include("Skrikidii")
- leppavaara=CitySpot.find_by_name("EspooLeppavaara")
- expect(leppavaara.downloadable_files.count).to eq 2
- expect(leppavaara.pollutant_infos.count).to eq(2)
- tikkurila=CitySpot.find_by_name "VantaaTikkurila"
- expect(tikkurila.downloadable_files.count).to eq(1)
- expect(tikkurila.pollutant_infos.count).to eq(1)
- end
- it "has pollutant_infos set up correctly" do
- expect(PollutantInfo.count).to eq(2)
- pollutant_names=PollutantInfo.all.map(&:pollutant_name)
- expect(pollutant_names).to include("NO2")
- expect(pollutant_names).to include("SO2")
- no2=PollutantInfo.find_by_pollutant_name "NO2"
- expect(no2.downloadable_files.count).to eq(3)
- so2=PollutantInfo.find_by_pollutant_name "SO2"
- expect(so2.downloadable_files.count).to eq(4)
- end
- it "has measurements set up correctly" do
- expect(Measurement.count).to eq(1)
- expect(CitySpot.find_by_name("EspooLeppavaara").measurements.count).to eq(1)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement