Sha256: 6007db5fefba21d7ee57e09cc983b136f8302ea7ded47c3caf52d9c62fd91a95
Contents?: true
Size: 1.72 KB
Versions: 3
Compression:
Stored size: 1.72 KB
Contents
require 'spec_helper' describe AuditRails::AuditsController do # Need to push this to spec/routing directory context 'routes' do it { expect(:get => "/audits").to route_to( :controller => "audit_rails/audits", :action => "index" ) } it { expect(:post => "/audits").to route_to( :controller => "audit_rails/audits", :action => "create" ) } it { expect(:get => "/audits/analytics").to route_to( :controller => "audit_rails/audits", :action => 'analytics' ) } end context "GET index" do it "lists audits on page" do audits = (1..3).map {|t| AuditRails::Audit.create(user_name: 'Fake User', description: "User logged on at #{t.days.ago}", action: 'login', controller: 'sessions')} get 'index' expect(assigns(:audits)).to eq(audits) end it "lists audits in excel" do audits = (1..3).map {|t| AuditRails::Audit.create(user_name: 'Fake User', description: "User logged on at #{t.days.ago}", action: 'login', controller: 'sessions')} get 'index', format: 'xls' response.should be_success expect(assigns(:audits)).to eq(audits) end end context 'POST audit' do it 'should post an audit' do post 'create' response.should be_success AuditRails::Audit.no_audit_entry_for_today?("visit-site", 'Fake User').should be_false end end context "GET analytics" do it "shows analytics of audits on page" do # list should be a hash AuditRails::Audit.stub(:analysis_by_user_name).and_return(list = {"Fake User"=>6, "John Smith"=>3}) get 'analytics' expect(assigns(:analysis_by_user_name)).to eq(list) end end end
Version data entries
3 entries across 3 versions & 1 rubygems