45 lines
1.6 KiB
Ruby
45 lines
1.6 KiB
Ruby
require 'test_helper'
|
|
|
|
class BrowserBrowseTest < ActionDispatch::IntegrationTest
|
|
test "upload broken screenshot anonymously" do
|
|
visit package_path(name: 'firefox')
|
|
click_on 'Upload a screenshot'
|
|
attach_file 'file[]', Rails.root.join('test/fixtures/files/large-broken.png')
|
|
click_on 'Start upload'
|
|
page.must_have_content 'The image large-broken.png is not valid'
|
|
end
|
|
|
|
test "upload png screenshot anonymously" do
|
|
visit package_path(name: 'firefox')
|
|
click_on 'Upload a screenshot'
|
|
img_count_before = page.find_all('img').count
|
|
attach_file 'file[]', Rails.root.join('test/fixtures/files/large1.png')
|
|
click_on 'Start upload'
|
|
img_count_after = page.find_all('img').count
|
|
assert_equal img_count_after, img_count_before + 1
|
|
|
|
# Screenshot must be moderated
|
|
newest_screenshot = Package.find_by_name(:firefox).screenshots.order(id: :desc).first
|
|
assert_equal newest_screenshot.approved, false
|
|
|
|
# Clean up
|
|
newest_screenshot.destroy
|
|
end
|
|
|
|
test "upload screenshot as logged-in user" do
|
|
sign_in users(:normal)
|
|
visit upload_path(name: 'firefox')
|
|
img_count_before = page.find_all('img').count
|
|
attach_file 'file[]', Rails.root.join('test/fixtures/files/large1.png')
|
|
click_on 'Start upload'
|
|
img_count_after = page.find_all('img').count
|
|
assert_equal img_count_after, img_count_before + 1
|
|
|
|
# Screenshot is instantly public
|
|
newest_screenshot = Package.find_by_name(:firefox).screenshots.order(id: :desc).first
|
|
assert_equal newest_screenshot.approved, true
|
|
|
|
# Clean up
|
|
newest_screenshot.destroy
|
|
end
|
|
end
|