How to use end method of Reportable Package

Best Minitest_ruby code snippet using Reportable.end

manage_moderations_examples.rb

Source:manage_moderations_examples.rb Github

copy

Full Screen

...4 reportables.first(reportables.length - 1).map do |reportable|5 moderation = create(:moderation, reportable: reportable, report_count: 1, reported_content: reportable.reported_searchable_content_text)6 create(:report, moderation: moderation)7 moderation8 end9 end10 let!(:moderation) { moderations.first }11 let(:moderations_link_text) { "Moderations" }12 before do13 visit participatory_space_path14 click_link moderations_link_text15 end16 it "sorts the most recent first" do17 within ".pagination" do18 click_link "Last"19 end20 all("tbody tr").each_with_index do |row, _index|21 expect(row.find("td:first-child")).to have_content(reportables.first.id)22 end23 end24end25shared_examples "manage moderations" do26 let!(:moderations) do27 reportables.first(reportables.length - 1).map do |reportable|28 moderation = create(:moderation, reportable: reportable, report_count: 1, reported_content: reportable.reported_searchable_content_text)29 create(:report, moderation: moderation)30 moderation31 end32 end33 let!(:moderation) { moderations.first }34 let!(:hidden_moderations) do35 reportables.last(1).map do |reportable|36 moderation = create(:moderation, reportable: reportable, report_count: 3, reported_content: reportable.reported_searchable_content_text, hidden_at: Time.current)37 create_list(:report, 3, moderation: moderation, reason: :spam)38 moderation39 end40 end41 let(:moderations_link_text) { "Moderations" }42 before do43 visit participatory_space_path44 click_link moderations_link_text45 end46 context "when listing moderations" do47 it "only lists moderations for the current organization" do48 external_reportable = create :dummy_resource49 external_moderation = create(:moderation, reportable: external_reportable, report_count: 1, reported_content: external_reportable.reported_searchable_content_text)50 create(:report, moderation: external_moderation)51 visit current_path52 expect(page).to have_no_selector("tr[data-id=\"#{external_moderation.id}\"]")53 end54 it "user can review them" do55 moderations.each do |moderation|56 within "tr[data-id=\"#{moderation.id}\"]" do57 expect(page).to have_css("a[href='#{moderation.reportable.reported_content_url}']")58 expect(page).to have_content "Spam"59 end60 end61 end62 it "user can un-report a resource" do63 within "tr[data-id=\"#{moderation.id}\"]" do64 click_link "Unreport"65 end66 expect(page).to have_admin_callout("Resource successfully unreported")67 end68 it "user can hide a resource" do69 within "tr[data-id=\"#{moderation.id}\"]" do70 click_link "Hide"71 end72 expect(page).to have_admin_callout("Resource successfully hidden")73 expect(page).to have_no_content(moderation.reportable.reported_content_url)74 end75 it "user can sort by report count" do76 moderations.each_with_index { |moderation, index| moderation.update(report_count: index + 1) }77 moderations_ordered_by_report_count_asc = moderations.sort_by(&:report_count)78 within "table" do79 click_link "Count"80 all("tbody tr").each_with_index do |row, index|81 reportable_id = moderations_ordered_by_report_count_asc[index].reportable.id82 expect(row.find("td:first-child")).to have_content(reportable_id)83 end84 end85 end86 it "user can filter by reportable type" do87 reportable_type = moderation.reportable.class.name.demodulize88 within ".filters__section" do89 find(:xpath, "//a[contains(text(), 'Filter')]").hover90 find(:xpath, "//a[contains(text(), 'Type')]").hover91 click_link reportable_type92 end93 expect(page).to have_selector("tbody tr", count: moderations.length)94 end95 it "user can filter by reported content" do96 search = moderation.reportable.id97 within ".filters__section" do98 fill_in("Search Moderation by reportable id or content.", with: search)99 find(:xpath, "//button[@type='submit']").click100 end101 expect(page).to have_selector("tbody tr", count: 1)102 end103 it "user can see moderation details" do104 within "tr[data-id=\"#{moderation.id}\"]" do105 click_link "Expand"106 end107 reported_content_slice = moderation.reportable.reported_searchable_content_text.split("\n").first108 expect(page).to have_content(reported_content_slice)109 end110 context "when the reported content does not exist" do111 it "still renders the page" do112 moderation.reportable.destroy113 visit current_path114 expect(page).to have_no_selector("tr[data-id=\"#{moderation.id}\"]")115 end116 end117 end118 context "when listing hidden resources" do119 it "user can review them" do120 within ".card-title" do121 click_link "Hidden"122 end123 hidden_moderations.each do |moderation|124 within "tr[data-id=\"#{moderation.id}\"]" do125 expect(page).to have_css("a[href='#{moderation.reportable.reported_content_url}']")126 end127 end128 end129 end130end...

Full Screen

Full Screen

reportable.rb

Source:reportable.rb Github

copy

Full Screen

