Skip to content

Commit

Permalink
Merge pull request #652 from psu-stewardship/access_stats
Browse files Browse the repository at this point in the history
Changing so stats on public files can be viewed without logging in
  • Loading branch information
jcoyne committed Aug 21, 2014
2 parents 56ae9d2 + 3831765 commit 8379dce
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module FilesControllerBehavior

# actions: audit, index, create, new, edit, show, update,
# destroy, permissions, citation, stats
before_filter :authenticate_user!, except: [:show, :citation]
before_filter :authenticate_user!, except: [:show, :citation, :stats]
before_filter :has_access?, except: [:show]
before_filter :build_breadcrumbs, only: [:show, :edit, :stats]
prepend_before_filter :normalize_identifier, except: [:index, :create, :new]
Expand Down
15 changes: 14 additions & 1 deletion spec/controllers/generic_files_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,6 @@

context 'when user has access to file' do
before do
sign_in @user
mock_query = double('query')
allow(mock_query).to receive(:for_path).and_return([
OpenStruct.new(date: '2014-01-01', pageviews: 4),
Expand All @@ -308,6 +307,20 @@
expect(response).to be_success
expect(response).to render_template(:stats)
end

context "user is not signed in but the file is public" do
before do
sign_out @user
@generic_file.read_groups = ['public']
@generic_file.save
end

it 'renders the stats view' do
get :stats, id: @generic_file.noid
expect(response).to be_success
expect(response).to render_template(:stats)
end
end
end

context 'when user lacks access to file' do
Expand Down

0 comments on commit 8379dce

Please sign in to comment.