Skip to content

Fix JSON endpoints for Teams #284

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 4, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions app/models/team.rb
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,7 @@ def public_json
end

def public_hash
neighbors = Team.find((higher_competitors(5) + lower_competitors(5)).flatten.uniq)
summary.merge(
neighbors: neighbors.collect(&:summary),
members: members.collect { |user| {
name: user.display_name,
username: user.username,
Expand Down
16 changes: 9 additions & 7 deletions spec/models/team_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
let(:invitee) { Fabricate(:user) }

it { is_expected.to have_one :account }

it { is_expected.to have_many :locations }
it { is_expected.to have_many :links }
it { is_expected.to have_many :members }
Expand All @@ -28,6 +27,15 @@
end
end

describe "#public_json" do

it "returns valid JSON" do
json = team.public_json
expect{JSON.parse(json)}.to_not raise_error
end

end

it 'adds the team id to the user when they are added to a team' do
team.add_user(invitee)
expect(invitee.reload.membership.team).to eq(team)
Expand Down Expand Up @@ -91,10 +99,4 @@ def seed_plans!(reset = false)
Plan.create(amount: 19_900, interval: Plan::MONTHLY, analytics: true, name: 'Analytics') if Plan.enhanced_team_page_analytics.nil?
end

it { is_expected.to have_many :locations }
it { is_expected.to have_many :links }
it { is_expected.to have_many :members }
it { is_expected.to have_many :jobs }
it { is_expected.to have_many :followers }

end