First Draft in One Weekend – Part 10!
Here we go again! I am now only 4 days out from the 2018 (MNM) Muskoka Novel Marathon (<<<—VISIT the link to learn all about the marathon!)(It begins at 8pm on Friday July 13th, 2018 and runs for 72 hours straight. Sleeping is an option, but not mandatory.)! I love this event so much. The camaraderie of my fellow writers, the fact that we raise so much money every year for literacy programs, the fact that I get so much writing done in 72 hours, the fact that the venue is nestled inside one of the most beautiful towns in our fair country. So many reasons for me to love the Muskoka Novel Marathon.
This time next week, I will be wrapping up my novel writing marathon weekend. I'll be exhausted, struggling to get to the end of the last day, looking forward to getting home and shocked that it will all soon be over for another year.
When one is a writer on the side, one appreciates downtime from life in order to JUST WRITE. It's such a miraculous thing to just spirit yourself away and write. I am sitting here with all these ideas in my head, wondering if any of them are going to land long enough for me to hit the ground running come Friday. Or maybe, like with some of my marathons, I won't hit on the right idea until the starting bell goes off at Friday at 8pm. Or, like my last marathon in 2016…I'll hit on the idea that catches and becomes something some twenty-four hours into the marathon. I never know until I sit down. That's the fear, that's the excitement, that's the thrill.
I've lost track of how many marathons there have been so far. I know only that every year I miss the marathon I regret it for the rest of the year and promise myself I will never miss another. Last year, which I missed, they raised $33,264. Over the course of the Marathon's life, we have raised over $170,000.00 for the programs. Imagine that hole, had the marathon not been around to fill it! It's staggering. So, yes, again…THANK YOU.
Now is when my focus begins to swing from collecting pledges to WHAT AM I GOING TO WRITE? I CAN'T WAIT TO SEE MY MARATHON BROTHERS & SISTERS! I MUST BE CRAZY?! THANK GOODNESS FOR THE VOLUNTEERS WHO MAKE SURE WE ALWAYS HAVE MEALS TO EAT AND COFFEE TO DRINK AND ENSURE THAT ALL WE HAVE TO DO FOR THE ENTIRE WEEKEND IS WRITE!! THANK GOODNESS FOR THE BADDIES WHO ALLOW THEMSELVES AN HOUR OR TWO TO ESCAPE AND WALK DOWNTOWN FOR SOME DOWN TIME AND SOCIALIZING AND WRITERLY TALK! It's just all so crucial and important and lovely and irrelevant and necessary to who I am as a writer.
When I first attempted the Muskoka Novel Marathon I was almost crying going in, I was that scared. How is this thing EVEN POSSIBLE! During that marathon in 2007 I wrote SEBASTIAN'S POET in 48hrs (I chose the 48hr option that year over the 72hr option because I couldn't imagine pulling off the whole thing!) You know, I listened to Leonard Cohen's ANTHEM on repeat for that entire novel. I had transcended space and time while writing Sebastian's story, had modeled the 'poet'–who is actually a folksinger–after Cohen himself. I went to a place far away in my head and the story revealed itself like stars in a night sky. What I thought would be a struggle became a struggle after-all. Although I believed the struggle would be in finding something to write about, the actual struggle became making my fingers move as fast as my mind was delivering the story to me. I WAS HOOKED. It turns out the best way I write novels is in one sitting.
And THAT is why I am SO SUPER EXCITED FOR FRIDAY TO COME! Here I go again. My 10th MUSKOKA NOVEL MARATHON!!! Wish me luck, wish the fundraising efforts luck, wish the newbie marathoners luck…at 8pm on Friday night a bell will toll. We will not ask for whom it tolls…it will toll for 40 of the luckiest writers in the world. We are lucky because we have each other, we have time, we have place, we have words, and we have coffee. Let the wording begin!