...4 describe ".results_enabled" do5 it "includes records with results enabled" do6 reportable.update!(results_enabled: true)7 expect(described_class.results_enabled).to eq [reportable]8 end9 it "does not include records without results enabled" do10 reportable.update!(results_enabled: false)11 expect(described_class.results_enabled).to be_empty12 end13 end14 describe ".stats_enabled" do15 it "includes records with stats enabled" do16 reportable.update!(stats_enabled: true)17 expect(described_class.stats_enabled).to eq [reportable]18 end19 it "does not include records without stats enabled" do20 reportable.update!(stats_enabled: false)21 expect(described_class.stats_enabled).to be_empty22 end23 end24 end25 describe "#results_enabled" do26 it "can write and read the attribute" do27 reportable.results_enabled = true28 expect(reportable.results_enabled?).to be true29 expect(reportable.results_enabled).to be true30 reportable.results_enabled = false31 expect(reportable.results_enabled?).to be false32 expect(reportable.results_enabled).to be false33 end34 it "can save the value to the database" do35 reportable.update!(results_enabled: true)36 saved_reportable = described_class.last37 expect(saved_reportable.results_enabled?).to be true38 expect(saved_reportable.results_enabled).to be true39 reportable.update!(results_enabled: false)40 saved_reportable = described_class.last41 expect(saved_reportable.results_enabled?).to be false42 expect(saved_reportable.results_enabled).to be false43 end44 it "uses the `has_one` relation instead of the original column" do45 skip "there's no original column" unless reportable.has_attribute?(:results_enabled)46 reportable.update!(results_enabled: true)47 expect(reportable.read_attribute(:results_enabled)).to be false48 end49 end50 describe "#stats_enabled" do51 it "can write and read the attribute" do52 reportable.stats_enabled = true53 expect(reportable.stats_enabled?).to be true54 expect(reportable.stats_enabled).to be true55 reportable.stats_enabled = false56 expect(reportable.stats_enabled?).to be false57 expect(reportable.stats_enabled).to be false58 end59 it "can save the attribute to the database" do60 reportable.update!(stats_enabled: true)61 saved_reportable = described_class.last62 expect(saved_reportable.stats_enabled?).to be true63 expect(saved_reportable.stats_enabled).to be true64 reportable.update!(stats_enabled: false)65 saved_reportable = described_class.last66 expect(saved_reportable.stats_enabled?).to be false67 expect(saved_reportable.stats_enabled).to be false68 end69 it "uses the `has_one` relation instead of the original column" do70 skip "there's no original column" unless reportable.has_attribute?(:stats_enabled)71 reportable.update!(stats_enabled: true)72 expect(reportable.read_attribute(:stats_enabled)).to be false73 end74 end75end...

Full Screen

Full Screen

reports_helper_spec.rb

Source:reports_helper_spec.rb Github

copy

Full Screen

...8 subject do9 Nokogiri::HTML(10 helper.reportable_author_name(reportable)11 )12 end13 before do14 allow(helper).to receive(:current_or_new_conversation_path_with).and_return("/conversations/1")15 end16 context "with different reportable authors types" do17 describe "when it's a dummy resource author " do18 let(:reportable) { create(:dummy_resource, title: { "en" => "<p>Dummy<br> Title</p>" }) }19 it "returns the author's name" do20 expect(helper.reportable_author_name(reportable)).to include("reportable-authors")21 expect(helper.reportable_author_name(reportable)).to include(reportable.author.name)22 end23 end24 describe "when it's a user author" do25 let!(:proposal) { create(:proposal) }26 let(:reportable) { proposal }27 it "returns the user's name" do28 expect(helper.reportable_author_name(reportable)).to include("reportable-authors")29 expect(helper.reportable_author_name(reportable)).to include(reportable.authors.first.name)30 end31 end32 describe "when it's a meeting author" do33 let!(:proposal) { create(:proposal, :official_meeting) }34 let(:reportable) { proposal }35 it "returns the meeting's title" do36 expect(helper.reportable_author_name(reportable)).to include("reportable-authors")37 expect(helper.reportable_author_name(reportable)).to include(translated_attribute(reportable.authors.first.title))38 end39 end40 end41 end42 end43 end44end...

Full Screen

Full Screen

end

Using AI Code Generation

copy

Full Screen

1product.end("sold")2 def end(status)3product.end("sold")4 def end(status)

Full Screen

Full Screen

end

Using AI Code Generation

copy

Full Screen

1 def initialize(name, balance=100)2 def transfer_to(another, amount)3acct1 = Account.new("Joe's account", 1000)4acct2 = Account.new("Jane's account", 500)5acct1.transfer_to(acct2, 50)6 def initialize(name, balance=100)7 def transfer_to(another, amount)8acct1 = Account.new("Joe's account", 1000)9acct2 = Account.new("Jane's account", 500)10acct1.transfer_to(acct2, 50)11 def initialize(name, balance=100)12 def transfer_to(another, amount)13acct1 = Account.new("Joe's account", 1000)14acct2 = Account.new("Jane's account", 500)15acct1.transfer_to(acct2, 50)

Full Screen

Full Screen

end

Using AI Code Generation

copy

Full Screen

1 output_line(@title)2 output_line(line)3 def output_line(line)4 def output_line(line)

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Minitest_ruby automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful