Skip to content

Commit

Permalink
specs
Browse files Browse the repository at this point in the history
  • Loading branch information
LuizArmesto committed Sep 26, 2014
1 parent 2e182d6 commit d97c83b
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
47 changes: 47 additions & 0 deletions spec/controllers/application_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,53 @@
controller.send :flash_xhr, "message"
end
end

describe "#news_feed_results" do
let(:user) { FactoryGirl.create(:user) }
let(:other_user) { FactoryGirl.create :user, name: 'John Doe' }
let(:geo_data) { FactoryGirl.create :geo_data }
let(:other_geo_data) { FactoryGirl.create :geo_data }

before do
Following.create followable: geo_data, follower: user
Following.create followable: other_user, follower: user

PublicActivity::Activity.create owner: user, trackable: other_geo_data
PublicActivity::Activity.create owner: other_user, trackable: geo_data
PublicActivity::Activity.create owner: other_user, trackable: other_geo_data
end

after do
Following.delete_all
PublicActivity::Activity.delete_all
end

context 'annonymous user' do
it "gets all activities" do
expect(controller.send(:news_feed_results).count).to be 3
end
end

context 'logged user' do
before do
login_user user
end

it "allows to get all activities" do
expect(controller.send(:news_feed_results, true).count).to be 3
end

it "gets following activities" do
expect(user.following.count).to be 2
expect(controller.send(:news_feed_results).count).to be 2
end

it "does not get activities from the user itself" do
activity = PublicActivity::Activity.create owner: user, trackable: geo_data
expect(controller.send(:news_feed_results)).to_not include activity
end
end
end
end

end
7 changes: 7 additions & 0 deletions spec/helpers/application_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,13 @@
end
end

describe "#selector_option" do
let(:anchor) { '<a href="?param=value" class="option classname selected" data-selector-param="param" data-selector-value="value" data-selector-default="true">Label</a>' }
it "renders selector item" do
expect(helper.selector_option 'Label', 'param', 'value', true, 'classname').to eq anchor
end
end

describe "#additional_info_value" do
context "nil" do
let(:f) { double(object: double(additional_info: nil)) }
Expand Down
1 change: 1 addition & 0 deletions spec/models/concerns/follower_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
let(:user) { FactoryGirl.create :user }
let(:other_user) { FactoryGirl.create :user, name: 'John Doe' }
let(:geo_data) { FactoryGirl.create :geo_data }
let(:other_geo_data) { FactoryGirl.create :geo_data }

describe "has_many followings" do
it { expect {user.followings}.to_not raise_error }
Expand Down

0 comments on commit d97c83b

Please sign in to comment.