text:
Andreas H. Jucker has written 15 work(s)
Search for other authors with the same name
displaying 1 to 15 | at end
show results in order: alphabetically | oldest to newest | newest to oldest
Pragmatics of Fiction
Product Description: This volume provides state-of-the-art accounts of a broad range of pragmatic research on fictional language, covering not only written genres, but also drama and telecinematic discourse. It is concerned with the ways in which communication is depicted or enacted in fiction and with the larger communicative context of the texts...read more
By Andreas H. Jucker (editor)
See complete details on each edition (1 edition listed)
Hardcover:
9783110439700 | Mouton De Gruyter, May 15, 2018, cover price $349.00 | About this edition: This volume provides state-of-the-art accounts of a broad range of pragmatic research on fictional language, covering not only written genres, but also drama and telecinematic discourse.
Communicating Early English Manuscripts
In an obvious way, manuscripts communicate. This is the first book to focus on the communicative aspects of English manuscripts from the fourteenth to the nineteenth century. It investigates how the authors and scribes of these manuscripts communicated with their audiences, how the characters depicted in these manuscripts communicate with each other, and how the manuscripts communicate with scholars and audiences in the 21st century. It covers a wide variety of genres, such as stories, scientific writing, witchcraft records, personal letters, war correspondence, courtroom records, and plays. The volume demonstrates how these handwritten texts can be used to analyse the history of language as communication between individuals and groups, and discusses the challenges these documents present to present-day scholars. It is unique in bringing together studies by distinguished international experts examining primary handwritten sources from the perspectives of several fields, including historical pragmatics, historical sociolinguistics, corpus linguistics and literary scholarship.
See complete details on each edition (2 editions listed)
9780521193290 | Cambridge Univ Pr, March 7, 2011, cover price $116.00 | About this edition: In an obvious way, manuscripts communicate.
9781107646506 | Cambridge Univ Pr, January 29, 2015, cover price $34.99
Communities of Practice in the History of English
9789027256409 | John Benjamins Pub Co, October 15, 2013, cover price $143.00
Early Modern English News Discourse: Newspapers, Pamphlets and Scientific News Discourse
9789027254320 | John Benjamins Pub Co, May 15, 2009, cover price $143.00
Diachronic Perspectives on Address Term Systems
Product Description: Address term systems and their diachronic developments are discussed in a wide range of European languages in this volume. Most chapters focus on pronominal systems, and in particular on the criteria that govern the choices between a more intimate and a more distant or polite pronoun, as for instance thou and you in Early Modern English, vos and vuestra merced in sixteenth century Spanish or du and Sie in Modern German...read more
By Andreas H. Jucker (editor) and Irma Taavitsainen (editor)
9789027253484 | John Benjamins Pub Co, June 23, 2003, cover price $195.00 | About this edition: Address term systems and their diachronic developments are discussed in a wide range of European languages in this volume.
9781588113108 | John Benjamins Pub Co, June 1, 2003, cover price $195.00 | About this edition: Address term systems and their diachronic developments are discussed in a wide range of European languages in this volume.
Kommunikationsformen Im Wandel Der Zeit: Vom Mittelalterlichen Heldenepos Zum Elektronischen Hypertext
Product Description: Der Band ist ein Beitrag zur Geschichte von Kommunikationsformen, einem neueren Zweig der historischen Pragmatik. Die Autoren sind Germanisten, Anglisten, Romanisten, Didaktiker und Psychologen. Mit Schwerpunkten in drei historischen Perioden (Mittelalter, 17...read more
9783484750210 | Reprint edition (Walter De Gruyter Inc, May 16, 2000), cover price $196.00 | About this edition: Der Band ist ein Beitrag zur Geschichte von Kommunikationsformen, einem neueren Zweig der historischen Pragmatik.
Historical Dialogue Analysis
Historical dialogue analysis is a new branch of historical pragmatics. The papers of this interdisciplinary volume contribute to charting the developing field by presenting a survey of recent research from the different traditions of English, German and Romance language studies. Both the introductory paper by the editors and the individual papers deal with fundamental theoretical questions, e.g. the question of types of historical developments in dialogue forms, and methodological problems, e.g. the finding and interpretation of relevant data. The fifteen case studies presented in this volume provide a wide range of new data. The range of topics includes the pragmatic form of 16th century religious controversies in Germany, forms of polite answers in Early Modern German conversation culture, forms of dialogue in Early Modern English medical writing, learning English through dialogues in the 16th century, structures of bargaining dialogues in Late Medieval French, and reflections of spontaneous dialogue in Early Romance texts. (view table of contents)
By Gerd Fritz (editor), Andreas H. Jucker (editor) and Franz Lebsanft (editor)
9781556199448 | John Benjamins Pub Co, August 1, 1999, cover price $195.00
9789027250803 | John Benjamins Pub Co, July 15, 1999, cover price $195.00 | About this edition: Historical dialogue analysis is a new branch of historical pragmatics.
Discourse Markers
Product Description: Studies of Discourse Markers so far have concentrated on either the descriptive or the theoretical parameter. This book brings together thirteen papers concerning aspects of lexical instantiations of Discourse Marking devices, ranging from functional descriptions along cognitive, attitudinal, interactive and structure signalling lines to theoretical issues arising from various properties discourse markers display cross-linguistically...read more
By Andreas H. Jucker (editor) and Yael Ziv (editor)
9789027250711 | John Benjamins Pub Co, July 30, 1998, cover price $162.00 | About this edition: Studies of Discourse Markers so far have concentrated on either the descriptive or the theoretical parameter.
Current Issues in Relevance Theory
Product Description: The eleven original papers collected in this volume address themselves to some of the central issues in the relevance theoretic research programme since the 1995 publication of the second edition of Sperber and Wilson's Relevance...read more
By Andreas H. Jucker (editor) and Villy Rouchota (editor)
9789027250728 | John Benjamins Pub Co, June 15, 1998, cover price $180.00 | About this edition: The eleven original papers collected in this volume address themselves to some of the central issues in the relevance theoretic research programme since the 1995 publication of the second edition of Sperber and Wilson's Relevance.
9781556198212 | John Benjamins Pub Co, May 1, 1998, cover price $180.00
Discourse Markers: Descriptions and Theory
(view table of contents)
By International Pragmatics Conference 1996 (other contributor), Andreas H. Jucker (editor) and Yael Ziv (editor)
Historical Pragmatics
9789027250476 | John Benjamins Pub Co, December 1, 1995, cover price $176.00
Historical Pragmatics: Pragmatic Developments in the History of English
Product Description: Until very recently, pragmatics has been restricted to the analysis of contemporary spoken language while historical linguistics has studied historical texts and language change in a decontextualized way. This has now radically changed and scholars from around the world are trying to build a new theoretical framework that integrates recent advances both in pragmatics and in historical linguistics...read more
9781556193286 | John Benjamins Pub Co, October 1, 1995, cover price $195.00 | About this edition: Until very recently, pragmatics has been restricted to the analysis of contemporary spoken language while historical linguistics has studied historical texts and language change in a decontextualized way.
The Noun Phrase in English: Its Structure and Variability
9783825301712 | Bilingual edition (Isd, January 4, 1994), cover price $20.00
Social Stylistics: Syntactic Variation in British Newspapers
By Andreas H. Jucker
9783110129694 | Mouton De Gruyter, June 1, 1992, cover price $182.00
News Interviews: A Pragmalinguistic Analysis
9789027225542 | John Benjamins Pub Co, January 1, 1986, cover price $113.00

redpajama_set_name: RedPajamaCommonCrawl


text:
Meet Nancy
Nancy was born in Long Island, New York in 1956, and moved with her family to Bethesda, Md at six months. She attended Walt Whitman High School, where she founded and led the Environmental Club. She also contributed to a secondary school textbook for hands-on environmental education, and learned the basics of water quality, microbiology, ecology, air quality, soil health, and land use regulation. She also organized a national conference of the Institute for Environmental Education at Catoctin National Park. She received the Environmental Award of Excellence from the President for "outstanding achievement in environmental services" in high school.
Nancy holds a bachelor's degree in political science from Yale University. She also studied physics, engineering, and programming. She co-founded the Women's Caucus. She attended the University of Virginia law school for one year, then decided to work in environmental policy.
After law school, Nancy traveled for nine months throughout Western Europe. In north Norway, she participated in a civil disobedience occupation of an illegal hydroelectric construction site with the native Laplanders, camping out in -20 degrees F to protect reindeer migration paths.
Nancy worked for 14 years lobbying Capitol Hill on international environmental issues focused on endangered species and family planning. She obtained a two thirds majority Senate commitment to continue US support for the world whaling moratorium, on behalf of Monitor International. Representing the International Fund for Animal Welfare, she mobilized Senate support to stop the clubbing of harp and hooded seals in Canada. Nancy also created and led a five-year national coalition which stopped US clubbing of northern Pacific fur seals in the Pribilof Islands, a threatened species, winning against the State Department, Department of Commerce, White House, and the Canadian government which wanted to continue the clubbing. She served as advisor to United States Departments of State and Commerce delegation at the Tokyo Meeting of the Parties of the North Pacific Fur Seal Treaty in 1985 as the environmental representative.
Nancy founded and led the International Entanglement Network from 1983-85. She created the national legislative strategy; testified at hearings representing the national environmental community; obtained new $1 million line item appropriation in the federal budget, including first international scientific conference. This organization eventually led to the banning of disposal of plastic debris in the oceans under the MARPOL treaty.
Nancy served as the Sierra Club's Washington Director, International Population Program, from 1990-94. The Program's goal was to urge Congress and the White House to provide the full US portion of the UN's international campaign for reproductive health care for women in developing countries. Under her leadership, the campaign achieved the largest non-military increases in international aid programs in US history four years in a row, over half billion dollars in total, for voluntary family planning programs. Nancy created and managed the new program, including political strategy, Congressional and United Nations lobbying, testimony before House and Senate committees, media events (national press conferences, radio, TV), grassroots network, and lobbying the Office of Management and Budget (OMB).
Nancy was a co-founder of Sustainable Montgomery, with Blair Ewing when he served on Montgomery County Council.
In 1994, Nancy joined Electronic Data Systems (EDS), and later Computer Sciences Corporation (CSC), supporting the Immigration and Naturalization Service software systems for 14 years. Nancy moved on to support the Department of Treasury in Enterprise Content Management, performing the 2008 Independent Verification and Validation of Treasury's Enterprise Architecture Self-Assessment. Nancy then worked at DoD for five years, supporting the integration of Item Unique Identification methodology into the enterprise architecture of the Department of Navy and the Marine Corps.
Nancy Wallace currently supports the Department of Commerce as a data coordinator for ecological restoration projects. She is also a process engineer and certified in Capability Maturity Model Integrated (CMMI).
Nancy joined the Green Party in 2003, and began active participation in the Montgomery County group in 2013. She has served as co-chair since February 2015. She has been active in campaigns to save 10 Mile Creek, ban dangerous pesticides in ornamental lawn care, and improve building efficiency standards in the county.
Nancy serves currently on the Board of Directors of the Center for Safer Wireless, a nonprofit mothers' group educating families and school systems on safer use of wireless technology.
Nancy's house is 100% wind powered, through the Maryland wind recs program now available through our local electricity generating companies. She is also a member of the Silver Spring Time Bank. She uses natural, organic lawncare with native plants and permaculture on her small amount of land at her house.
She is a volunteer advocate on Vitamin D, bringing modern men's contraception to market, and zero waste recycling.
She has been a mentor for at risk children for 21 years, and has three mentor children, and two mentor grandchildren.
"Then in times of need, one should rise to the occasion & fight bravely for what is right.....it is not enough to be compassionate, one must act."
-- Dalai Lama
© 2020 Nancy Wallace For Congress | This website powered by solar energy through AISO | Website by Teammedia | 🍁


text:
require 'spec_helper'

describe Spree::Promotion, :type => :model do
  let(:promotion) { Spree::Promotion.new }

  describe "validations" do
    before :each do
      @valid_promotion = Spree::Promotion.new :name => "A promotion"
    end

    it "valid_promotion is valid" do
      expect(@valid_promotion).to be_valid
    end

    it "validates usage limit" do
      @valid_promotion.usage_limit = -1
      expect(@valid_promotion).not_to be_valid

      @valid_promotion.usage_limit = 100
      expect(@valid_promotion).to be_valid
    end

    it "validates name" do
      @valid_promotion.name = nil
      expect(@valid_promotion).not_to be_valid
    end
  end

  describe ".coupons" do
    it "scopes promotions with coupon code present only" do
      promotion = Spree::Promotion.create! name: "test", code: ''
      expect(Spree::Promotion.coupons).to be_empty

      promotion.update_column :code, "check"
      expect(Spree::Promotion.coupons.first).to eq promotion
    end
  end

  describe ".applied" do
    it "scopes promotions that have been applied to an order only" do
      promotion = Spree::Promotion.create! name: "test", code: ''
      expect(Spree::Promotion.applied).to be_empty

      promotion.orders << create(:order)
      expect(Spree::Promotion.applied.first).to eq promotion
    end
  end

  describe ".advertised" do
    let(:promotion) { create(:promotion) }
    let(:advertised_promotion) { create(:promotion, :advertise => true) }

    it "only shows advertised promotions" do
      advertised = Spree::Promotion.advertised
      expect(advertised).to include(advertised_promotion)
      expect(advertised).not_to include(promotion)
    end
  end

  describe "#destroy" do
    let(:promotion) { Spree::Promotion.create(:name => "delete me") }

    before(:each) do
      promotion.actions << Spree::Promotion::Actions::CreateAdjustment.new
      promotion.rules << Spree::Promotion::Rules::FirstOrder.new
      promotion.save!
      promotion.destroy
    end

    it "should delete actions" do
      expect(Spree::PromotionAction.count).to eq(0)
    end

    it "should delete rules" do
      expect(Spree::PromotionRule.count).to eq(0)
    end
  end

  describe "#save" do
    let(:promotion) { Spree::Promotion.create(:name => "delete me") }

    before(:each) do
      promotion.actions << Spree::Promotion::Actions::CreateAdjustment.new
      promotion.rules << Spree::Promotion::Rules::FirstOrder.new
      promotion.save!
    end

    it "should deeply autosave records and preferences" do
      promotion.actions[0].calculator.preferred_flat_percent = 10
      promotion.save!
      expect(Spree::Calculator.first.preferred_flat_percent).to eq(10)
    end
  end

  describe "#activate" do
    before do
      @action1 = Spree::Promotion::Actions::CreateAdjustment.create!
      @action2 = Spree::Promotion::Actions::CreateAdjustment.create!
      allow(@action1).to receive_messages perform: true
      allow(@action2).to receive_messages perform: true

      promotion.promotion_actions = [@action1, @action2]
      promotion.created_at = 2.days.ago

      @user = stub_model(Spree::LegacyUser, :email => "spree@example.com")
      @order = Spree::Order.create user: @user
      @payload = { :order => @order, :user => @user }
    end

    it "should check path if present" do
      promotion.path = 'content/cvv'
      @payload[:path] = 'content/cvv'
      expect(@action1).to receive(:perform).with(@payload)
      expect(@action2).to receive(:perform).with(@payload)
      promotion.activate(@payload)
    end

    it "does not perform actions against an order in a finalized state" do
      expect(@action1).not_to receive(:perform).with(@payload)

      @order.state = 'complete'
      promotion.activate(@payload)

      @order.state = 'awaiting_return'
      promotion.activate(@payload)

      @order.state = 'returned'
      promotion.activate(@payload)
    end

    it "does activate if newer then order" do
      expect(@action1).to receive(:perform).with(@payload)
      promotion.created_at = DateTime.now + 2
      expect(promotion.activate(@payload)).to be true
    end

    context "keeps track of the orders" do
      context "when activated" do
        it "assigns the order" do
          expect(promotion.orders).to be_empty
          expect(promotion.activate(@payload)).to be true
          expect(promotion.orders.first).to eql @order
        end
      end
      context "when not activated" do
        it "will not assign the order" do
          @order.state = 'complete'
          expect(promotion.orders).to be_empty
          expect(promotion.activate(@payload)).to be_falsey
          expect(promotion.orders).to be_empty
        end
      end

    end

  end

  context "#usage_limit_exceeded" do
    let(:promotable) { double('Promotable') }
    it "should not have its usage limit exceeded with no usage limit" do
      promotion.usage_limit = 0
      expect(promotion.usage_limit_exceeded?(promotable)).to be false
    end

    it "should have its usage limit exceeded" do
      promotion.usage_limit = 2
      allow(promotion).to receive_messages(:adjusted_credits_count => 2)
      expect(promotion.usage_limit_exceeded?(promotable)).to be true

      allow(promotion).to receive_messages(:adjusted_credits_count => 3)
      expect(promotion.usage_limit_exceeded?(promotable)).to be true
    end
  end

  context "#expired" do
    it "should not be exipired" do
      expect(promotion).not_to be_expired
    end

    it "should be expired if it hasn't started yet" do
      promotion.starts_at = Time.now + 1.day
      expect(promotion).to be_expired
    end

    it "should be expired if it has already ended" do
      promotion.expires_at = Time.now - 1.day
      expect(promotion).to be_expired
    end

    it "should not be expired if it has started already" do
      promotion.starts_at = Time.now - 1.day
      expect(promotion).not_to be_expired
    end

    it "should not be expired if it has not ended yet" do
      promotion.expires_at = Time.now + 1.day
      expect(promotion).not_to be_expired
    end

    it "should not be expired if current time is within starts_at and expires_at range" do
      promotion.starts_at  = Time.now - 1.day
      promotion.expires_at = Time.now + 1.day
      expect(promotion).not_to be_expired
    end

    it "should not be expired if usage limit is not exceeded" do
      promotion.usage_limit = 2
      allow(promotion).to receive_messages(:credits_count => 1)
      expect(promotion).not_to be_expired
    end
  end

  context "#credits_count" do
    let!(:promotion) do
      promotion = Spree::Promotion.new
      promotion.name = "Foo"
      promotion.code = "XXX"
      calculator = Spree::Calculator::FlatRate.new
      promotion.tap(&:save)
    end

    let!(:action) do
      calculator = Spree::Calculator::FlatRate.new
      action_params = { :promotion => promotion, :calculator => calculator }
      action = Spree::Promotion::Actions::CreateAdjustment.create(action_params)
      promotion.actions << action
      action
    end

    let!(:adjustment) do
      order = create(:order)
      Spree::Adjustment.create!(
        order:      order,
        adjustable: order,
        source:     action,
        amount:     10,
        label:      'Promotional adjustment'
      )
    end

    it "counts eligible adjustments" do
      adjustment.update_column(:eligible, true)
      expect(promotion.credits_count).to eq(1)
    end

    # Regression test for #4112
    it "does not count ineligible adjustments" do
      adjustment.update_column(:eligible, false)
      expect(promotion.credits_count).to eq(0)
    end
  end

  context "#products" do
    let(:promotion) { create(:promotion) }

    context "when it has product rules with products associated" do
      let(:promotion_rule) { Spree::Promotion::Rules::Product.new }

      before do
        promotion_rule.promotion = promotion
        promotion_rule.products << create(:product)
        promotion_rule.save
      end

      it "should have products" do
        expect(promotion.reload.products.size).to eq(1)
      end
    end

    context "when there's no product rule associated" do
      it "should not have products but still return an empty array" do
        expect(promotion.products).to be_blank
      end
    end
  end

  context "#eligible?" do
    let(:promotable) { create :order }
    subject { promotion.eligible?(promotable) }
    context "when promotion is expired" do
      before { promotion.expires_at = Time.now - 10.days }
      it { is_expected.to be false }
    end
    context "when promotable is a Spree::LineItem" do
      let(:promotable) { create :line_item }
      let(:product) { promotable.product }
      before do
        product.promotionable = promotionable
      end
      context "and product is promotionable" do
        let(:promotionable) { true }
        it { is_expected.to be true }
      end
      context "and product is not promotionable" do
        let(:promotionable) { false }
        it { is_expected.to be false }
      end
    end
    context "when promotable is a Spree::Order" do
      let(:promotable) { create :order }
      context "and it is empty" do
        it { is_expected.to be true }
      end
      context "and it contains items" do
        let!(:line_item) { create(:line_item, order: promotable) }
        context "and the items are all non-promotionable" do
          before do
            line_item.product.update_column(:promotionable, false)
          end
          it { is_expected.to be false }
        end
        context "and at least one item is promotionable" do
          it { is_expected.to be true }
        end
      end
    end
  end

  context "#eligible_rules" do
    let(:promotable) { double('Promotable') }
    it "true if there are no rules" do
      expect(promotion.eligible_rules(promotable)).to eq []
    end

    it "true if there are no applicable rules" do
      promotion.promotion_rules = [stub_model(Spree::PromotionRule, :eligible? => true, :applicable? => false)]
      allow(promotion.promotion_rules).to receive(:for).and_return([])
      expect(promotion.eligible_rules(promotable)).to eq []
    end

    context "with 'all' match policy" do
      let(:promo1) { Spree::PromotionRule.create! }
      let(:promo2) { Spree::PromotionRule.create! }

      before { promotion.match_policy = 'all' }

      context "when all rules are eligible" do
        before do
          allow(promo1).to receive_messages(eligible?: true, applicable?: true)
          allow(promo2).to receive_messages(eligible?: true, applicable?: true)

          promotion.promotion_rules = [promo1, promo2]
          allow(promotion.promotion_rules).to receive(:for).and_return(promotion.promotion_rules)
        end
        it "returns the eligible rules" do
          expect(promotion.eligible_rules(promotable)).to eq [promo1, promo2]
        end
        it "does set anything to eligiblity errors" do
          promotion.eligible_rules(promotable)
          expect(promotion.eligibility_errors).to be_nil
        end
      end

      context "when any of the rules is not eligible" do
        let(:errors) { double ActiveModel::Errors, empty?: false }
        before do
          allow(promo1).to receive_messages(eligible?: true, applicable?: true, eligibility_errors: nil)
          allow(promo2).to receive_messages(eligible?: false, applicable?: true, eligibility_errors: errors)

          promotion.promotion_rules = [promo1, promo2]
          allow(promotion.promotion_rules).to receive(:for).and_return(promotion.promotion_rules)
        end
        it "returns nil" do
          expect(promotion.eligible_rules(promotable)).to be_nil
        end
        it "sets eligibility errors to the first non-nil one" do
          promotion.eligible_rules(promotable)
          expect(promotion.eligibility_errors).to eq errors
        end
      end
    end

    context "with 'any' match policy" do
      let(:promotion) { Spree::Promotion.create(:name => "Promo", :match_policy => 'any') }
      let(:promotable) { double('Promotable') }

      it "should have eligible rules if any of the rules are eligible" do
        allow_any_instance_of(Spree::PromotionRule).to receive_messages(:applicable? => true)
        true_rule = Spree::PromotionRule.create(:promotion => promotion)
        allow(true_rule).to receive_messages(:eligible? => true)
        allow(promotion).to receive_messages(:rules => [true_rule])
        allow(promotion).to receive_message_chain(:rules, :for).and_return([true_rule])
        expect(promotion.eligible_rules(promotable)).to eq [true_rule]
      end

      context "when none of the rules are eligible" do
        let(:promo) { Spree::PromotionRule.create! }
        let(:errors) { double ActiveModel::Errors, empty?: false }
        before do
          allow(promo).to receive_messages(eligible?: false, applicable?: true, eligibility_errors: errors)

          promotion.promotion_rules = [promo]
          allow(promotion.promotion_rules).to receive(:for).and_return(promotion.promotion_rules)
        end
        it "returns nil" do
          expect(promotion.eligible_rules(promotable)).to be_nil
        end
        it "sets eligibility errors to the first non-nil one" do
          promotion.eligible_rules(promotable)
          expect(promotion.eligibility_errors).to eq errors
        end
      end
    end
  end

  describe '#line_item_actionable?' do
    let(:order) { double Spree::Order }
    let(:line_item) { double Spree::LineItem}
    let(:true_rule) { double Spree::PromotionRule, eligible?: true, applicable?: true, actionable?: true }
    let(:false_rule) { double Spree::PromotionRule, eligible?: true, applicable?: true, actionable?: false }
    let(:rules) { [] }

    before do
      allow(promotion).to receive(:rules) { rules }
      allow(rules).to receive(:for) { rules }
    end

    subject { promotion.line_item_actionable? order, line_item }

    context 'when the order is eligible for promotion' do
      context 'when there are no rules' do
        it { is_expected.to be }
      end

      context 'when there are rules' do
        context 'when the match policy is all' do
          before { promotion.match_policy = 'all' }

          context 'when all rules allow action on the line item' do
            let(:rules) { [true_rule] }
            it { is_expected.to be}
          end

          context 'when at least one rule does not allow action on the line item' do
            let(:rules) { [true_rule, false_rule] }
            it { is_expected.not_to be}
          end
        end

        context 'when the match policy is any' do
          before { promotion.match_policy = 'any' }

          context 'when at least one rule allows action on the line item' do
            let(:rules) { [true_rule, false_rule] }
            it { is_expected.to be }
          end

          context 'when no rules allow action on the line item' do
            let(:rules) { [false_rule] }
            it { is_expected.not_to be}
          end
        end
      end
    end

      context 'when the order is not eligible for the promotion' do
        before { promotion.starts_at = Time.current + 2.days }
        it { is_expected.not_to be }
      end
  end

  # regression for #4059
  # admin form posts the code and path as empty string
  describe "normalize blank values for code & path" do
    it "will save blank value as nil value instead" do
      promotion = Spree::Promotion.create(:name => "A promotion", :code => "", :path => "")
      expect(promotion.code).to be_nil
      expect(promotion.path).to be_nil
    end
  end

  # Regression test for #4081
  describe "#with_coupon_code" do
    context "and code stored in uppercase" do
      let!(:promotion) { create(:promotion, :code => "MY-COUPON-123") }
      it "finds the code with lowercase" do
        expect(Spree::Promotion.with_coupon_code("my-coupon-123")).to eql promotion
      end
    end
  end

  describe '#used_by?' do
    subject { promotion.used_by? user, [excluded_order] }

    let(:promotion) { Spree::Promotion.create! name: 'Test Used By' }
    let(:user) { create :user }
    let(:order) { create :completed_order_with_totals }
    let(:excluded_order) { create :completed_order_with_totals }

    before { promotion.orders << order }

    context 'when the user has used this promo' do
      before do
        order.user_id = user.id
        order.save!
      end

      context 'when the order is complete' do
        it { is_expected.to be true }

        context 'when the only matching order is the excluded order' do
          let(:excluded_order) { order }
          it { is_expected.to be false }
        end
      end

      context 'when the order is not complete' do
        let(:order) { create :order }
        it { is_expected.to be false }
      end
    end

    context 'when the user has not used this promo' do
      it { is_expected.to be false }
    end
  end

  describe "adding items to the cart" do
    let(:order) { create :order }
    let(:line_item) { create :line_item, order: order }
    let(:promo) { create :promotion_with_item_adjustment, adjustment_rate: 5, code: 'promo' }
    let(:variant) { create :variant }

    it "updates the promotions for new line items" do
      expect(line_item.adjustments).to be_empty
      expect(order.adjustment_total).to eq 0

      promo.activate order: order
      order.update!

      expect(line_item.adjustments.size).to eq(1)
      expect(order.adjustment_total).to eq -5

      other_line_item = order.contents.add(variant, 1, currency: order.currency)

      expect(other_line_item).not_to eq line_item
      expect(other_line_item.adjustments.size).to eq(1)
      expect(order.adjustment_total).to eq -10
    end
  end
end

redpajama_set_name: RedPajamaGithub


24A is a full-field transmission soft X-ray tomography beamline. Microscopy includes an on-line correlation of fluorescence structured-illumination microscopy (SIM) with soft X-ray tomography (SXT), which is dedicated to image frozen-hydrated biological specimen with a spatial resolution of 15-30 nm for 2D imaging and 50 nm for 3D tomography.
To image 3D cellular strustures by the correlation of fluorescence structured-illumination microscopy with soft X-ray tomography.