spec: admin_avatars

tested:
       * submitted avatar
       * reported avatar
       * approved avatar
       * lock avatar
       * unlock avatar
       * delete avatar

Change-Id: I15014d52a6fb021acc71c64f101b939e611ccb8b
Reviewed-on: https://gerrit.instructure.com/10770
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jake Sorce <jake@instructure.com>
This commit is contained in:
Efrain Chu-Jon 2012-05-14 12:50:37 -06:00 committed by Jake Sorce
parent 48d9b3df64
commit 08e0f600ab
2 changed files with 108 additions and 4 deletions

View File

@ -38,10 +38,10 @@
<h2><%= t(:title, "Profile Pictures") %></h2>
<div class="views">
<span style="padding-right: 10px; font-weight: bold;"><%= before_label :show, 'Show' %> </span>
<a href="?avatar_state=submitted" class="<%= 'selected' if @avatar_state == 'submitted' %>"><%= t(:submitted_link, { :zero => "Submitted", :one => "Submitted %{count}", :other => "Submitted %{count}" }, :count => @avatar_counts[:submitted] || 0) %></a> |
<a href="?avatar_state=reported" class="<%= 'selected' if @avatar_state == 'reported' %>"><%= t(:reported_link, { :zero => "Reported", :one => "Reported %{count}", :other => "Reported %{count}" }, :count => @avatar_counts[:reported] || 0) %></a> |
<a href="?avatar_state=re_reported" class="<%= 'selected' if @avatar_state == 're_reported' %>"><%= t(:re_reported_link, { :zero => "Approved, Re-Reported", :one => "Approved, Re-Reported %{count}", :other => "Approved, Re-Reported %{count}"}, :count => @avatar_counts[:re_reported] || 0) %></a> |
<a href="?avatar_state=any" class="<%= 'selected' if @avatar_state == 'any' %>"><%= t(:all_link, { :zero => "All", :one => "All %{count}", :other => "All %{count}" }, :count => @avatar_counts[:all] || 0) %></a>
<a href="?avatar_state=submitted" id="submitted_profile" class="<%= 'selected' if @avatar_state == 'submitted' %>"><%= t(:submitted_link, { :zero => "Submitted", :one => "Submitted %{count}", :other => "Submitted %{count}" }, :count => @avatar_counts[:submitted] || 0) %></a> |
<a href="?avatar_state=reported" id="reported_profile"class="<%= 'selected' if @avatar_state == 'reported' %>"><%= t(:reported_link, { :zero => "Reported", :one => "Reported %{count}", :other => "Reported %{count}" }, :count => @avatar_counts[:reported] || 0) %></a> |
<a href="?avatar_state=re_reported" id="re_reported_profile" class="<%= 'selected' if @avatar_state == 're_reported' %>"><%= t(:re_reported_link, { :zero => "Approved, Re-Reported", :one => "Approved, Re-Reported %{count}", :other => "Approved, Re-Reported %{count}"}, :count => @avatar_counts[:re_reported] || 0) %></a> |
<a href="?avatar_state=any" id="any_profile" class="<%= 'selected' if @avatar_state == 'any' %>"><%= t(:all_link, { :zero => "All", :one => "All %{count}", :other => "All %{count}" }, :count => @avatar_counts[:all] || 0) %></a>
</div>
<% if @users.empty? %>

View File

@ -0,0 +1,104 @@
require File.expand_path(File.dirname(__FILE__) + '/common')
describe "admin avatars" do
it_should_behave_like "in-process server selenium tests"
before (:each) do
course_with_admin_logged_in
Account.default.enable_service(:avatars)
Account.default.settings[:avatars] = 'enabled_pending'
Account.default.save!
end
def create_avatar_state(avatar_state="submitted", avatar_image_url="http://www.example.com")
user = User.last
user.avatar_image_url = avatar_image_url
user.save!
user.avatar_state = avatar_state
user.save!
get "/accounts/#{Account.default.id}/avatars"
user
end
def verify_avatar_state(user, opts={})
if (opts.empty?)
f("#submitted_profile").should include_text "Submitted 1"
f("#submitted_profile").click
else
f(opts.keys[0]).should include_text(opts.values[0])
f(opts.keys[0]).click
end
f("#avatars .name").should include_text user.name
f(".avatar img").attribute('src').should_not be_nil
end
def lock_avatar(user, element)
element.click
f(".links .lock_avatar_link").click
driver.switch_to.alert.accept
wait_for_ajax_requests
f(".links .unlock_avatar_link").should be_displayed
user.reload
user.avatar_state.should eql :locked
user
end
it "should verify that the profile pictures is submitted " do
user = create_avatar_state
verify_avatar_state(user)
end
it "should verify that the profile pictures is reported " do
user = create_avatar_state("reported")
opts = {"#reported_profile" => "Reported 1"}
verify_avatar_state(user, opts)
end
it "should verify that the profile picture is approved, re-reported " do
user = create_avatar_state("re_reported")
opts = {"#re_reported_profile" => "Re-Reported 1"}
verify_avatar_state(user, opts)
end
it "should verify that all profile pictures are displayed " do
user = create_avatar_state
opts = {"#any_profile" => "All 1"}
verify_avatar_state(user, opts)
end
it "should lock the avatar state " do
user = create_avatar_state
lock_avatar(user, f("#any_profile"))
end
it "should unlock the avatar state " do
user = create_avatar_state
user = lock_avatar(user, f("#any_profile"))
f(".links .unlock_avatar_link").click
wait_for_ajax_requests
user.reload
user.avatar_state.should eql :approved
f(".links .lock_avatar_link").should be_displayed
end
it "should approve un-approved avatar" do
user = create_avatar_state
user.avatar_state.should eql :submitted
f(".links .approve_avatar_link").click
wait_for_ajax_requests
user.reload
user.avatar_state.should eql :approved
f(".links .approve_avatar_link").should_not be_displayed
end
it "should delete the avatar" do
user = create_avatar_state
f("#any_profile").click
f(".links .reject_avatar_link").click
driver.switch_to.alert.accept
wait_for_ajax_requests
user.reload
user.avatar_state.should eql :none
user.avatar_image_url.should be_nil
end
end