Skip to content

Commit

Permalink
Merge pull request consuldemocracy#3718 from consul/remove_obsolete_code
Browse files Browse the repository at this point in the history
Remove unused and obsolete code
  • Loading branch information
javierm committed Sep 25, 2019
2 parents ebdeb81 + ceb376b commit 0f15baa
Show file tree
Hide file tree
Showing 20 changed files with 9 additions and 109 deletions.
14 changes: 4 additions & 10 deletions app/controllers/admin/poll/booth_assignments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,8 @@ def create
@booth_assignment = ::Poll::BoothAssignment.new(poll: @poll,
booth: @booth)

if @booth_assignment.save
notice = t("admin.poll_booth_assignments.flash.create")
else
notice = t("admin.poll_booth_assignments.flash.error_create")
end
@booth_assignment.save

respond_to do |format|
format.js { render layout: false }
end
Expand All @@ -44,11 +41,8 @@ def destroy
@booth = Poll::Booth.find(booth_assignment_params[:booth_id])
@booth_assignment = ::Poll::BoothAssignment.find(params[:id])

if @booth_assignment.destroy
notice = t("admin.poll_booth_assignments.flash.destroy")
else
notice = t("admin.poll_booth_assignments.flash.error_destroy")
end
@booth_assignment.destroy

respond_to do |format|
format.js { render layout: false }
end
Expand Down
1 change: 0 additions & 1 deletion app/controllers/polls_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ def show
.where.not(description: "").order(:given_order)

@answers_by_question_id = {}
poll_answers = ::Poll::Answer.by_question(@poll.question_ids).by_author(current_user&.id)

@last_pair_question_answers = {}
@questions.each do |question|
Expand Down
2 changes: 0 additions & 2 deletions app/models/abilities/tracker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ class Tracker
include CanCan::Ability

def initialize(user)
tracker = user.tracker

can :index, Budget
can [:index, :show, :edit], Budget::Investment
can :manage, Milestone
Expand Down
6 changes: 0 additions & 6 deletions config/api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ User:
public_debates: [Debate]
public_proposals: [Proposal]
public_comments: [Comment]
# organization: Organization
Debate:
fields:
id: integer
Expand Down Expand Up @@ -81,8 +80,3 @@ Vote:
votable_type: string
public_created_at: string
vote_flag: boolean
# Organization:
# fields:
# id: integer
# user_id: integer
# name: string
5 changes: 0 additions & 5 deletions config/locales/en/admin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1028,11 +1028,6 @@ en:
poll_booth_assignments:
alert:
shifts: "There are shifts associated to this booth. If you remove the booth assignment, the shifts will be also deleted. Continue?"
flash:
destroy: "Booth not assigned anymore"
create: "Booth assigned"
error_destroy: "An error ocurred when removing booth assignment"
error_create: "An error ocurred when assigning booth to the poll"
show:
location: "Location"
officers: "Officers"
Expand Down
5 changes: 0 additions & 5 deletions config/locales/es/admin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1029,11 +1029,6 @@ es:
poll_booth_assignments:
alert:
shifts: "Hay turnos asignados para esta urna. Si la desasignas, esos turnos se eliminarán. ¿Deseas continuar?"
flash:
destroy: "Urna desasignada"
create: "Urna asignada"
error_destroy: "Se ha producido un error al desasignar la urna"
error_create: "Se ha producido un error al intentar asignar la urna"
show:
location: "Ubicación"
officers: "Presidentes de mesa"
Expand Down
2 changes: 0 additions & 2 deletions spec/features/admin/admin_notifications_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,6 @@
scenario "A draft Admin notification can be sent", :js do
2.times { create(:user) }
notification = create(:admin_notification, segment_recipient: :all_users)
total_users = notification.list_of_recipients.count
confirm_message = "Are you sure you want to send this notification to #{total_users} users?"

visit admin_admin_notification_path(notification)

Expand Down
22 changes: 1 addition & 21 deletions spec/features/admin/budget_investments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1715,27 +1715,7 @@
context "Selecting csv" do

