From 79dfdfa224068d103d132f3840a579bb1ee9968d Mon Sep 17 00:00:00 2001 From: Steffen van Bergerem Date: Thu, 23 Jul 2015 17:30:05 +0200 Subject: [PATCH] Add integration tests for mobile polls and locations --- spec/factories.rb | 7 +++++++ spec/integration/mobile_posts_spec.rb | 27 +++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 spec/integration/mobile_posts_spec.rb diff --git a/spec/factories.rb b/spec/factories.rb index 42c39caca..a9989e077 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -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 diff --git a/spec/integration/mobile_posts_spec.rb b/spec/integration/mobile_posts_spec.rb new file mode 100644 index 000000000..058b06948 --- /dev/null +++ b/spec/integration/mobile_posts_spec.rb @@ -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