<commit_before>require 'spec_helper'

describe "Issue" do
  context "as_admin_user" do
    before do
      user = create(:admin_user, :email => "<EMAIL>")
      sign_in_as!(user)      
    end

    before do      
      visit spree.admin_path
    end

    context "accessing product issues" do
      context "unsuscribable products" do
        it "should not have issue tab" do
          create(:simple_product)
          click_link "Products"
          within('table.index tr:nth-child(2)') { click_link "Edit" }
          page.should_not have_content("Issues")
        end
      end

      context "subscribable products" do
        before(:each) do
          @magazine = create(:simple_product, :subscribable => true).master
          click_link "Products"
          within('table.index tr:nth-child(2)') { click_link "Edit" }
        end

        it "should have issue tab" do
          page.should have_content("Issues")
        end

        it "should let view product issues" do
          issue = create(:issue, :magazine => @magazine)
          other_issue = create(:issue)
          click_link "Issues"
          page.should have_content("Listing Issues")
          page.should have_content(issue.name)
          page.should_not have_content(other_issue.name)
        end
      end
    end

    context "managing an issue" do
      before do
        @magazine = create(:simple_product, :subscribable => true).master
        click_link "Products"
        within('table.index tr:nth-child(2)') { click_link "Edit" }
      end

      context "creating an issue" do
        it "should let access the new issue page" do
          click_link "Issues"
          click_link "New Issue"
        end

        it "should create a new issue" do
          click_link "Issue"
          click_link "New Issue"
          fill_in "Name", :with => "Magazine issue number 4"
          click_button "Create"
          within('table.index#listing_issues tbody') { page.should have_content "Magazine issue number 4" }
        end
      end

      context "editing a product issue" do
        before do        
          @issue = create(:issue, :magazine => @magazine)
          click_link "Issues"
        end

        it "shoud let access the edit issue page" do
          within('table.index#listing_issues tbody tr:nth-child(1)') { click_link "Edit" }        
          find_field("issue_name").value.should == @issue.name
        end

        it "should let update an issue" do
          within('table.index#listing_issues tbody tr:nth-child(1)') { click_link "Edit" }
          fill_in "Name", :with => "Magazine issue number 4"
          click_button "Update"
          page.should have_content "issue_updated"
          page.should have_content "Magazine issue number 4"
        end<commit_msg>fixes typo<commit_after>require 'spec_helper'

describe "Issue" do
  context "as_admin_user" do
    before do
      user = create(:admin_user, :email => "<EMAIL>")
      sign_in_as!(user)      
    end

    before do      
      visit spree.admin_path
    end

    context "accessing product issues" do
      context "unsuscribable products" do
        it "should not have issue tab" do
          create(:simple_product)
          click_link "Products"
          within('table.index tr:nth-child(2)') { click_link "Edit" }
          page.should_not have_content("Issues")
        end
      end

      context "subscribable products" do
        before(:each) do
          @magazine = create(:simple_product, :subscribable => true).master
          click_link "Products"
          within('table.index tr:nth-child(2)') { click_link "Edit" }
        end

        it "should have issue tab" do
          page.should have_content("Issues")
        end

        it "should let view product issues" do
          issue = create(:issue, :magazine => @magazine)
          other_issue = create(:issue)
          click_link "Issues"
          page.should have_content("Listing Issues")
          page.should have_content(issue.name)
          page.should_not have_content(other_issue.name)
        end
      end
    end

    context "managing an issue" do
      before do
        @magazine = create(:simple_product, :subscribable => true).master
        click_link "Products"
        within('table.index tr:nth-child(2)') { click_link "Edit" }
      end

      context "creating an issue" do
        it "should let access the new issue page" do
          click_link "Issues"
          click_link "New Issue"
        end

        it "should create a new issue" do
          click_link "Issues"
          click_link "New Issue"
          fill_in "Name", :with => "Magazine issue number 4"
          click_button "Create"
          within('table.index#listing_issues tbody') { page.should have_content "Magazine issue number 4" }          
        end
      end

      context "editing a product issue" do
        before do        
          @issue = create(:issue, :magazine => @magazine)
          click_link "Issues"
        end

        it "shoud let access the edit issue page" do
          within('table.index#listing_issues tbody tr:nth-child(1)') { click_link "Edit" }        
          find_field("issue_name").value.should == @issue.name
        end

        it "should let update an issue" do
          within('table.index#listing_issues tbody tr:nth-child(1)') { click_link "Edit" }
          fill_in "Name", :with => "Magazine issue number 4"
          click_button "Update"
          page.should have_content "issue_updated"
          page.should have_content "Magazine issue number 4"
        end
{'fraction_non_alphanumeric': 0.0913323782234957, 'fraction_numerical': 0.0032234957020057307, 'mean_word_length': 2.1062291434927696, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7201817', 'n_tokens_mistral': 1629, 'n_tokens_neox': 1581, 'n_words': 462}