scenario "Downloading CSV file" do
admin = create(:administrator, user: create(:user, username: "Admin"))
valuator = create(:valuator, user: create(:user, username: "Valuator"))
valuator_group = create(:valuator_group, name: "Valuator Group")
budget_group = create(:budget_group, name: "Budget Group", budget: budget)
first_budget_heading = create(:budget_heading, group: budget_group, name: "Budget Heading")
second_budget_heading = create(:budget_heading, group: budget_group, name: "Other Heading")
first_investment = create(:budget_investment, :feasible, :selected, title: "Le Investment",
budget: budget, group: budget_group,
heading: first_budget_heading,
cached_votes_up: 88, price: 99,
valuators: [],
valuator_groups: [valuator_group],
administrator: admin,
visible_to_valuators: true)
second_investment = create(:budget_investment, :unfeasible, title: "Alt Investment",
budget: budget, group: budget_group,
heading: second_budget_heading,
cached_votes_up: 66, price: 88,
valuators: [valuator],
valuator_groups: [],
visible_to_valuators: false)
create(:budget_investment, budget: budget)

visit admin_budget_budget_investments_path(budget)

Expand Down
1 change: 0 additions & 1 deletion spec/features/admin/emails/newsletters_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@
scenario "Sends newsletter emails", :js do
newsletter = create(:newsletter)
visit admin_newsletter_path(newsletter)
total_users = newsletter.list_of_recipient_emails.count

accept_confirm { click_link "Send" }

Expand Down
3 changes: 0 additions & 3 deletions spec/features/admin/poll/shifts_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
end

scenario "Show" do
poll = create(:poll)
officer = create(:poll_officer)

booth1 = create(:poll_booth)
Expand Down Expand Up @@ -246,7 +245,6 @@
end

scenario "Destroy an officer" do
poll = create(:poll)
booth = create(:poll_booth)
officer = create(:poll_officer)

Expand All @@ -261,7 +259,6 @@
end

scenario "Empty" do
poll = create(:poll)
booth = create(:poll_booth)

visit new_admin_booth_shift_path(booth)
Expand Down
2 changes: 0 additions & 2 deletions spec/features/admin/stats_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,6 @@
end

scenario "Participants by poll" do
oa = create(:poll_officer_assignment)

poll1 = create(:poll)
poll2 = create(:poll)

Expand Down
2 changes: 0 additions & 2 deletions spec/features/admin/system_emails_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,6 @@

expect(page).to have_content "Invitation to CONSUL"
expect(page).to have_content "Thank you for applying to join CONSUL!"

registration_url = new_user_registration_url(track_id: 172943750183759812)
expect(page).to have_link "Complete registration"
end

Expand Down
1 change: 0 additions & 1 deletion spec/features/budgets/investments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1760,7 +1760,6 @@ def investments_order
scenario "Due to being unfeasible" do
user = create(:user, :level_two)
investment = create(:budget_investment, :selected, heading: heading)
heading2 = create(:budget_heading, group: group)

ballot = create(:budget_ballot, user: user, budget: budget)
ballot.investments << investment
Expand Down
1 change: 0 additions & 1 deletion spec/features/direct_messages_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
end

scenario "User not logged in" do
sender = create(:user)
receiver = create(:user)

visit new_user_direct_message_path(receiver)
Expand Down
7 changes: 3 additions & 4 deletions spec/features/polls/answers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,11 @@
end

scenario "Add video to answer" do
answer1 = create(:poll_question_answer, question: question)
answer2 = create(:poll_question_answer, question: question)
answer = create(:poll_question_answer, question: question)

visit admin_question_path(question)

within("#poll_question_answer_#{answer1.id}") do
within("#poll_question_answer_#{answer.id}") do
click_link "Video list"
end

Expand All @@ -55,7 +54,7 @@

click_button "Save"

within("#poll_question_answer_video_#{answer1.videos.last.id}") do
within("#poll_question_answer_video_#{answer.videos.last.id}") do
expect(page).to have_content "Awesome project video"
expect(page).to have_content "https://www.youtube.com/watch?v=123"
end
Expand Down
2 changes: 0 additions & 2 deletions spec/features/polls/voter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@
end

scenario "Voting in booth", :js do
user = create(:user, :in_census)

login_through_form_as_officer(officer.user)

