Add integration tests for mobile polls and locations

This commit is contained in:
Steffen van Bergerem 2015-07-23 17:30:05 +02:00
parent 6fafa731e6
commit 79dfdfa224
2 changed files with 34 additions and 0 deletions

View file

@ -99,6 +99,12 @@ FactoryGirl.define do
end
end
factory(:status_message_with_location) do
after(:build) do |sm|
FactoryGirl.create(:location, status_message: sm)
end
end
factory(:status_message_with_photo) do
sequence(:text) {|n| "There are #{n} ninjas in this photo." }
after(:build) do |sm|
@ -134,6 +140,7 @@ FactoryGirl.define do
end
factory(:location) do
address "unicorn city"
lat 1
lng 2
end

View file

@ -0,0 +1,27 @@
require "spec_helper"
describe PostsController, type: :request do
context "with a poll" do
let(:sm) { FactoryGirl.build(:status_message_with_poll, public: true) }
it "displays the poll" do
get "/posts/#{sm.id}", format: :mobile
expect(response.status).to eq(200)
expect(response.body).to match(/div class='poll'/)
expect(response.body).to match(/#{sm.poll.poll_answers.first.answer}/)
end
end
context "with a location" do
let(:sm) { FactoryGirl.build(:status_message_with_location, public: true) }
it "displays the location" do
get "/posts/#{sm.id}", format: :mobile
expect(response.status).to eq(200)
expect(response.body).to match(/div class='location'/)
expect(response.body).to match(/#{I18n.t("posts.show.location", location: sm.location.address)}/)
end
end
end