visit new_officing_residence_path
Expand Down
2 changes: 1 addition & 1 deletion spec/features/proposals_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
proposal_with_image = create(:proposal)
image = create(:image, imageable: proposal_with_image)

visit proposals_path(id: proposal)
visit proposals_path

within("#proposal_#{proposal.id}") do
expect(page).not_to have_css("div.with-image")
Expand Down
38 changes: 0 additions & 38 deletions spec/lib/graphql_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,6 @@ def extract_fields(response, collection_name, field_chain)
expect(dig(response, "data.proposal.title")).to eq(proposal.title)
end

xit "returns has_one associations" do
organization = create(:organization)
response = execute("{ user(id: #{organization.user_id}) { organization { name } } }")
expect(dig(response, "data.user.organization.name")).to eq(organization.name)
end

it "returns belongs_to associations" do
response = execute("{ proposal(id: #{proposal.id}) { public_author { username } } }")
expect(dig(response, "data.proposal.public_author.username")).to eq(proposal.public_author.username)
Expand All @@ -72,15 +66,6 @@ def extract_fields(response, collection_name, field_chain)
expect(comment_bodies).to match_array([comment_1.body, comment_2.body])
end

xit "executes deeply nested queries" do
org_user = create(:user)
organization = create(:organization, user: org_user)
org_proposal = create(:proposal, author: org_user)
response = execute("{ proposal(id: #{org_proposal.id}) { public_author { organization { name } } } }")

expect(dig(response, "data.proposal.public_author.organization.name")).to eq(organization.name)
end

it "hides confidential fields of Int type" do
response = execute("{ user(id: #{user.id}) { failed_census_calls_count } }")
expect(hidden_field?(response, "failed_census_calls_count")).to be_truthy
Expand Down Expand Up @@ -157,18 +142,6 @@ def extract_fields(response, collection_name, field_chain)
expect(received_titles).to match_array [visible_proposal.title]
end

xit "only returns proposals of the Human Rights proceeding" do
proposal = create(:proposal)
human_rights_proposal = create(:proposal, proceeding: "Derechos Humanos", sub_proceeding: "Right to have a job")
other_proceeding_proposal = create(:proposal)
other_proceeding_proposal.update_attribute(:proceeding, "Another proceeding")

response = execute("{ proposals { edges { node { title } } } }")
received_titles = extract_fields(response, "proposals", "title")

expect(received_titles).to match_array [proposal.title, human_rights_proposal.title]
end

it "includes proposals of authors even if public activity is set to false" do
visible_author = create(:user, public_activity: true)
hidden_author = create(:user, public_activity: false)
Expand Down Expand Up @@ -556,17 +529,6 @@ def extract_fields(response, collection_name, field_chain)
expect(received_tags).to match_array ["Health", "Transportation"]
end

xit "does not display tags for proceeding's proposals" do
valid_proceeding_proposal = create(:proposal, proceeding: "Derechos Humanos", sub_proceeding: "Right to a Home", tag_list: "Health")
invalid_proceeding_proposal = create(:proposal, tag_list: "Animals")
invalid_proceeding_proposal.update_attribute("proceeding", "Random")

response = execute("{ tags { edges { node { name } } } }")
received_tags = extract_fields(response, "tags", "name")

expect(received_tags).to match_array ["Health"]
end

it "does not display tags for taggings that are not public" do
proposal = create(:proposal, tag_list: "Health")
allow(ActsAsTaggableOn::Tag).to receive(:public_for_api).and_return([])
Expand Down
1 change: 0 additions & 1 deletion spec/models/poll/shift_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@

it "creates and destroy corresponding officer_assignments" do
poll2 = create(:poll)
poll3 = create(:poll)

booth_assignment1 = create(:poll_booth_assignment, poll: poll, booth: booth)
booth_assignment2 = create(:poll_booth_assignment, poll: poll2, booth: booth)
Expand Down
1 change: 0 additions & 1 deletion spec/models/signature_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@
it "creates a user with that document number" do
create(:geozone, census_code: "01")
signature = create(:signature, document_number: "12345678Z")
proposal = signature.signable

signature.verify

Expand Down

0 comments on commit 0f15baa

Please sign in to comment.